00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef DEFORMABLE_OCTREE_NODE_H
00020 #define DEFORMABLE_OCTREE_NODE_H
00021 
00022 
00023 #include <X3DTK/private/X3D_X3DBoundedObject.h>
00024 #include <animal/engine/EngineNode.h>
00025 #include <string>
00026 using std::string;
00027 
00028 #include <X3DTK/private/X3D_X3DChildNode.h>
00029 
00030 #include "Octree.h"
00031 #include "SFVec3fCellConstrained.h"
00032 #include "Frame.h"
00033 #include "DeformableOctreeShapeNode.h"
00034 
00035 
00036 namespace X3DTK
00037 {
00038 
00039 namespace X3D
00040 {
00041 
00042 using namespace animal;
00043 using namespace animal::octree;
00044 
00046 class DeformableOctreeNode :  
00047             
00048             public EngineNode
00049 {
00050 
00051 public:
00053     DeformableOctreeNode();
00054 
00056     ~DeformableOctreeNode();
00057 
00058     
00059     virtual animal::ConstrainedItem* pickPoint( float* , float* , float );
00060 
00061     virtual void declareOutputs( X3D_X3DNodeList& );
00062 
00064     void setDeformableOctreeShapeNode( DeformableOctreeShapeNode *dosn );
00065 
00066 
00068     
00071 
00074 
00076 
00077 
00078 
00079     virtual void postInit();
00080     virtual void draw();
00081 
00082     
00083     void updateGL();
00084 
00085 
00086 
00087     void getBoundingBox( float & minX, float & minY, float & minZ, float & maxX, float & maxY, float & maxZ);
00088     void updateBoundingBox();
00089     
00090     void animate( float dt );
00091     void postAnimate( float dt );
00092 
00093 
00094 
00095     Octree * getOctree() const { return _octree; };
00096     
00097 public:
00098     void slotSubdivide();
00099     void slotSimplify();
00100 
00101     void slotMoveXPlus();
00102     void slotMoveXMinus();
00103     void slotMoveYPlus();
00104     void slotMoveYMinus();
00105     void slotMoveZPlus();
00106     void slotMoveZMinus();
00107 
00108     
00109     void slotCycleCell();
00110     void slotCyclePoint();
00111     void slotGoFather();
00112     void slotGoChild();
00113 
00114     
00115     void slotSetDrawEmptyCells(bool);
00116     bool getOptionDrawEmptyCells();
00117 
00118     void slotSetDrawOctree(bool);
00119     bool getOptionDrawOctree();
00120 
00121     void slotSetDrawSelection(bool);
00122     bool getOptionDrawSelection();
00123 
00124     void slotSetNMaxPointsPerCell( unsigned int n );
00125     unsigned int getOptionNMaxPointsPerCell( );
00126 
00127     void slotSetDrawSelectedCellsPoints(bool b);
00128     bool getOptionDrawSelectedCellsPoints();
00129 
00130     void slotSetDrawNeighbours( bool b );
00131     bool getOptionDrawNeighbours() const;
00132 
00133     void slotSetDrawFrames(bool b)
00134     {
00135         _drawFrames = b;
00136     };
00137     bool getOptionDrawFrames()
00138     {
00139         return _drawFrames;
00140     };
00141 
00142     void slotSetInterpolationMethod( int index );
00143 
00144     void slotChangeToolsSize( int size );
00145     FloatingPointType getToolsSize();
00146 
00147     void slotButtonTest();
00148 
00149 
00150     void slotButtonDirectManipulation( );
00151 
00152 
00153 
00154 
00155 protected:
00156     DeformableOctreeShapeNode *_dosn;
00157 
00158 
00159 
00160     Octree *_octree;
00161 
00162     Cell *_selectedCell;
00163     int _selectedVertexId;
00164 
00165     
00166 
00167 
00168     void createOctree();
00169 
00170 
00171     OctreeVertex* getSelectedVertex();
00172     Cell* getSelectedCell();
00173 
00174 
00175 
00176 
00177     void drawCells( Cell *cell );
00178 
00179     void drawVertex( OctreeVertex *vertex, float size = 1.0, unsigned int details = 10 );
00180 
00181     
00182     void drawSelection();
00183     void drawCellsPoints( Cell *cell );
00184 
00185     void drawFrames( Cell *cell );
00186 
00187     void drawFrame( Frame f );
00188 
00189     void drawVector( Vec3d p1, Vec3d p2 );
00190     
00191     void drawOctreeVertices( );
00192 
00193     void drawNeighbours( Cell *cell );
00194 
00195     
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206     void initOptions();
00207 
00208     bool _drawEmptyCells;
00209     bool _drawOctree;
00210     bool _drawSelection;
00211     bool _drawSelectedCellsPoints;
00212     bool _drawFrames;
00213     bool _drawNeighbours;
00214 
00215 
00216     FloatingPointType _toolsSize;
00217     unsigned int _selectionId;
00218     
00219     SFString _engineType;
00220 
00221 
00222 };
00223 
00224 } 
00225 }   
00226 
00227 
00228 
00229 #endif
00230 
00231 
00232 
00233 
00234 
00235