Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1745 - in trunk: Model/Groups scenes
- Date: Fri, 28 Sep 2007 17:04:09 -0600 (MDT)
Author: bigler
Date: Fri Sep 28 17:04:08 2007
New Revision: 1745
Added:
trunk/scenes/teapotRoom.cc
Modified:
trunk/Model/Groups/ObjGroup.h
trunk/scenes/CMakeLists.txt
Log:
Model/Groups/ObjGroup.h
Make the class member veriables protected insetad of private. This
allows for some custom actions when loading the materials.
scenes/CMakeLists.txt
scenes/teapotRoom.cc
Add the beginnings of the original teapot scene from rtrt.
Modified: trunk/Model/Groups/ObjGroup.h
==============================================================================
--- trunk/Model/Groups/ObjGroup.h (original)
+++ trunk/Model/Groups/ObjGroup.h Fri Sep 28 17:04:08 2007
@@ -15,9 +15,9 @@
ObjGroup( const char *filename,
Material *defaultMaterial=NULL ) throw (InputError);
virtual ~ObjGroup();
-
- private:
- void create_materials( Glm::GLMmodel *model );
+
+ protected:
+ virtual void create_materials( Glm::GLMmodel *model );
Material **material_array;
unsigned material_array_size;
Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Fri Sep 28 17:04:08 2007
@@ -26,6 +26,13 @@
TARGET_LINK_LIBRARIES(scene_primtest ${MANTA_SCENE_LINK})
ENDIF(SCENE_PRIMTEST)
+# Old RTRT teapot scene
+SET(SCENE_TEAPOT_ROOM TRUE CACHE BOOL "Old RTRT teapot scene")
+IF(SCENE_TEAPOT_ROOM)
+ ADD_LIBRARY(scene_teapotRoom teapotRoom.cc)
+ TARGET_LINK_LIBRARIES(scene_teapotRoom ${MANTA_SCENE_LINK})
+ENDIF(SCENE_TEAPOT_ROOM)
+
# octree isosurface
SET(SCENE_OCTISOVOL 0 CACHE BOOL "octree isosurface")
IF(SCENE_OCTISOVOL)
Added: trunk/scenes/teapotRoom.cc
==============================================================================
--- (empty file)
+++ trunk/scenes/teapotRoom.cc Fri Sep 28 17:04:08 2007
@@ -0,0 +1,245 @@
+#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/Parallelogram.h>
+
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/AmbientLights/ArcAmbient.h>
+
+
+#include <Core/Exceptions/IllegalArgument.h>
+
+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* glass= new Dielectric(1.5, 1.0, Color(RGB(.80, .93 ,
.87)).Pow(.02));//, 0.001);
+ Object* box=new Cube(glass, Vector(-500,-100,-10), Vector(300,300,0) );
+ group->add(box);
+
+ // Legs
+ Material* legs = new MetalMaterial( Color::white() * 0.01 );
+ group->add(new Cube(legs, Vector(-480,-80,-200), Vector(-450,-50,-10) ) );
+ group->add(new Cube(legs, Vector(-480,250,-200), Vector(-450,280,-10) ) );
+ group->add(new Cube(legs, Vector(250,-80,-200), Vector(280,-50,-10) ) );
+ group->add(new Cube(legs, Vector(250,250,-200), Vector(280,280,-10) ) );
+
+ // Crossbars
+ group->add(new Cube(legs, Vector(-450,-70,-40), Vector(250,-60,-10) ) );
+ group->add(new Cube(legs, Vector(-450,260,-40), Vector(250,280,-10) ) );
+ group->add(new Cube(legs, Vector(-470,-70,-40), Vector(-460,250,-10) ) );
+ group->add(new Cube(legs, Vector(260,-70,-40), Vector(270,250,-10) ) );
+}
+
+void addFloor(Group* group)
+{
+ /* RTRT CrowMarble(double scale,
+ const Vector& direction,
+ const Color& c1,
+ const Color& c2,
+ const Color& c3)
+ FastTurbulence(int _noctaves = 6,
+ double _a = 0.5,
+ double _s = 2.0,
+ int seed = 0,
+ int tblsize = 4096)
+ */
+
+ /* Manta MarbleTexture(
+ ValueType const &value1,
+ ValueType const &value2,
+ Real const scale,
+ Real const fscale,
+ Real const tscale,
+ int const octaves,
+ Real const lacunarity,
+ Real const gain );
+ */
+
+ MarbleTexture<Color>* mtex1=new MarbleTexture<Color>
+ (
+ Color(RGB(0.5,0.6,0.6)), // value1
+ //Color(RGB(0.4,0.55,0.52)),
+ Color(RGB(0.35,0.45,0.42)), // value2
+ 10, // scale
+ // Vector(2,1,0) // RTRT direction
+ 2.0, // fscale (From RTRT dir?)
+ 15.0, // tscale
+ 6, // octaves
+ 2.0, // lacunarity (_s?)
+ 0.5 // gain (_a?)
+ );
+ MarbleTexture<Color>* mtex2=new MarbleTexture<Color>
+ (
+ Color(RGB(0.4,0.3,0.2)), // value1
+ //Color(RGB(0.35,0.34,0.32)),
+ Color(RGB(0.20,0.24,0.24)), // value2
+ 15, // scale
+ // Vector(-1,3,0) // RTRT direction
+ 1, // fscale (From RTRT dir?)
+ 10, // tscale
+ 6, // octaves
+ 2.0, // lacunarity (_s?)
+ 0.5 // gain (_a?)
+ );
+ MarbleTexture<Color>* mtex3=new MarbleTexture<Color>
+ (Color(RGB(0.1,0.2,0.5)), Color(RGB(0.7,0.8,1.0)),
+ 10.0, 1.0, 15.0, 6, 2.0, 0.6 );
+
+ Material* marble1=new Phong(
+ mtex1,
+ new Constant<Color>(Color::white()*0.6),
+ 100,
+ new Constant<ColorComponent>(0)
+ );
+ Material* marble2=new Phong(
+ mtex2,
+ new Constant<Color>(Color::white()*0.6),
+ 100,
+ new Constant<ColorComponent>(0)
+ );
+
+ Material* checkered_floor = new Checker(marble1,
+ marble2,
+ Vector(16,0,0), Vector(0,16,0));
+ //Vector(0.005,0,0), Vector(0,0.0050,0));
+
+ // checkered_floor = new CopyTextureMaterial(new
Constant<Color>(Color::white()));
+ Object* floor=new Rect(checkered_floor,
+ Vector(0,0,-200),
+ Vector(1600,0,0),
+ Vector(0,1600,0));
+ group->add(floor);
+}
+
+void addWalls(Group* group)
+{
+ Material* white = new Lambertian(Color::white() * 0.8);
+ group->add( // room10
+ new Rect(white, Vector(1600,0,600), Vector(0,0,800),
Vector(0,1600,0))
+ );
+
+ group->add( // room00
+ new Rect(white, Vector(-1600,0,600), Vector(0,0,800),
Vector(0,1600,0))
+ );
+
+ group->add( // room11
+ new Rect(white, Vector(0,1600,600), Vector(0,0,800),
Vector(1600, 0,0))
+ );
+
+ group->add( // room01
+ new Rect(white, Vector(0,-1600,600), Vector(0,0,800),
Vector(1600, 0,0))
+ );
+
+// group->add( // ceiling (roomtb)
+// new Rect(white, Vector(0,0,1400), Vector(0,1600,0),
Vector(1600, 0,0))
+// );
+
+}
+
+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);
+ addWalls(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(200,400,1300), Color(RGB(1,1,1))*0.8));
+ 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] r1745 - in trunk: Model/Groups scenes, bigler, 09/28/2007
Archive powered by MHonArc 2.6.16.