INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
ray-tracer.cpp
1#include <qapplication.h>
2#include <iostream>
3#include <fstream>
4#include <sstream>
5#include <string>
6#include "Viewer.h"
7#include "Scene.h"
8#include "Sphere.h"
9#include "Material.h"
10#include "PointLight.h"
11
12using namespace std;
13using namespace rt;
14
15int main(int argc, char** argv)
16{
17 // Read command lines arguments.
18 QApplication application(argc,argv);
19
20 // Creates a 3D scene
21 Scene scene;
22
23 // Light at infinity
24 Light* light0 = new PointLight( GL_LIGHT0, Point4( 0,0,1,0 ),
25 Color( 1.0, 1.0, 1.0 ) );
26 Light* light1 = new PointLight( GL_LIGHT1, Point4( 7,5,15,1 ),
27 Color( 1.0, 1.0, 1.0 ) );
28 scene.addLight( light0 );
29 scene.addLight( light1 );
30
31 // Objects
32 Sphere* sphere1 = new Sphere( Point3( 0, 0, 0), 2.0, Material::bronze() );
33 Sphere* sphere2 = new Sphere( Point3( 0, 4, 0), 1.0, Material::emerald() );
34 scene.addObject( sphere1 );
35 scene.addObject( sphere2 );
36
37 // Instantiate the viewer.
38 Viewer viewer;
39 // Give a name
40 viewer.setWindowTitle("Ray-tracer preview");
41
42 // Sets the scene
43 viewer.setScene( scene );
44
45 // Make the viewer window visible on screen.
46 viewer.show();
47 // Run main loop.
48 application.exec();
49 return 0;
50}
Definition Viewer.h:6
Namespace RayTracer.
Definition Color.h:11
PointVector< Real, 3 > Point3
The type for representing a 3d vector;.
Lights are used to give lights in a scene.
Definition Light.h:17
void addObject(GraphicalObject *anObject)
Adds a new object to the scene.
Definition Scene.h:69
void addLight(Light *aLight)
Adds a new light to the scene.
Definition Scene.h:75
A sphere is a concrete GraphicalObject that represents a sphere in 3D space.
Definition Sphere.h:15