Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OPC_BaseModel.h
Go to the documentation of this file.
1 /*
3  * OPCODE - Optimized Collision Detection
4  * Copyright (C) 2001 Pierre Terdiman
5  * Homepage: http://www.codercorner.com/Opcode.htm
6  */
8 
10 
16 
19 // Include Guard
20 #ifndef __OPC_BASEMODEL_H__
21 #define __OPC_BASEMODEL_H__
22 
25  {
27  OPCODECREATE();
28 
31  bool mNoLeaf;
32  bool mQuantized;
33 #ifdef __MESHMERIZER_H__
34  bool mCollisionHull;
35 #endif // __MESHMERIZER_H__
37  bool mCanRemap;
38 
39  // (*) This pointer is saved internally and used by OPCODE until collision structures are released,
40  // so beware of the object's lifetime.
41  };
42 
43  enum ModelFlag
44  {
45  OPC_QUANTIZED = (1<<0),
46  OPC_NO_LEAF = (1<<1),
47  OPC_SINGLE_NODE = (1<<2)
48  };
49 
51  {
52  public:
53  // Constructor/Destructor
54  BaseModel();
55  virtual ~BaseModel();
56 
58 
63  virtual bool Build(const OPCODECREATE& create) = 0;
65 
67 
71  virtual udword GetUsedBytes() const = 0;
73 
75 
81  virtual bool Refit();
83 
85 
89  inline_ const AABBTree* GetSourceTree() const { return mSource; }
91 
93 
97  inline_ const AABBOptimizedTree* GetTree() const { return mTree; }
99 
101 
105  inline_ AABBOptimizedTree* GetTree() { return mTree; }
107 
109 
114  inline_ udword GetNbNodes() const { return mTree->GetNbNodes(); }
116 
118 
122  inline_ BOOL HasLeafNodes() const { return !(mModelCode & OPC_NO_LEAF); }
124 
126 
130  inline_ BOOL IsQuantized() const { return mModelCode & OPC_QUANTIZED; }
132 
134 
138  inline_ BOOL HasSingleNode() const { return mModelCode & OPC_SINGLE_NODE; }
140 
142 
146  inline_ udword GetModelCode() const { return mModelCode; }
148 
150 
154  inline_ const MeshInterface* GetMeshInterface() const { return mIMesh; }
156 
158 
162  inline_ void SetMeshInterface(const MeshInterface* imesh) { mIMesh = imesh; }
164 
165  protected:
170  // Internal methods
171  void ReleaseBase();
172  bool CreateTree(bool no_leaf, bool quantized);
173  };
174 
175 #endif //__OPC_BASEMODEL_H__