00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __X3DNURBSSURFACEGEOMETRYNODE_H__
00030 #define __X3DNURBSSURFACEGEOMETRYNODE_H__
00031
00032 #include "X3DParametricGeometryNode.h"
00033 #include "DependentNodeFields.h"
00034 #include "X3DCoordinateNode.h"
00035 #include "X3DTextureCoordinateNode.h"
00036 #include "NurbsTextureCoordinate.h"
00037 #include "CoordBoundField.h"
00038 #include "SFInt32.h"
00039 #include "MFDouble.h"
00040 #include "TextureCoordinateGenerator.h"
00041
00042 namespace H3D {
00043
00122 class H3DAPI_API X3DNurbsSurfaceGeometryNode :
00123 public X3DParametricGeometryNode {
00124 public:
00125
00128 typedef DependentSFNode< X3DCoordinateNode,
00129 FieldRef< X3DGeometricPropertyNode,
00130 Field,
00131 &X3DCoordinateNode::propertyChanged > >
00132 SFCoordinateNode;
00133
00138 typedef DependentSFNode<
00139 X3DGeometricPropertyNode,
00140 FieldRef< X3DGeometricPropertyNode,
00141 Field,
00142 &X3DGeometricPropertyNode::propertyChanged > >
00143 TexCoordOrNurbsTexDependent;
00144
00146 typedef CoordBoundField SFBound;
00147
00150 class H3DAPI_API TexCoordOrNurbsTex: public TexCoordOrNurbsTexDependent {
00151 public:
00152
00157 ~TexCoordOrNurbsTex() {
00158 value = NULL;
00159 }
00160
00161 virtual void onAdd( Node *n ) {
00162 SFNode::onAdd( n );
00163 X3DTextureCoordinateNode *tex_coord_node =
00164 dynamic_cast< X3DTextureCoordinateNode * >( n );
00165
00166 NurbsTextureCoordinate *nurbs_tex_coord =
00167 dynamic_cast< NurbsTextureCoordinate * >( n );
00168
00169 if( !tex_coord_node && !nurbs_tex_coord ) {
00170 stringstream s;
00171 s << "Expecting X3DTextureCoordinateNode or NurbsTextureCoordinate";
00172 throw InvalidNodeType( n->getTypeName(),
00173 s.str(),
00174 H3D_FULL_LOCATION );
00175 }
00176 }
00177 };
00178 friend class TexCoordOrNurbsTex;
00179
00181 ~X3DNurbsSurfaceGeometryNode() {
00182 if( nurbs_object ) gluDeleteNurbsRenderer( nurbs_object );
00183 }
00184
00186 X3DNurbsSurfaceGeometryNode( Inst< SFNode > _metadata = 0,
00187 Inst< SFBound > _bound = 0,
00188 Inst< DisplayList > _displayList = 0,
00189 Inst< MFBool > _isTouched = 0,
00190 Inst< MFVec3f > _force = 0,
00191 Inst< MFVec3f > _contactPoint = 0,
00192 Inst< MFVec3f > _contactNormal = 0,
00193 Inst< SFCoordinateNode > _controlPoint = 0,
00194 Inst< TexCoordOrNurbsTex > _texCoord = 0,
00195 Inst< SFInt32 > _uTessellation = 0,
00196 Inst< SFInt32 > _vTessellation = 0,
00197 Inst< MFDouble > _weight = 0,
00198 Inst< SFBool > _solid = 0,
00199 Inst< SFBool > _uClosed = 0,
00200 Inst< SFBool > _vClosed = 0,
00201 Inst< SFInt32 > _uDimension = 0,
00202 Inst< SFInt32 > _vDimension = 0,
00203 Inst< MFDouble > _uKnot = 0,
00204 Inst< MFDouble > _vKnot = 0,
00205 Inst< SFInt32 > _uOrder = 0,
00206 Inst< SFInt32 > _vOrder = 0 );
00207
00209 virtual void render();
00210
00213 virtual void renderBetweenBeginEnd(
00214 GLUnurbsObj *nurbs_object,
00215 X3DTextureCoordinateNode *tex_coord_node,
00216 TextureCoordinateGenerator *tex_coord_gen,
00217 NurbsTextureCoordinate *nurbs_tex_coord,
00218 GLfloat *texKnotU,
00219 GLfloat *texKnotV,
00220 GLfloat *texCoordinates,
00221 GLfloat *u_knots,
00222 GLfloat *v_knots,
00223 H3DInt32 &sizeOfVertex,
00224 GLfloat *withWeights,
00225 H3DInt32 &uSizeToUse,
00226 H3DInt32 &vSizeToUse,
00227 H3DInt32 &map2Vertex3Or4 ) {};
00228
00239 auto_ptr< SFCoordinateNode > controlPoint;
00240
00251 auto_ptr< TexCoordOrNurbsTex > texCoord;
00252
00260 auto_ptr< SFInt32 > uTessellation;
00261
00269 auto_ptr< SFInt32 > vTessellation;
00270
00283 auto_ptr< MFDouble > weight;
00284
00292 auto_ptr< SFBool > solid;
00293
00301 auto_ptr< SFBool > uClosed;
00302
00310 auto_ptr< SFBool > vClosed;
00311
00318 auto_ptr< SFInt32 > uDimension;
00319
00326 auto_ptr< SFInt32 > vDimension;
00327
00333 auto_ptr< MFDouble > uKnot;
00334
00340 auto_ptr< MFDouble > vKnot;
00341
00348 auto_ptr< SFInt32 > uOrder;
00349
00356 auto_ptr< SFInt32 > vOrder;
00357
00359 static H3DNodeDatabase database;
00360
00361 protected:
00362 GLUnurbsObj *nurbs_object;
00363
00364 };
00365 }
00366
00367 #endif