Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2161 - trunk/Model/Groups


Chronological Thread 
  • From: "Thiago Ize" <thiago@sci.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2161 - trunk/Model/Groups
  • Date: Tue, 1 Apr 2008 21:04:57 -0600 (MDT)

Author: thiago
Date: Tue Apr  1 21:04:57 2008
New Revision: 2161

Modified:
   trunk/Model/Groups/Mesh.cc
   trunk/Model/Groups/Mesh.h
Log:
Added the function scaleMesh which will scale the mesh.
This is particularly useful for normalizing mesh sizes
of very small or big meshes which otherwise would have
rendered incorrectly due to Manta's (current) use of a
fixed epsilon size.

Modified: trunk/Model/Groups/Mesh.cc
==============================================================================
--- trunk/Model/Groups/Mesh.cc  (original)
+++ trunk/Model/Groups/Mesh.cc  Tue Apr  1 21:04:57 2008
@@ -5,6 +5,7 @@
 #include <Core/Util/Preprocessor.h>
 #include <Core/Util/UpdateGraph.h>
 #include <Interface/InterfaceRTTI.h>
+#include <Interface/Context.h>
 #include <Model/Groups/Mesh.h>
 #include <Model/Primitives/MeshTriangle.h>
 
@@ -342,6 +343,22 @@
       i-=3;
     }
   }
+}
+
+void Mesh::scaleMesh(Real scalingFactor)
+{
+  if (dirtybbox) {
+    PreprocessContext dummyContext;
+    computeBounds(dummyContext, 0, 1);
+  }
+
+  Vector center = bbox.center();
+
+  for (size_t i=0; i < vertices.size(); ++i)
+    vertices[i] = scalingFactor*(vertices[i] - center);
+
+  bbox[0] = scalingFactor*(bbox[0] - center);
+  bbox[1] = scalingFactor*(bbox[1] - center);
 }
 
 namespace Manta {

Modified: trunk/Model/Groups/Mesh.h
==============================================================================
--- trunk/Model/Groups/Mesh.h   (original)
+++ trunk/Model/Groups/Mesh.h   Tue Apr  1 21:04:57 2008
@@ -99,6 +99,9 @@
     //removes degenerate triangles from mesh.
     void removeDegenerateTriangles();
 
+    //Resize the mesh geometry so the diagonal is scalingFactor longer.
+    void scaleMesh(Real scalingFactor);
+
     void readwrite(ArchiveElement* archive);
   };
 




  • [Manta] r2161 - trunk/Model/Groups, Thiago Ize, 04/01/2008

Archive powered by MHonArc 2.6.16.

Top of page