OgreEdgeListBuilder.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __EdgeListBuilder_H__
#define __EdgeListBuilder_H__
#include "OgrePrerequisites.h"
#include "OgreVector4.h"
#include "OgreHardwareVertexBuffer.h"
#include "OgreRenderOperation.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport EdgeData : public EdgeDataAlloc
{
public:
EdgeData();
struct Triangle {
size_t indexSet;
size_t vertexSet;
size_t vertIndex[3];
size_t sharedVertIndex[3];
Triangle() :indexSet(0), vertexSet(0) {}
};
struct Edge {
size_t triIndex[2];
size_t vertIndex[2];
size_t sharedVertIndex[2];
bool degenerate;
};
typedef std::vector<Vector4, STLAllocator<Vector4, CategorisedAlignAllocPolicy<MEMCATEGORY_GEOMETRY> > > TriangleFaceNormalList;
typedef vector<char>::type TriangleLightFacingList;
typedef vector<Triangle>::type TriangleList;
typedef vector<Edge>::type EdgeList;
struct EdgeGroup
{
size_t vertexSet;
const VertexData* vertexData;
size_t triStart;
size_t triCount;
EdgeList edges;
};
typedef vector<EdgeGroup>::type EdgeGroupList;
TriangleList triangles;
TriangleFaceNormalList triangleFaceNormals;
TriangleLightFacingList triangleLightFacings;
EdgeGroupList edgeGroups;
bool isClosed;
void updateTriangleLightFacing(const Vector4& lightPos);
void updateFaceNormals(size_t vertexSet, const HardwareVertexBufferSharedPtr& positionBuffer);
void log(Log* log);
};
class _OgreExport EdgeListBuilder
{
public:
EdgeListBuilder();
virtual ~EdgeListBuilder();
void addVertexData(const VertexData* vertexData);
void addIndexData(const IndexData* indexData, size_t vertexSet = 0,
RenderOperation::OperationType opType = RenderOperation::OT_TRIANGLE_LIST);
EdgeData* build(void);
void log(Log* l);
protected:
struct CommonVertex {
Vector3 position;
size_t index;
size_t vertexSet;
size_t indexSet;
size_t originalIndex;
};
struct Geometry {
size_t vertexSet;
size_t indexSet;
const IndexData* indexData;
RenderOperation::OperationType opType;
};
struct geometryLess {
bool operator()(const Geometry& a, const Geometry& b) const
{
if (a.vertexSet < b.vertexSet) return true;
if (a.vertexSet > b.vertexSet) return false;
return a.indexSet < b.indexSet;
}
};
struct vectorLess {
bool operator()(const Vector3& a, const Vector3& b) const
{
if (a.x < b.x) return true;
if (a.x > b.x) return false;
if (a.y < b.y) return true;
if (a.y > b.y) return false;
return a.z < b.z;
}
};
typedef vector<const VertexData*>::type VertexDataList;
typedef vector<Geometry>::type GeometryList;
typedef vector<CommonVertex>::type CommonVertexList;
GeometryList mGeometryList;
VertexDataList mVertexDataList;
CommonVertexList mVertices;
EdgeData* mEdgeData;
typedef map<Vector3, size_t, vectorLess>::type CommonVertexMap;
CommonVertexMap mCommonVertexMap;
typedef multimap< std::pair<size_t, size_t>, std::pair<size_t, size_t> >::type EdgeMap;
EdgeMap mEdgeMap;
void buildTrianglesEdges(const Geometry &geometry);
size_t findOrCreateCommonVertex(const Vector3& vec, size_t vertexSet,
size_t indexSet, size_t originalIndex);
void connectOrCreateEdge(size_t vertexSet, size_t triangleIndex, size_t vertIndex0, size_t vertIndex1,
size_t sharedVertIndex0, size_t sharedVertIndex1);
};
}
#include "OgreHeaderSuffix.h"
#endif
OgreVector4.h
Ogre::Vector3::z
Real z
Definition: OgreVector3.h:54
Ogre::EdgeListBuilder::mVertices
CommonVertexList mVertices
Definition: OgreEdgeListBuilder.h:250
Ogre::EdgeListBuilder::geometryLess
Comparator for sorting geometries by vertex set.
Definition: OgreEdgeListBuilder.h:224
Ogre::EdgeListBuilder::CommonVertex::indexSet
size_t indexSet
The vertex set this came from.
Definition: OgreEdgeListBuilder.h:213
Ogre::EdgeData::Edge
Edge data.
Definition: OgreEdgeListBuilder.h:74
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::EdgeListBuilder::vectorLess
Comparator for unique vertex list.
Definition: OgreEdgeListBuilder.h:233
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::EdgeData::Triangle::indexSet
size_t indexSet
The set of indexes this triangle came from (NB it is possible that the triangles on one side of an ed...
Definition: OgreEdgeListBuilder.h:62
Ogre::IndexData
Summary class collecting together index data source information.
Definition: OgreVertexIndexData.h:242
Ogre::EdgeListBuilder::mVertexDataList
VertexDataList mVertexDataList
Definition: OgreEdgeListBuilder.h:249
Ogre::EdgeData::EdgeGroup::edges
EdgeList edges
The edges themselves.
Definition: OgreEdgeListBuilder.h:116
Ogre::EdgeData::EdgeList
vector< Edge >::type EdgeList
Definition: OgreEdgeListBuilder.h:99
Ogre::EdgeData::triangleFaceNormals
TriangleFaceNormalList triangleFaceNormals
All triangle face normals.
Definition: OgreEdgeListBuilder.h:127
Ogre::EdgeListBuilder::CommonVertex::index
size_t index
Location of point in euclidean space.
Definition: OgreEdgeListBuilder.h:211
Ogre::EdgeListBuilder::GeometryList
vector< Geometry >::type GeometryList
Definition: OgreEdgeListBuilder.h:245
Ogre::EdgeData
This class contains the information required to describe the edge connectivity of a given set of vert...
Definition: OgreEdgeListBuilder.h:52
Ogre::EdgeListBuilder::mGeometryList
GeometryList mGeometryList
Definition: OgreEdgeListBuilder.h:248
Ogre::EdgeListBuilder::mCommonVertexMap
CommonVertexMap mCommonVertexMap
Definition: OgreEdgeListBuilder.h:254
Ogre::EdgeListBuilder::CommonVertex
A vertex can actually represent several vertices in the final model, because vertices along texture s...
Definition: OgreEdgeListBuilder.h:209
Ogre::EdgeData::edgeGroups
EdgeGroupList edgeGroups
All edge groups of this edge list.
Definition: OgreEdgeListBuilder.h:131
Ogre::EdgeData::TriangleLightFacingList
vector< char >::type TriangleLightFacingList
Working vector used when calculating the silhouette.
Definition: OgreEdgeListBuilder.h:96
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::EdgeData::EdgeGroup::vertexSet
size_t vertexSet
The vertex set index that contains the vertices for this edge group.
Definition: OgreEdgeListBuilder.h:105
Ogre::EdgeListBuilder::CommonVertex::position
Vector3 position
Definition: OgreEdgeListBuilder.h:210
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:86
OgrePrerequisites.h
Ogre::EdgeData::EdgeGroup
A group of edges sharing the same vertex data.
Definition: OgreEdgeListBuilder.h:102
Ogre::EdgeListBuilder::geometryLess::operator()
bool operator()(const Geometry &a, const Geometry &b) const
Definition: OgreEdgeListBuilder.h:225
Ogre::EdgeData::TriangleFaceNormalList
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...
Definition: OgreEdgeListBuilder.h:91
Ogre::EdgeData::triangleLightFacings
TriangleLightFacingList triangleLightFacings
Triangle light facing states.
Definition: OgreEdgeListBuilder.h:129
Ogre::Vector3::y
Real y
Definition: OgreVector3.h:54
Ogre::EdgeListBuilder::Geometry
A set of indexed geometry data.
Definition: OgreEdgeListBuilder.h:217
OgreHardwareVertexBuffer.h
Ogre::EdgeListBuilder::Geometry::indexSet
size_t indexSet
The vertex data set this geometry data refers to.
Definition: OgreEdgeListBuilder.h:219
OgreRenderOperation.h
Ogre::EdgeListBuilder::vectorLess::operator()
bool operator()(const Vector3 &a, const Vector3 &b) const
Definition: OgreEdgeListBuilder.h:234
Ogre::RenderOperation::OperationType
OperationType
The rendering operation type to perform.
Definition: OgreRenderOperation.h:48
Ogre::EdgeListBuilder::Geometry::opType
RenderOperation::OperationType opType
The index information which describes the triangles.
Definition: OgreEdgeListBuilder.h:221
Ogre::EdgeData::TriangleList
vector< Triangle >::type TriangleList
Definition: OgreEdgeListBuilder.h:98
OgreHeaderSuffix.h
Ogre::EdgeData::EdgeGroup::triStart
size_t triStart
Index to main triangles array, indicate the first triangle of this edge group, and all triangles of t...
Definition: OgreEdgeListBuilder.h:112
Ogre::EdgeListBuilder::mEdgeData
EdgeData * mEdgeData
Definition: OgreEdgeListBuilder.h:251
Ogre::EdgeData::Triangle::vertexSet
size_t vertexSet
The vertex set these vertices came from.
Definition: OgreEdgeListBuilder.h:64
Ogre::Log
Definition: OgreLog.h:103
Ogre::EdgeListBuilder::EdgeMap
multimap< std::pair< size_t, size_t >, std::pair< size_t, size_t > >::type EdgeMap
Edge map, used to connect edges.
Definition: OgreEdgeListBuilder.h:258
Ogre::EdgeData::EdgeGroup::vertexData
const VertexData * vertexData
Pointer to vertex data used by this edge group.
Definition: OgreEdgeListBuilder.h:107
Ogre::EdgeListBuilder::Geometry::vertexSet
size_t vertexSet
Definition: OgreEdgeListBuilder.h:218
Ogre::EdgeData::Edge::degenerate
bool degenerate
Indicates if this is a degenerate edge, ie it does not have 2 triangles.
Definition: OgreEdgeListBuilder.h:85
Ogre::Vector3::x
Real x
Definition: OgreVector3.h:54
Ogre::RenderOperation::OT_TRIANGLE_LIST
A list of triangles, 3 vertices per triangle.
Definition: OgreRenderOperation.h:56
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::EdgeListBuilder::CommonVertexMap
map< Vector3, size_t, vectorLess >::type CommonVertexMap
Map for identifying common vertices.
Definition: OgreEdgeListBuilder.h:253
Ogre::EdgeData::isClosed
bool isClosed
Flag indicate the mesh is manifold.
Definition: OgreEdgeListBuilder.h:133
Ogre::EdgeListBuilder::Geometry::indexData
const IndexData * indexData
The index data set this geometry data refers to.
Definition: OgreEdgeListBuilder.h:220
Ogre::EdgeData::Triangle
Basic triangle structure.
Definition: OgreEdgeListBuilder.h:59
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::EdgeListBuilder::CommonVertexList
vector< CommonVertex >::type CommonVertexList
Definition: OgreEdgeListBuilder.h:246
Ogre::EdgeListBuilder::CommonVertex::vertexSet
size_t vertexSet
Place of vertex in common vertex list.
Definition: OgreEdgeListBuilder.h:212
Ogre::EdgeData::triangles
TriangleList triangles
Main triangles array, stores all triangles of this edge list.
Definition: OgreEdgeListBuilder.h:125
Ogre::EdgeListBuilder::VertexDataList
vector< const VertexData * >::type VertexDataList
Definition: OgreEdgeListBuilder.h:244
Ogre::EdgeListBuilder::mEdgeMap
EdgeMap mEdgeMap
Definition: OgreEdgeListBuilder.h:259
Ogre::EdgeData::EdgeGroupList
vector< EdgeGroup >::type EdgeGroupList
Definition: OgreEdgeListBuilder.h:120
Ogre::EdgeListBuilder::CommonVertex::originalIndex
size_t originalIndex
The index set this was referenced (first) from.
Definition: OgreEdgeListBuilder.h:214
Ogre::EdgeData::Triangle::Triangle
Triangle()
Definition: OgreEdgeListBuilder.h:71
Ogre::EdgeData::EdgeGroup::triCount
size_t triCount
Number triangles of this edge group.
Definition: OgreEdgeListBuilder.h:114
Ogre::EdgeListBuilder
General utility class for building edge lists for geometry.
Definition: OgreEdgeListBuilder.h:169
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::multimap
Definition: OgrePrerequisites.h:547

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.