diff options
author | maximius <none@none> | 2009-10-17 15:51:44 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:51:44 -0700 |
commit | e585187b248f48b3c6e9247b49fa07c6565d65e5 (patch) | |
tree | 637c5b7ddacf41040bef4ea4f75a97da64c6a9bc /src/shared/vmap/BaseModel.h | |
parent | 26b5e033ffde3d161382fc9addbfa99738379641 (diff) |
*Backed out changeset 3be01fb200a5
--HG--
branch : trunk
Diffstat (limited to 'src/shared/vmap/BaseModel.h')
-rw-r--r-- | src/shared/vmap/BaseModel.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/shared/vmap/BaseModel.h b/src/shared/vmap/BaseModel.h index 1e896bb62ec..098e1d9381b 100644 --- a/src/shared/vmap/BaseModel.h +++ b/src/shared/vmap/BaseModel.h @@ -17,22 +17,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef _BASEMODEL_H_ #define _BASEMODEL_H_ + #include <G3D/AABox.h> #include <G3D/Vector3.h> + #include "ShortVector.h" #include "ShortBox.h" #include "TreeNode.h" + /** A model is based on triangles. To be able to check intersection we need a BSP-Tree. This Class holds the array of triangles as well as the management information for the BSP-Tree. Both are stored in static array and index information is used instead of pointers. Therefore we can load the whole object as a binary block. + The vectors are relative to a base position. */ + namespace VMAP { + class BaseModel { protected: @@ -48,31 +55,48 @@ namespace VMAP iNNodes = pNNodes; iNTriangles = pNTriangles; iTriangles = pTriangleBox; iTreeNodes = pTreeNode; }; BaseModel(unsigned int pNNodes, unsigned int pNTriangles); + // destructor does nothing ! The subclass controles the array memory and knows when to free it ~BaseModel() {} + void free(); void init(unsigned int pNNodes, unsigned int pNTriangles); + void getMember(G3D::Array<TriangleBox>& pMembers); + inline const TriangleBox& getTriangle(int pPos) const { return(iTriangles[pPos]); } inline TriangleBox& getTriangle(int pPos) { return(iTriangles[pPos]); } + inline void setTriangle(const TriangleBox& pTriangleBox, int pPos) { iTriangles[pPos] = pTriangleBox; } + inline const TreeNode& getTreeNode(int pPos) const { return(getTreeNodes()[pPos]); } inline TreeNode& getTreeNode(int pPos) { return(getTreeNodes()[pPos]); } + inline void setTreeNode(const TreeNode& pTreeNode, int pPos) { getTreeNodes()[pPos] = pTreeNode; } + inline void setBasePosition(const G3D::Vector3& pBasePosition) { iBasePosition = pBasePosition; } + inline const G3D::Vector3& getBasePosition() const { return(iBasePosition); } + inline unsigned int getNNodes() const { return(iNNodes); } inline unsigned int getNTriangles() const { return(iNTriangles); } + inline void setNNodes(unsigned int pNNodes) { iNNodes = pNNodes; } inline void setNTriangles(unsigned int pNTriangles) { iNTriangles = pNTriangles; } + inline void setTriangleArray(TriangleBox *pGlobalTriangleArray ) { iTriangles = pGlobalTriangleArray ; } inline void setTreeNodeArray(TreeNode *pGlobalTreeNodeArray ) { iTreeNodes = pGlobalTreeNodeArray ; } + inline TriangleBox* getTriangles() const { return(iTriangles); } + inline TreeNode* getTreeNodes() const{ return(iTreeNodes); } + inline size_t getMemUsage() { return(iNTriangles * sizeof(TriangleBox) + iNNodes * sizeof(TreeNode) + sizeof(BaseModel)); } + void intersect(const G3D::AABox& pBox, const G3D::Ray& pRay, float& pMaxDist, G3D::Vector3& pOutLocation, G3D::Vector3& pOutNormal) const; bool intersect(const G3D::AABox& pBox, const G3D::Ray& pRay, float& pMaxDist) const; }; + } #endif /*BASEMODEL_H_*/ |