Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 343 vs 350 for /trunk/Source Code/AI/PathFinding/NavMeshes/Headers/NavMeshLoader.h

Diff revisions: vs.
  @@ -4,18 +4,27 @@
4 4
5 5 This file is part of DIVIDE Framework.
6 6
7 - Permission is hereby granted, free of charge, to any person obtaining a copy of this software
8 - and associated documentation files (the "Software"), to deal in the Software without restriction,
9 - including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 - and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
7 + Permission is hereby granted, free of charge, to any person obtaining a copy
8 + of this software
9 + and associated documentation files (the "Software"), to deal in the Software
10 + without restriction,
11 + including without limitation the rights to use, copy, modify, merge, publish,
12 + distribute, sublicense,
13 + and/or sell copies of the Software, and to permit persons to whom the
14 + Software is furnished to do so,
11 15 subject to the following conditions:
12 16
13 - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 + The above copyright notice and this permission notice shall be included in
18 + all copies or substantial portions of the Software.
14 19
15 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 + IMPLIED,
22 + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 + PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 + DAMAGES OR OTHER LIABILITY,
26 + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 + IN CONNECTION WITH THE SOFTWARE
19 28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 29
21 30 */
  @@ -36,7 +45,8 @@
36 45 // misrepresented as being the original software.
37 46 // 3. This notice may not be removed or altered from any source distribution.
38 47 //
39 - // Changes, Additions and Refactoring : Copyright (c) 2010-2011 Lethal Concept, LLC
48 + // Changes, Additions and Refactoring : Copyright (c) 2010-2011 Lethal Concept,
49 + // LLC
40 50 // Changes, Additions and Refactoring Author: Simon Wittenberg (MD)
41 51 // The above license is fully inherited.
42 52
  @@ -48,118 +58,105 @@
