00001 00002 #include <math.h> 00003 00004 #include "OSGDVRTriangle.h" 00005 00006 OSG_USING_NAMESPACE 00007 00008 DVRTriangle::DVRTriangle(void) 00009 { 00010 // at least we need the vertex position and a texture coordinate 00011 cutPoint = (GLdouble*) malloc(6 * sizeof(GLdouble)); 00012 00013 for(UInt32 i = 0; i < 3; i++) 00014 { 00015 vertices [i] = -1; 00016 neighbours[i] = -1; 00017 cutPnt [i] = 0.0f; 00018 } 00019 } 00020 00021 DVRTriangle::DVRTriangle(const DVRTriangle &tri) 00022 { 00023 cutPoint = (GLdouble*) malloc(6 * sizeof(GLdouble)); 00024 00025 for(UInt32 i = 0; i < 3; i++) 00026 { 00027 vertices [i] = tri.vertices [i]; 00028 neighbours[i] = tri.neighbours[i]; 00029 cutPnt [i] = 0.0f; 00030 } 00031 00032 normal = tri.normal; 00033 } 00034 00035 DVRTriangle::~DVRTriangle(void) 00036 { 00037 free(cutPoint); // allocation by malloc/realloc 00038 } 00039 00040 bool DVRTriangle::setNumAddPerVertexAttr(UInt32 additionalPerVertexAttributes) 00041 { 00042 cutPoint = (GLdouble*) realloc( 00043 cutPoint, 00044 (6 + additionalPerVertexAttributes) * sizeof(GLdouble)); 00045 00046 return cutPoint != NULL; 00047 } 00048 00049 void DVRTriangle::dump() const 00050 { 00051 std::cerr <<"Verts: " 00052 << vertices[0] << " " 00053 << vertices[1] << " " 00054 << vertices[2] 00055 <<" Neighbours: " 00056 << neighbours[0] << " " 00057 << neighbours[1] << " " 00058 << neighbours[2] << std::endl; 00059 } 00060
1.5.5