proj home

Files   Classes   Functions   Hierarchy  

vrmlconvert Class Reference

Convert VRML to vrmlshape class. More...

#include <vrmlconvert.h>

List of all members.

Public Member Functions

boolc eval (vector< vrmlshape > &s, vrmlshapeparse const &p) const
 Convert the parser to vmrlshape objects.


Detailed Description

Convert VRML to vrmlshape class.

The VRML is restricted to points and normals as triangles.

Example
  vrmlshapeparse p;
  p.readfile("p3.wrl");

  vector<vrmlshape> s;
  vrmlconvert()(s,p);
Note that no optimization occures. If a software package exports crap VRML - for example every triangle is an indexed face set this converter stores each triangle as a vrmlshape. I suggest using something to compile the static geometry (eg OpenGL display lists) after it has been converted.

Definition at line 36 of file vrmlconvert.h.


Member Function Documentation

boolc vrmlconvert::eval ( vector< vrmlshape > &  s,
vrmlshapeparse const &  p 
) const

Convert the parser to vmrlshape objects.

Definition at line 140 of file vrmlconvert.cpp.

References vrmlshapeparse::vshp.

Referenced by vrmltest::test01().

00144 {
00145   vector< vrmlshaperaw > const & v(p.vshp);
00146 
00147   if(!hastriangles(v))
00148     return false;
00149 
00150   // Iterate writing shapes.
00151   vrmlshape * curr = 0;
00152 
00153   uintc imax = v.size();
00154   for (uint i=0; i<imax; ++i)
00155   {
00156     if (!v[i].istriangles)
00157       continue;
00158 
00159     if (s.empty())
00160     {
00161       s.push_back(vrmlshape());
00162       curr = & s.back();
00163       writepointsandnormals(*curr,v[i]); 
00164       writeattributes(*curr,v[i]);
00165     }
00166     else
00167     {
00168       curr = & s.back();
00169       if (equalattributes(*curr,v[i]))
00170       {
00171         writepointsandnormals(*curr,v[i]); 
00172       }
00173       else
00174       {
00175         s.push_back(vrmlshape());
00176         writepointsandnormals(*curr,v[i]); 
00177         writeattributes(*curr,v[i]);
00178       }
00179     }
00180   }
00181 
00182   return true;
00183 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:24 2011 for Chelton Evans Source by  doxygen 1.5.8