48 58 #include "Graphs/Headers/SceneNode.h"
49 59
50 60 namespace Divide {
51 - namespace AI {
52 - namespace Navigation {
61 + namespace AI {
62 + namespace Navigation {
53 63
54 - // This struct contains the vertices and triangles in recast coords
55 - class NavModelData {
56 - public:
57 - NavModelData() : _vertices(0),
58 - _vertexCount(0),
59 - _vertexCapacity(0),
60 - _normals(0),
61 - _triangleCount(0),
62 - _triangleCapacity(0),
63 - _triangles(0),
64 - _valid(false)
65 - {
64 + // This struct contains the vertices and triangles in recast coords
65 + class NavModelData {
66 + public:
67 + NavModelData()
68 + : _vertices(0),
69 + _vertexCount(0),
70 + _vertexCapacity(0),
71 + _normals(0),
72 + _triangleCount(0),
73 + _triangleCapacity(0),
74 + _triangles(0),
75 + _valid(false) {}
76 +
77 + void clear(bool del = true) {
78 + _valid = false;
79 +
80 + _vertexCount = _triangleCount = 0;
81 + _vertexCapacity = _vertexCount = 0;
82 + _triangleCapacity = _triangleCount = 0;
83 +
84 + if (del) {
85 + MemoryManager::DELETE_ARRAY(_vertices);
86 + } else {
87 + _vertices = 0;
66 88 }
67 -
68 - void clear(bool del = true) {
69 - _valid = false;
70 -
71 - _vertexCount = _triangleCount = 0;
72 - _vertexCapacity = _vertexCount = 0;
73 - _triangleCapacity = _triangleCount = 0;
74 -
75 - if (del) {
76 - MemoryManager::DELETE_ARRAY( _vertices );
77 - } else {
78 - _vertices = 0;
79 - }
80 - if (del) {
81 - MemoryManager::DELETE_ARRAY( _triangles );
82 - } else {
83 - _triangles = 0;
84 - }
85 - if (del) {
86 - MemoryManager::DELETE_ARRAY( _normals );
87 - } else {
88 - _normals = 0;
89 - }
90 - _triangleAreaType.clear();
91 - _navMeshName = "";
89 + if (del) {
90 + MemoryManager::DELETE_ARRAY(_triangles);
91 + } else {
92 + _triangles = 0;
92 93 }
93 -
94 - inline bool isValid() const {return _valid;}
95 - inline void isValid(bool state) {_valid = state;}
96 -
97 - inline void setName(const stringImpl& name) {_navMeshName = name;}
98 - inline const stringImpl& getName() const {return _navMeshName;}
99 -
100 - inline const F32* getVerts() const { return _vertices; }
101 - inline const F32* getNormals() const { return _normals; }
102 - inline const I32* getTris() const { return _triangles; }
103 - inline U32 getVertCount() const { return _vertexCount; }
104 - inline U32 getTriCount() const { return _triangleCount; }
105 -
106 - inline vectorImpl<SamplePolyAreas >& getAreaTypes() {return _triangleAreaType;}
107 -
108 - F32* _vertices;
109 - F32* _normals;
110 - I32* _triangles;
111 - U32 _vertexCapacity;
112 - U32 _vertexCount;
113 - U32 _triangleCount;
114 - U32 _triangleCapacity;
115 -
116 - private:
117 - bool _valid;
118 - stringImpl _navMeshName;
119 - vectorImpl<SamplePolyAreas > _triangleAreaType;
120 - };
121 -
122 - namespace NavigationMeshLoader {
123 - enum MeshDetailLevel {
124 - DETAIL_ABSOLUTE = 0,
125 - DETAIL_BOUNDINGBOX = 1
126 - };
127 -
128 - ///Load the input geometry from file (Wavefront OBJ format) and save it in 'outData'
129 - bool loadMeshFile(NavModelData& outData,
130 - const char* fileName);
131 - ///Save the navigation input geometry in Wavefront OBJ format
132 - bool saveMeshFile(const NavModelData& inData,
133 - const char* filename);
134 - ///Merge the data from two navigation geometry sources
135 - NavModelData mergeModels(NavModelData& a,
136 - NavModelData& b,
137 - bool delOriginals = false);
138 - ///Parsing method that calls itself recursively untill all geometry has been parsed
139 - bool parse(const BoundingBox& box,
140 - NavModelData& outData,
141 - SceneGraphNode* sgn);
142 -
143 - void addVertex(NavModelData* modelData,
144 - const vec3<F32>& vertex);
145 -
146 - void addTriangle(NavModelData* modelData,
147 - const vec3<U32>& triangleIndices,
148 - U32 triangleIndexOffset = 0,
149 - const SamplePolyAreas& areaType = SAMPLE_POLYAREA_GROUND);
150 -
151 - char* parseRow(char* buf,
152 - char* bufEnd,
153 - char* row,
154 - I32 len);
155 -
156 - I32 parseFace(char* row,
157 - I32* data,
158 - I32 n,
159 - I32 vcnt);
160 - };
161 - }; //namespace Navigation
162 - }; //namespace AI
163 - }; //namespace Divide
94 + if (del) {
95 + MemoryManager::DELETE_ARRAY(_normals);
96 + } else {
97 + _normals = 0;
98 + }
99 + _triangleAreaType.clear();
100 + _navMeshName = "";
101 + }
102 +
103 + inline bool isValid() const { return _valid; }
104 + inline void isValid(bool state) { _valid = state; }
105 +
106 + inline void setName(const stringImpl& name) { _navMeshName = name; }
107 + inline const stringImpl& getName() const { return _navMeshName; }
108 +
109 + inline const F32* getVerts() const { return _vertices; }
110 + inline const F32* getNormals() const { return _normals; }
111 + inline const I32* getTris() const { return _triangles; }
112 + inline U32 getVertCount() const { return _vertexCount; }
113 + inline U32 getTriCount() const { return _triangleCount; }
114 +
115 + inline vectorImpl<SamplePolyAreas>& getAreaTypes() {
116 + return _triangleAreaType;
117 + }
118 +
119 + F32* _vertices;
120 + F32* _normals;
121 + I32* _triangles;
122 + U32 _vertexCapacity;
123 + U32 _vertexCount;
124 + U32 _triangleCount;
125 + U32 _triangleCapacity;
126 +
127 + private:
128 + bool _valid;
129 + stringImpl _navMeshName;
130 + vectorImpl<SamplePolyAreas> _triangleAreaType;
131 + };
132 +
133 + namespace NavigationMeshLoader {
134 + enum MeshDetailLevel { DETAIL_ABSOLUTE = 0, DETAIL_BOUNDINGBOX = 1 };
135 +
136 + /// Load the input geometry from file (Wavefront OBJ format) and save it in
137 + /// 'outData'
138 + bool loadMeshFile(NavModelData& outData, const char* fileName);
139 + /// Save the navigation input geometry in Wavefront OBJ format
140 + bool saveMeshFile(const NavModelData& inData, const char* filename);
141 + /// Merge the data from two navigation geometry sources
142 + NavModelData mergeModels(NavModelData& a, NavModelData& b,
143 + bool delOriginals = false);
144 + /// Parsing method that calls itself recursively untill all geometry has been
145 + /// parsed
146 + bool parse(const BoundingBox& box, NavModelData& outData, SceneGraphNode* sgn);
147 +
148 + void addVertex(NavModelData* modelData, const vec3<F32>& vertex);
149 +
150 + void addTriangle(NavModelData* modelData, const vec3<U32>& triangleIndices,
151 + U32 triangleIndexOffset = 0,
152 + const SamplePolyAreas& areaType = SAMPLE_POLYAREA_GROUND);
153 +
154 + char* parseRow(char* buf, char* bufEnd, char* row, I32 len);
155 +
156 + I32 parseFace(char* row, I32* data, I32 n, I32 vcnt);
157 + };
158 + }; // namespace Navigation
159 + }; // namespace AI
160 + }; // namespace Divide
164 161
165 162 #endif