Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1451 - trunk/scenes


Chronological Thread 
  • From: thiago@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1451 - trunk/scenes
  • Date: Fri, 6 Jul 2007 14:54:26 -0600 (MDT)

Author: thiago
Date: Fri Jul  6 14:54:25 2007
New Revision: 1451

Modified:
   trunk/scenes/primtest.cc
Log:
Forgot to commit this in previous commit. This does the actual logic
for whether the file is a ply or obj file.

Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc    (original)
+++ trunk/scenes/primtest.cc    Fri Jul  6 14:54:25 2007
@@ -14,6 +14,7 @@
 #include <Model/MiscObjects/Intersection.h>
 #include <Model/MiscObjects/KeyFrameAnimation.h>
 #include <Model/Groups/Group.h>
+#include <Model/Groups/ObjGroup.h>
 #include <Model/Groups/DynBVH.h>
 #include <Model/Lights/PointLight.h>
 #include <Model/Materials/Checker.h>
@@ -77,7 +78,7 @@
   string material = "default";
   string texture = "default";
   string arraytype = "spin";
-  string modelName = 
"/usr/sci/data/Geometry/Stanford_Sculptures/bun_zipper_res4.ply";
+  string modelName = "";
   string imageName = "texture.tga";
   bool set_primtype = false;
   bool bgpoly = true;
@@ -359,60 +360,45 @@
     t.initWithScale(Vector(100, 100, 100));
     //t.initWithScale(Vector(1, 1, 1));
 
-    KeyFrameAnimation *animation = new 
KeyFrameAnimation(KeyFrameAnimation::linear);
-    AccelerationStructure *as= new Grid();
+    KeyFrameAnimation *animation = new KeyFrameAnimation();
+    //KeyFrameAnimation *animation = new 
KeyFrameAnimation(KeyFrameAnimation::linear);
+    //AccelerationStructure *as= new Grid();
+    AccelerationStructure *as= new DynBVH();
     group->add(animation);
     animation->useAccelerationStructure(as);
-    animation->startAnimation();
 
-    //delete group; group = new DynBVH();
 
-    /*    
-    ifstream in(modelName.c_str());
-    while (in) {
-      float x,y,z, d1, d2, d3, id;
-      in >>x >>y>>z>>d1>> d2>> d3>> id;
-      Vector center(x,y,z);
-      group->add(new Sphere(matl, center, .001 ));
+    Mesh *frame = NULL;
+    if (!strncmp(modelName.c_str()+modelName.length()-4, ".ply", 4)) {
+      frame = new Mesh;
+      if (!readPlyFile(modelName, t, frame, matl)) 
+        printf("error loading or reading ply file: %s\n", modelName.c_str());
+      animation->push_back(frame);
+    }
+    else if  (!strncmp(modelName.c_str()+modelName.length()-4, ".obj", 4)) {
+      frame = new ObjGroup(modelName.c_str());
+      animation->push_back(frame);
+    }
+    else {
+      //let load a hardcoded animation.
+      //TODO: do something smart so we don't need to hardcode this.
+      char model[128] = "/Users/thiago/data/models/hand/hand_00.obj";
+    //char model[128] = 
"/Users/thiago/data/models/armadillo-kz/frame001.obj";
+      for (int i=0; i <= 43; ++i) {
+        model[36] = '0'+(i/10);
+        model[37] = '0'+(i%10);
+//     for (int i=1; i < 11; ++i) {
+//       model[45] = '0'+(i/10);
+//       model[46] = '0'+(i%10);
+
+        cout <<"loading " <<model<<endl;
+        Group *frame = new ObjGroup(model);
+        animation->push_back(frame);
+      }
     }
-    */
-
-    AffineTransform t1;
-    t1.initWithScale(Vector(50, 50, 50));
-
-    AffineTransform t2;
-    t2.initWithScale(Vector(100, 100, 300));
-
-    AffineTransform t3;
-    t3.initWithScale(Vector(300, 100, 100));
-
-
-    Group *frame = new Group;
-    if (!readPlyFile(modelName, t, frame, 0, matl))
-       printf("error loading or reading ply file: %s\n", modelName.c_str()); 
//would be better to throw an error.
-
-    Group *frame2 = new Group;
-    string modelName2 = 
"/usr/sci/data/Geometry/Stanford_Sculptures/bun_zipper_res2.ply";
-    if (!readPlyFile(modelName, t1, frame2, 0, matl))
-       printf("error loading or reading ply file: %s\n", 
modelName2.c_str()); //would be better to throw an error.
-
-    Group *frame3 = new Group;
-    string modelName3 = 
"/usr/sci/data/Geometry/Stanford_Sculptures/bun_zipper_res3.ply";
-    if (!readPlyFile(modelName, t2, frame3, 0, matl))
-       printf("error loading or reading ply file: %s\n", 
modelName3.c_str()); //would be better to throw an error.
-
-    Group *frame4 = new Group;
-    string modelName4 = 
"/usr/sci/data/Geometry/Stanford_Sculptures/bun_zipper_res4.ply";
-    if (!readPlyFile(modelName, t3, frame4, 0, matl))
-       printf("error loading or reading ply file: %s\n", 
modelName4.c_str()); //would be better to throw an error.
-
-
-    animation->push_back(frame);
-    animation->push_back(frame2);
-    animation->push_back(frame3);
-    animation->push_back(frame4);
 
-    animation->setDuration(20);
+    animation->setDuration(3);
+    animation->startAnimation();
 
 #endif //USE_PRIVATE_CODE
   } else if (primtype == "heightfield") {
@@ -546,9 +532,9 @@
   scene->setObject(group);
 
   LightSet* lights = new LightSet();
-  lights->add(new PointLight(Vector(5,5,8), Color(RGB(1,1,1))*2));
-  Color cup(RGB(0.1, 0.3, 0.8));
-  Color cdown(RGB(0.82, 0.62, 0.62));
+  lights->add(new PointLight(Vector(-2,4,-8), Color(RGB(1,1,1))*1));
+  Color cup(RGB(0.3, 0.3, 0.3));
+  Color cdown(RGB(0.62, 0.62, 0.62));
   Vector up(0,1,0);
   lights->setAmbientLight(new ArcAmbient(cup, cdown, up));
   scene->setLights(lights);




  • [MANTA] r1451 - trunk/scenes, thiago, 07/06/2007

Archive powered by MHonArc 2.6.16.

Top of page