Skip to content

Instantly share code, notes, and snippets.

@wridgers
Created January 18, 2013 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wridgers/4569544 to your computer and use it in GitHub Desktop.
Save wridgers/4569544 to your computer and use it in GitHub Desktop.
bool Tracer::loadExampleScene()
{
// render settings
// lighting settings
Tracer::useAmbientLighting(true);
Tracer::setAmbientLightingColour(Colour(255, 255, 255));
Tracer::setAmbientLightingIntensity(0.05);
// lights
// create a light
Light *light = new Light();
light->setPosition(Vector3(500,500,0));
light->setColour(Colour(255,255,255));
// add to the scene
Tracer::lights.push_back(light);
// camera
Tracer::camera = new Camera();
// props
// props need materials
Sphere *sphere = new Sphere();
sphere->setPosition(Vector3(150,0,200));
sphere->setRadius(100);
// give it a material
Material *red = new Material();
red->setColour(Colour(255,0,0));
// apply!
sphere->setMaterial(red);
// add it to the scene
Tracer::spheres.push_back(sphere);
// another sphere!
sphere = new Sphere();
sphere->setPosition(Vector3(-150,0,200));
sphere->setRadius(100);
// give it a material
Material *blue = new Material();
blue->setColour(Colour(0,0,255));
blue->setSpecularReflectionCoeff(0);
// apply!
sphere->setMaterial(blue);
// add it to the scene
Tracer::spheres.push_back(sphere);
// another sphere!
sphere = new Sphere();
sphere->setPosition(Vector3(0,0,800));
sphere->setRadius(100);
// apply!
sphere->setMaterial(red);
// add it to the scene
Tracer::spheres.push_back(sphere);
// action!
return true;
// TODO: delete scene
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment