00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef __VR3OBJ_H__
00022 #define __VR3OBJ_H__
00023
00024 #include <VR3Mesh.h>
00025
00026 #include <set>
00027
00029
00077 class VR3Obj {
00078 #if (defined(_WIN32) || defined(_WIN64)) && !defined(VR3CONF_NOPHYSICS)
00079
00080 friend class VR3PhysicsSimulator;
00081 #endif
00082
00084 GLfloat m_lod_activations[VR3OBJ_NUM_LODS];
00086 GLint m_lod_count;
00087
00089 std::set<VR3Obj*> m_children;
00091 VR3Obj* m_parent;
00092
00094 GLfloat m_pos[3];
00096 GLfloat m_scale[3];
00098 GLfloat m_rotation_matrix[16];
00100 GLfloat m_pivot[3];
00101
00103 VR3Mesh* m_meshes[VR3OBJ_NUM_LODS];
00104
00106 bool m_ishidden;
00107
00109
00110
00112
00119 void TotModelMatrix(GLfloat* modelmat) const;
00120
00122
00124
00125
00127
00131 void Init();
00132
00134
00136
00137
00139
00157 void Draw(const GLfloat* modelmat, int flags);
00158
00160
00162 VR3Obj(const VR3Obj&);
00164 VR3Obj& operator = (const VR3Obj&);
00165
00166 public:
00167
00168
00169
00171
00172
00174
00177 VR3Obj();
00178
00180
00193 VR3Obj( const char* mesh_file,
00194 GLfloat x=0.0f, GLfloat y=0.0f, GLfloat z=0.0f,
00195 const char* mesh_name = 0, int objID = -1);
00196
00198
00201 VR3Obj(VR3Mesh* mesh);
00202
00204 ~VR3Obj();
00205
00207
00208
00209
00211
00212
00214
00224 int AddChild(VR3Obj* c, GLfloat x, GLfloat y, GLfloat z);
00225
00227
00234 int AddChild(VR3Obj* c);
00235
00237
00244 int RemoveChild(VR3Obj* c);
00245
00247
00248
00249
00251
00252
00254
00264 void SetPivotPoint(GLfloat x, GLfloat y, GLfloat z);
00265
00267
00270 void SetPivotPoint(const GLfloat* vec);
00271
00273
00280 void GetPivotPoint(GLfloat* vec);
00281
00283
00288 void GetPosition(GLfloat* p);
00289
00291
00297 void SetPosition(GLfloat x, GLfloat y, GLfloat z);
00298
00300
00303 void SetPosition(const GLfloat* point);
00304
00306
00311 void GetScale(GLfloat* s);
00312
00314
00320 void SetScale(GLfloat scx, GLfloat scy, GLfloat scz);
00321
00323
00326 void SetScale(const GLfloat* s);
00327
00329
00335 void GetRotationMatrix(GLfloat* m);
00336
00338
00344 void SetRotationMatrix(const GLfloat* m);
00345
00347
00358 VR3Mesh* GetMesh(int lod = 0);
00359
00361
00366 void Hide() { m_ishidden = true; }
00367
00369
00372 void UnHide() { m_ishidden = false; }
00373
00375
00386 void LinkToMesh(VR3Mesh* m, GLfloat dist=0.0f);
00387
00389
00401 bool PointInBBox(GLfloat x, GLfloat y, GLfloat z);
00402
00404
00408 bool PointInBBox(const GLfloat* p)
00409 { return PointInBBox(p[0], p[1], p[2]); }
00410
00412
00426 void LocalToWorld(const GLfloat* inpoint, GLfloat* outpoint);
00427
00429
00435 bool IsRoot()
00436 { return (m_parent == 0); }
00437
00439
00444 VR3Obj* GetParent()
00445 { return m_parent; }
00446
00448
00449
00450
00452
00453
00455
00464 void SetRotation(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00465
00467
00471 void SetRotation(GLfloat angle, GLfloat* axis)
00472 { SetRotation(angle, axis[0], axis[1], axis[2]); }
00473
00475
00485 void RotateLocal(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00486
00488
00492 void RotateLocal(GLfloat angle, GLfloat* axis)
00493 { RotateLocal(angle,axis[0],axis[1],axis[2]); }
00494
00496
00507 void RotateGlobal(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00508
00510
00514 void RotateGlobal(GLfloat angle, const GLfloat* axis)
00515 { RotateGlobal(angle,axis[0],axis[1],axis[2]); }
00516
00518
00523 void TranslateLocal(GLfloat x, GLfloat y, GLfloat z);
00524
00526
00529 void TranslateLocal(const GLfloat* vec)
00530 { TranslateLocal(vec[0],vec[1],vec[2]); }
00531
00533
00539 void TranslateGlobal(GLfloat x, GLfloat y, GLfloat z);
00540
00542
00545 void TranslateGlobal(const GLfloat* vec)
00546 { TranslateGlobal(vec[0],vec[1],vec[2]); }
00547
00549
00556 void Normalize(GLfloat size);
00557
00559
00560
00561
00563
00564
00566
00571 void Draw(int flags = 0);
00572
00574
00575 };
00576
00577 #endif