proj home

Files   Classes   Functions   Hierarchy  

vrmlshape.h

Go to the documentation of this file.
00001 #ifndef VRMLSHAPE_H
00002 #define VRMLSHAPE_H
00003 
00004 #include <cassert>
00005 #include <vector>
00006 using namespace std;
00007 
00008 #include <typedefs.h>
00009 
00010 /*
00011 \brief  Using VRML as a primitive graphics format.
00012 
00013  EVERYTHING IS TRIANGLES,
00014  NON-TRIANGLE STRUCTURES ARE NOT SUPPORTED.
00015  (possible extensions are lines, because primitive)
00016 
00017  Using VRML as a primitive graphics format this data
00018  structure represents two different formats: 
00019    -  Primitive VRML
00020    -  Triangle Stream.
00021   
00022  The write{P,PN,PNC} expect the data in Triangle Stream
00023  format where the corresponding vectors are triangles.
00024 */
00025 class vrmlshape
00026 {
00027 public:
00028 
00030   vector<float> point;
00032   vector<float> normal;
00034   vector<float> color;
00035   
00037   float diffuseColor[3];
00040   void diffuseColorWrite() const;
00041 
00043   ostream & print( ostream & os ) const;
00044 
00046   void writeP() const;
00048   void writePN() const;
00050   void writePNC() const;
00051 
00054   void writePwind() const;
00055 };
00056 
00057 
00061 class vrmllines
00062 {
00063 public:
00064 
00067   vector<float> point;
00070   vector<float> color;
00071 
00073   void writeP() const;
00075   void writePC() const;
00076 
00079   template< typename T >
00080   void addnormals
00081   ( 
00082     vrmlshape& s,
00083     T const & col,
00084     floatc len
00085   )
00086   {
00087     if (s.normal.empty())
00088       return;
00089 
00090     uintc imax = s.normal.size();
00091     for (uint i=0; i<imax; i+=3)
00092     {
00093       point.push_back( s.point[i] );
00094       point.push_back( s.point[i+1] );
00095       point.push_back( s.point[i+2] );
00096 
00097       point.push_back( s.point[i]+len*s.normal[i] );
00098       point.push_back( s.point[i+1]+len*s.normal[i+1] );
00099       point.push_back( s.point[i+2]+len*s.normal[i+2] );
00100 
00101       color.push_back(col[0]);
00102       color.push_back(col[1]);
00103       color.push_back(col[2]);
00104       color.push_back(col[0]);
00105       color.push_back(col[1]);
00106       color.push_back(col[2]);
00107     }
00108   }
00109 };
00110 
00111 #endif
00112 
00113 

Generated on Fri Mar 4 00:49:32 2011 for Chelton Evans Source by  doxygen 1.5.8