Text archives Help
- From: shirley@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1759 - trunk/scenes
- Date: Sat, 6 Oct 2007 18:45:49 -0600 (MDT)
Author: shirley
Date: Sat Oct 6 18:45:48 2007
New Revision: 1759
Added:
trunk/scenes/softshadow.cc
Modified:
trunk/scenes/CMakeLists.txt
Log:
16 point light test
Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Sat Oct 6 18:45:48 2007
@@ -40,6 +40,13 @@
TARGET_LINK_LIBRARIES(scene_teapotRoom ${MANTA_SCENE_LINK})
ENDIF(SCENE_TEAPOT_ROOM)
+# softshadow via many point sources
+SET(SCENE_SOFT_SHADOW TRUE CACHE BOOL "Soft Shadow test")
+IF(SCENE_SOFT_SHADOW)
+ ADD_LIBRARY(scene_softshadow softshadow.cc)
+ TARGET_LINK_LIBRARIES(scene_softshadow ${MANTA_SCENE_LINK})
+ENDIF(SCENE_SOFT_SHADOW)
+
# octree isosurface
SET(SCENE_OCTISOVOL 0 CACHE BOOL "octree isosurface")
IF(SCENE_OCTISOVOL)
Added: trunk/scenes/softshadow.cc
==============================================================================
--- (empty file)
+++ trunk/scenes/softshadow.cc Sat Oct 6 18:45:48 2007
@@ -0,0 +1,154 @@
+#include <Interface/Scene.h>
+#include <Interface/LightSet.h>
+
+#include <Model/Groups/ObjGroup.h>
+#include <Model/Groups/DynBVH.h>
+
+#include <Model/Materials/Checker.h>
+#include <Model/Materials/CopyTextureMaterial.h>
+#include <Model/Materials/Dielectric.h>
+#include <Model/Materials/Lambertian.h>
+#include <Model/Materials/MetalMaterial.h>
+#include <Model/Materials/Phong.h>
+
+#include <Model/Textures/Constant.h>
+#include <Model/Textures/MarbleTexture.h>
+
+#include <Model/Primitives/Cube.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/Primitives/Parallelogram.h>
+
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/AmbientLights/ArcAmbient.h>
+
+#include <Core/Exceptions/IllegalArgument.h>
+
+#include <iostream>
+
+using namespace Manta;
+using namespace std;
+
+#define Rect(material, center, dir1, dir2) \
+ Parallelogram(material, (center) - (dir1) - (dir2), (dir1)*2, (dir2)*2)
+
+class TeapotObjGroup: public ObjGroup {
+public:
+ TeapotObjGroup( const char* filename ):
+ ObjGroup(filename)
+ {
+ }
+
+protected:
+ virtual void create_materials( Glm::GLMmodel *model )
+ {
+ // Here we are going to override the materials with our stuff
+
+
//////////////////////////////////////////////////////////////////////////
+ // Path to the model for loading textures.
+ string model_path = model->pathname;
+
+ size_t pos = model_path.rfind( '/' );
+ if (pos != string::npos) {
+ model_path = model_path.substr( 0, pos+1 );
+ }
+
+ material_array = new Material *[ model->nummaterials ];
+ material_array_size = model->nummaterials;
+
+ // Just override the materials
+ for (unsigned int i=0;i<model->nummaterials;++i) {
+ material_array[i] = new Lambertian(new
Constant<Color>(Color(RGB(1,0,1))));
+ }
+ }
+};
+
+void usage()
+{
+ cerr << "Valid options for scene:\n";
+ cerr << " -model - Required. The file to load.\n";
+}
+
+void argumentError(int i, const vector<string>& args)
+{
+ usage();
+ throw IllegalArgument("scene teapotRoom", i, args);
+}
+
+void addTable(Group* group)
+{
+ // Top
+ Material* legs = new MetalMaterial( Color::white() * 0.01 );
+ Object* box=new Sphere(legs, Vector(-100,-100,-10), 100 );
+ group->add(box);
+}
+
+void addFloor(Group* group)
+{
+ Material* white = new Lambertian(Color::white() * 0.8);
+
+ Object* floor=new Rect(white,
+ Vector(0,0,-200),
+ Vector(1600,0,0),
+ Vector(0,1600,0));
+ group->add(floor);
+}
+
+
+extern "C"
+Scene* make_scene(const ReadContext&, const vector<string>& args)
+{
+ for(size_t i=0;i<args.size();i++){
+ string arg = args[i];
+ if (arg == "--help") {
+ usage();
+ return 0;
+ }
+ }
+
+ // Start adding geometry
+ Group* group = new Group();
+
+ addTable(group);
+ addFloor(group);
+
+ Scene* scene = new Scene();
+ scene->setBackground(new ConstantBackground(Color(RGB(0.1, 0.1, 0.1))));
+
+ DynBVH* bvh = new DynBVH();
+ bvh->setGroup(group);
+ scene->setObject(bvh);
+
+ LightSet* lights = new LightSet();
+ lights->add(new PointLight(Vector(225,375,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(375,300,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(400,350,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(550,325,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(275,425,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(300,400,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(475,450,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(500,475,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(250,575,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(350,525,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(525,500,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(425,550,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(200,600,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(325,675,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(450,625,1300), Color(RGB(1,1,1))*0.05));
+ lights->add(new PointLight(Vector(575,650,1300), Color(RGB(1,1,1))*0.05));
+ Color cup(RGB(0.5, 0.5, 0));
+ Color cdown(RGB(0.1, 0.1, 0.7));
+ Vector up(0,0,1);
+ // Vector up(0,1,0);
+ lights->setAmbientLight(new ArcAmbient(cup, cdown, up));
+ scene->setLights(lights);
+
+ // Add a default camera
+ Vector eye(700,1390,300);
+ Vector lookat(0,0,150);
+ Real fov=45;
+ scene->addBookmark("default view", eye, lookat, up, fov, fov);
+
+ return scene;
+}
+
- [Manta] r1759 - trunk/scenes, shirley, 10/06/2007
Archive powered by MHonArc 2.6.16.