proj home

Files   Classes   Functions   Hierarchy  

vrmlshape Class Reference

#include <vrmlshape.h>

Collaboration diagram for vrmlshape:
Collaboration graph

List of all members.

Public Member Functions

void diffuseColorWrite () const
 Write the diffuse color if it is enabled by having non negative values.
ostreamprint (ostream &os) const
 For debug print out the classes attributes.
void writeP () const
 Write wireframe triangles.
void writePN () const
 Write Point and Normal per point triangles.
void writePNC () const
 Write Point, Normal and Color per point triangles.
void writePwind () const
 Write the triangles winding by coloring in the vertices Red, Green and Blue.

Public Attributes

vector< float > point
 Each 3 floats is a point and 3 points per triangle.
vector< float > normal
 Each 3 floats is a normal and 3 normals per triangle.
vector< float > color
 Each 3 floats is a color and 3 colors per triangle.
float diffuseColor [3]
 The global color.

Detailed Description

Definition at line 25 of file vrmlshape.h.


Member Function Documentation

void vrmlshape::diffuseColorWrite (  )  const

Write the diffuse color if it is enabled by having non negative values.

Definition at line 95 of file vrmlshape.cpp.

References diffuseColor.

Referenced by writeP(), and writePN().

00096 {
00097   assert(diffuseColor[0]>=0.0);
00098 
00099   glColor3f
00100   (
00101     diffuseColor[0],
00102     diffuseColor[1],
00103     diffuseColor[2]
00104   );
00105 }

ostream & vrmlshape::print ( ostream os  )  const

For debug print out the classes attributes.

Definition at line 53 of file vrmlshape.cpp.

References color, diffuseColor, normal, and point.

00054 {
00055   os << "diffuseColor: ";
00056   os << diffuseColor[0] << " ";
00057   os << diffuseColor[1] << " ";
00058   os << diffuseColor[2] << " ";
00059   os << endl;
00060 
00061   os << "point:" << endl;
00062 
00063   for (uint i=0; i<point.size(); ++i)
00064   {
00065     os << point[i] << " ";
00066     if ((i+1)%3==0)
00067       os << endl;
00068   }
00069   os << endl;
00070 
00071   os << "normal:" << endl;
00072 
00073   for (uint i=0; i<normal.size(); ++i)
00074   {
00075     os << normal[i] << " ";
00076     if ((i+1)%3==0)
00077       os << endl;
00078   }
00079   os << endl;
00080 
00081   os << "color:" << endl;
00082 
00083   for (uint i=0; i<color.size(); ++i)
00084   {
00085     os << color[i] << " ";
00086     if ((i+1)%3==0)
00087       os << endl;
00088   }
00089   os << endl;
00090 
00091   return os;
00092 }

void vrmlshape::writeP (  )  const

Write wireframe triangles.

Definition at line 108 of file vrmlshape.cpp.

References diffuseColorWrite(), and point.

00109 {
00110   uintc sz = point.size();
00111 
00112   if (sz==0)
00113     return;
00114 
00115 //<TODO> look at this code, does writeP() word?
00116   glBegin(GL_LINES);
00117 //  glBegin(GL_TRIANGLES);
00118 
00119   diffuseColorWrite();
00120 
00121   assert((point.size()%3)==0);
00122 
00123   for (uint i=0; i<sz; i+=9 )
00124   {
00125     glVertex3f(point[i+0],point[i+1],point[i+2]);
00126     glVertex3f(point[i+3],point[i+4],point[i+5]);
00127     glVertex3f(point[i+3],point[i+4],point[i+5]);
00128     glVertex3f(point[i+6],point[i+7],point[i+8]);
00129     glVertex3f(point[i+6],point[i+7],point[i+8]);
00130     glVertex3f(point[i+0],point[i+1],point[i+2]);
00131   }
00132 
00133   glEnd();
00134 }

void vrmlshape::writePN (  )  const

Write Point and Normal per point triangles.

Definition at line 136 of file vrmlshape.cpp.

References axes(), diffuseColorWrite(), normal, and point.

00137 {
00138   uintc sz = point.size();
00139 
00140   if (sz==0)
00141     return;
00142 
00143   assert(sz==normal.size());
00144 
00145 
00146 #ifdef DEBUG_VRMLSHAPE
00147 axes(0.25);
00148 #endif
00149 
00150 
00151   glBegin(GL_TRIANGLES);
00152 
00153   diffuseColorWrite();
00154 
00155   for (uint i=0; i<sz; i+=3 )
00156   {
00157     glNormal3f(normal[i],normal[i+1],normal[i+2]);
00158     glVertex3f(point[i],point[i+1],point[i+2]);
00159   }
00160 
00161   glEnd();
00162 }

void vrmlshape::writePNC (  )  const

Write Point, Normal and Color per point triangles.

Definition at line 164 of file vrmlshape.cpp.

References color, normal, and point.

00165 {
00166   uintc sz = point.size();
00167 
00168   if (sz==0)
00169     return;
00170 
00171   assert(sz==normal.size());
00172   assert(sz==color.size());
00173 
00174   glBegin(GL_TRIANGLES);
00175 
00176   for (uint i=0; i<sz; i+=3 )
00177   {
00178     glNormal3f(normal[i],normal[i+1],normal[i+2]);
00179     glColor3f(color[i],color[i+1],color[i+2]);
00180     glVertex3f(point[i],point[i+1],point[i+2]);
00181   }
00182 
00183   glEnd();
00184 }

void vrmlshape::writePwind (  )  const

Write the triangles winding by coloring in the vertices Red, Green and Blue.

Definition at line 186 of file vrmlshape.cpp.

References point.

00187 {
00188   uintc sz = point.size();
00189 
00190   if (sz==0)
00191     return;
00192 
00193   glBegin(GL_TRIANGLES);
00194 
00195   uint k;
00196 
00197   for (uint i=0; i<sz; i+=3 )
00198   {
00199     k = i/3;
00200     k %= 3;
00201     switch (k)
00202     {
00203       case 0: glColor3f(1.0,0.0,0.0); break;
00204       case 1: glColor3f(0.0,1.0,0.0); break;
00205       default: glColor3f(0.0,0.0,1.0); break;
00206     }
00207 
00208     glVertex3f(point[i],point[i+1],point[i+2]);
00209   }
00210 
00211   glEnd();
00212 }


Member Data Documentation

vector<float> vrmlshape::color

Each 3 floats is a color and 3 colors per triangle.

Definition at line 34 of file vrmlshape.h.

Referenced by print(), and writePNC().

The global color.

Definition at line 37 of file vrmlshape.h.

Referenced by diffuseColorWrite(), and print().

vector<float> vrmlshape::normal

Each 3 floats is a normal and 3 normals per triangle.

Definition at line 32 of file vrmlshape.h.

Referenced by vrmllines::addnormals(), print(), writePN(), and writePNC().

vector<float> vrmlshape::point

Each 3 floats is a point and 3 points per triangle.

Definition at line 30 of file vrmlshape.h.

Referenced by vrmllines::addnormals(), print(), writeP(), writePN(), writePNC(), and writePwind().


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

Generated on 27 Nov 2012 for Chelton Evans Source by  doxygen 1.6.1