OgreEdgeListBuilder.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __EdgeListBuilder_H__
29 #define __EdgeListBuilder_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreVector4.h"
34 #include "OgreRenderOperation.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre {
53  {
54  public:
55 
56  EdgeData();
57 
59  struct Triangle {
62  size_t indexSet;
64  size_t vertexSet;
66  size_t vertIndex[3];
69  size_t sharedVertIndex[3];
70 
71  Triangle() :indexSet(0), vertexSet(0) {}
72  };
74  struct Edge {
78  size_t triIndex[2];
81  size_t vertIndex[2];
83  size_t sharedVertIndex[2];
85  bool degenerate;
86  };
87 
91  typedef std::vector<Vector4, STLAllocator<Vector4, CategorisedAlignAllocPolicy<MEMCATEGORY_GEOMETRY> > > TriangleFaceNormalList;
92 
97 
100 
102  struct EdgeGroup
103  {
105  size_t vertexSet;
112  size_t triStart;
114  size_t triCount;
117 
118  };
119 
121 
133  bool isClosed;
134 
135 
145  void updateTriangleLightFacing(const Vector4& lightPos);
151  void updateFaceNormals(size_t vertexSet, const HardwareVertexBufferSharedPtr& positionBuffer);
152 
153 
154 
156  void log(Log* log);
157 
158  };
159 
170  {
171  public:
172 
173  EdgeListBuilder();
174  virtual ~EdgeListBuilder();
180  void addVertexData(const VertexData* vertexData);
191  void addIndexData(const IndexData* indexData, size_t vertexSet = 0,
193 
198  EdgeData* build(void);
199 
201  void log(Log* l);
202  protected:
203 
209  struct CommonVertex {
211  size_t index;
212  size_t vertexSet;
213  size_t indexSet;
214  size_t originalIndex;
215  };
217  struct Geometry {
218  size_t vertexSet;
219  size_t indexSet;
222  };
224  struct geometryLess {
225  bool operator()(const Geometry& a, const Geometry& b) const
226  {
227  if (a.vertexSet < b.vertexSet) return true;
228  if (a.vertexSet > b.vertexSet) return false;
229  return a.indexSet < b.indexSet;
230  }
231  };
233  struct vectorLess {
234  bool operator()(const Vector3& a, const Vector3& b) const
235  {
236  if (a.x < b.x) return true;
237  if (a.x > b.x) return false;
238  if (a.y < b.y) return true;
239  if (a.y > b.y) return false;
240  return a.z < b.z;
241  }
242  };
243 
247 
258  typedef multimap< std::pair<size_t, size_t>, std::pair<size_t, size_t> >::type EdgeMap;
260 
261  void buildTrianglesEdges(const Geometry &geometry);
262 
264  size_t findOrCreateCommonVertex(const Vector3& vec, size_t vertexSet,
265  size_t indexSet, size_t originalIndex);
267  void connectOrCreateEdge(size_t vertexSet, size_t triangleIndex, size_t vertIndex0, size_t vertIndex1,
268  size_t sharedVertIndex0, size_t sharedVertIndex1);
269  };
273 }
274 
275 #include "OgreHeaderSuffix.h"
276 
277 #endif
278 
CommonVertexList mVertices
Comparator for sorting geometries by vertex set.
size_t indexSet
The vertex set this came from.
#define _OgreExport
Definition: OgrePlatform.h:257
Comparator for unique vertex list.
Summary class collecting together vertex source information.
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
size_t indexSet
The set of indexes this triangle came from (NB it is possible that the triangles on one side of an ed...
Summary class collecting together index data source information.
VertexDataList mVertexDataList
EdgeList edges
The edges themselves.
vector< Edge >::type EdgeList
TriangleFaceNormalList triangleFaceNormals
All triangle face normals.
size_t index
Location of point in euclidean space.
vector< Geometry >::type GeometryList
This class contains the information required to describe the edge connectivity of a given set of vert...
CommonVertexMap mCommonVertexMap
A vertex can actually represent several vertices in the final model, because vertices along texture ...
EdgeGroupList edgeGroups
All edge groups of this edge list.
vector< char >::type TriangleLightFacingList
Working vector used when calculating the silhouette.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
size_t vertexSet
The vertex set index that contains the vertices for this edge group.
Shared pointer implementation used to share vertex buffers.
A group of edges sharing the same vertex data.
std::vector< Vector4, STLAllocator< Vector4, CategorisedAlignAllocPolicy< MEMCATEGORY_GEOMETRY > > > TriangleFaceNormalList
Array of 4D vector of triangle face normal, which is unit vector orthogonal to the triangles...
TriangleLightFacingList triangleLightFacings
Triangle light facing states.
A set of indexed geometry data.
size_t indexSet
The vertex data set this geometry data refers to.
OperationType
The rendering operation type to perform.
RenderOperation::OperationType opType
The index information which describes the triangles.
vector< Triangle >::type TriangleList
size_t triStart
Index to main triangles array, indicate the first triangle of this edge group, and all triangles of t...
size_t vertexSet
The vertex set these vertices came from.
bool operator()(const Vector3 &a, const Vector3 &b) const
multimap< std::pair< size_t, size_t >, std::pair< size_t, size_t > >::type EdgeMap
Edge map, used to connect edges.
const VertexData * vertexData
Pointer to vertex data used by this edge group.
bool degenerate
Indicates if this is a degenerate edge, ie it does not have 2 triangles.
A list of triangles, 3 vertices per triangle.
map< Vector3, size_t, vectorLess >::type CommonVertexMap
Map for identifying common vertices.
bool isClosed
Flag indicate the mesh is manifold.
const IndexData * indexData
The index data set this geometry data refers to.
Basic triangle structure.
vector< CommonVertex >::type CommonVertexList
size_t vertexSet
Place of vertex in common vertex list.
TriangleList triangles
Main triangles array, stores all triangles of this edge list.
vector< const VertexData * >::type VertexDataList
bool operator()(const Geometry &a, const Geometry &b) const
vector< EdgeGroup >::type EdgeGroupList
size_t originalIndex
The index set this was referenced (first) from.
size_t triCount
Number triangles of this edge group.
General utility class for building edge lists for geometry.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri Dec 20 2013 01:24:15