readded original ex1
This commit is contained in:
parent
6d78d8c554
commit
3d17719e12
1 changed files with 8 additions and 10 deletions
18
ex1.cpp
18
ex1.cpp
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
#include "shader/flatshader.h"
|
#include "shader/flatshader.h"
|
||||||
|
|
||||||
int main()
|
int main() {
|
||||||
{
|
|
||||||
// Let's create a simple cornell box scene...
|
// Let's create a simple cornell box scene...
|
||||||
SimpleScene scene;
|
SimpleScene scene;
|
||||||
|
|
||||||
|
@ -19,7 +18,6 @@ int main()
|
||||||
auto red = std::make_shared<FlatShader>(Color(1.0f, 0.3f, 0.2f));
|
auto red = std::make_shared<FlatShader>(Color(1.0f, 0.3f, 0.2f));
|
||||||
auto white = std::make_shared<FlatShader>(Color(1.0f, 1.0f, 1.0f));
|
auto white = std::make_shared<FlatShader>(Color(1.0f, 1.0f, 1.0f));
|
||||||
auto blue = std::make_shared<FlatShader>(Color(0.2f, 0.3f, 1.0f));
|
auto blue = std::make_shared<FlatShader>(Color(0.2f, 0.3f, 1.0f));
|
||||||
auto black = std::make_shared<FlatShader>(Color(0, 0, 0));
|
|
||||||
|
|
||||||
// Add shaders for the objects
|
// Add shaders for the objects
|
||||||
auto green = std::make_shared<FlatShader>(Color(0.0f, 1.0f, 0.0f));
|
auto green = std::make_shared<FlatShader>(Color(0.0f, 1.0f, 0.0f));
|
||||||
|
@ -27,7 +25,7 @@ int main()
|
||||||
auto orange = std::make_shared<FlatShader>(Color(1.0f, 0.5f, 0.0f));
|
auto orange = std::make_shared<FlatShader>(Color(1.0f, 0.5f, 0.0f));
|
||||||
|
|
||||||
// Set up the cornell box walls
|
// Set up the cornell box walls
|
||||||
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, +5.0f), Vector3d(0.0f, 0.0f, -1.0f), black));
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, +5.0f), Vector3d(0.0f, 0.0f, -1.0f), purple));
|
||||||
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, -5.0f), Vector3d(0.0f, 0.0f, +1.0f), purple));
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, -5.0f), Vector3d(0.0f, 0.0f, +1.0f), purple));
|
||||||
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, +5.0f, 0.0f), Vector3d(0.0f, -1.0f, 0.0f), white));
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, +5.0f, 0.0f), Vector3d(0.0f, -1.0f, 0.0f), white));
|
||||||
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, -5.0f, 0.0f), Vector3d(0.0f, +1.0f, 0.0f), white));
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, -5.0f, 0.0f), Vector3d(0.0f, +1.0f, 0.0f), white));
|
||||||
|
@ -35,16 +33,16 @@ int main()
|
||||||
scene.add(std::make_shared<InfinitePlane>(Vector3d(-5.0f, 0.0f, 0.0f), Vector3d(+1.0f, 0.0f, 0.0f), red));
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(-5.0f, 0.0f, 0.0f), Vector3d(+1.0f, 0.0f, 0.0f), red));
|
||||||
|
|
||||||
// Add a sphere
|
// Add a sphere
|
||||||
scene.add(std::make_shared<Sphere>(Vector3d(0.0f, 0.0f, 0.0f), 0.5f, green));
|
scene.add(std::make_shared<Sphere>(Vector3d(-3.0f, 0.0f, 0.0f), 1.5f, green));
|
||||||
scene.add(std::make_shared<Triangle>(Vector3d(0.5f, 0.0f, 0.0f), Vector3d(-0.5f, 0.0f, 0.0f),
|
scene.add(std::make_shared<Triangle>(Vector3d(0.0f, -5.0f, -4.0f), Vector3d(0.0f, -3.0f, 0.0f),
|
||||||
Vector3d(0.0f, 0.0f, 0.5f), orange));
|
Vector3d(5.0f, -2.0f, -3.0f), orange));
|
||||||
|
|
||||||
// Set up the camera
|
// Set up the camera
|
||||||
PerspectiveCamera camera;
|
PerspectiveCamera camera;
|
||||||
camera.setFovAngle(70);
|
camera.setFovAngle(70);
|
||||||
camera.setPosition(Vector3d(0.0f, 4.0f, 0.0f));
|
camera.setPosition(Vector3d(-2.5f, 2.5f, -10.0f));
|
||||||
camera.setForwardDirection(Vector3d(0.0f, -1.0f, 0.0f));
|
camera.setForwardDirection(Vector3d(0.25f, -0.33f, 1.0f));
|
||||||
camera.setUpDirection(Vector3d(0.0f, 0.0f, 1.0f));
|
camera.setUpDirection(Vector3d(0.2f, 1.0f, 0.0f));
|
||||||
|
|
||||||
// Render the scene
|
// Render the scene
|
||||||
SimpleRenderer renderer;
|
SimpleRenderer renderer;
|
||||||
|
|
Loading…
Reference in a new issue