summaryrefslogtreecommitdiffstats
path: root/matchblox/C_3DObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/C_3DObject.h')
-rw-r--r--matchblox/C_3DObject.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/matchblox/C_3DObject.h b/matchblox/C_3DObject.h
new file mode 100644
index 0000000..4027596
--- /dev/null
+++ b/matchblox/C_3DObject.h
@@ -0,0 +1,66 @@
+#ifndef C_3DOBJECT_HEADER_FILE
+
+#define C_3DOBJECT_HEADER_FILE
+
+#include <fstream>
+#include <vector>
+
+#include "typedefs.h"
+
+class C_3DObject
+{
+public:
+ C_3DObject();
+ C_3DObject(const char* f_strFileName,
+ char* f_strColorTexName,
+ MatProps_t f_Material);
+ C_3DObject(const char* f_strFileName,
+ GLuint f_uiTexturei,
+ MatProps_t f_Material);
+
+ ~C_3DObject();
+
+ inline void SetPos(double f_dX, double f_dY, double f_dZ)
+ { m_Pos.x = f_dX; m_Pos.y = f_dY; m_Pos.z = f_dZ; }
+ inline void SetRot(double f_dX, double f_dY, double f_dZ)
+ { m_Rot.x = f_dX; m_Rot.y = f_dY; m_Rot.z = f_dZ; }
+ inline void SetScale(double f_dX, double f_dY, double f_dZ)
+ { m_Scale.x = f_dX; m_Scale.y = f_dY; m_Scale.z = f_dZ; }
+ inline void SetPos(const Vect3D_t &pos)
+ { m_Pos = pos; }
+ inline void SetRot(const Vect3D_t &rot)
+ { m_Rot = rot; }
+ inline void SetScale(const Vect3D_t &scale)
+ { m_Scale = scale; }
+
+ inline const Vect3D_t& GetPos() { return m_Pos; }
+ inline const Vect3D_t& GetRot() { return m_Rot; }
+ inline const Vect3D_t& GetScale() { return m_Scale; }
+ inline const BoundingBox_t& GetBoundingBox() { return m_BBox; }
+ inline bool Initialized() { return m_bDispListValid; }
+
+ void TransRotateScale(); //applies the scaling, translation and rotation
+ //for this object
+ virtual void Render(); //renders the object using the current projection
+ //and modelview matrices
+
+protected:
+ Vect3D_t m_Pos,
+ m_Rot,
+ m_Scale;
+
+ BoundingBox_t m_BBox; //bounding box of the object
+ GLuint m_uiListIndex; //display list index
+ bool m_bDispListValid;
+ GLuint m_uiColorTex;
+ bool m_bOwnTexture;
+ MatProps_t m_Mat;
+
+ bool CreateObject(const char *f_pFilePath);
+ bool LoadGeometryData(const char *f_pFilePath, Geometry_t &f_Geom);
+ bool ParseVect3D(const char *f_pInbuffer, Vect3D_t &f_V3);
+ bool ParseTriangle(const char *f_pInbuffer, Triangle_t &f_triangle);
+};
+
+#endif //C_3DOBJECT_HEADER_FILE
+