Work on mesh generation code.

This commit is contained in:
David Williams 2007-10-05 23:28:52 +00:00
parent 08f1034d76
commit 3f79261f8f
3 changed files with 81 additions and 13 deletions

View File

@ -32,7 +32,7 @@ namespace Ogre
{ {
public: public:
SurfaceVertex(); SurfaceVertex();
SurfaceVertex(UIntVector3 positionToSet); SurfaceVertex(UIntVector3 positionToSet, float alphaToSet);
SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet); SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet);
friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs); friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs);
@ -50,9 +50,11 @@ namespace Ogre
std::string toString(void) const; std::string toString(void) const;
private: private:
UIntVector3 position;
Vector3 normal;
float alpha; float alpha;
Vector3 normal;
UIntVector3 position;
SurfaceEdgeIterator edge; SurfaceEdgeIterator edge;

View File

@ -626,16 +626,80 @@ namespace Ogre
if((material0 == material1) && (material1 == material2)) if((material0 == material1) && (material1 == material2))
{ {
SurfaceVertex surfaceVertex0(vertex0); SurfaceVertex surfaceVertex0(vertex0,1.0);
surfaceVertex0.setAlpha(1.0); SurfaceVertex surfaceVertex1(vertex1,1.0);
SurfaceVertex surfaceVertex1(vertex1); SurfaceVertex surfaceVertex2(vertex2,1.0);
surfaceVertex1.setAlpha(1.0);
SurfaceVertex surfaceVertex2(vertex2);
surfaceVertex2.setAlpha(1.0);
result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
} }
else if(material0 == material1)
{
{
SurfaceVertex surfaceVertex0(vertex0,1.0);
SurfaceVertex surfaceVertex1(vertex1,1.0);
SurfaceVertex surfaceVertex2(vertex2,0.0);
result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
{
SurfaceVertex surfaceVertex0(vertex0,0.0);
SurfaceVertex surfaceVertex1(vertex1,0.0);
SurfaceVertex surfaceVertex2(vertex2,1.0);
result[material2].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
}
else if(material1 == material2)
{
{
SurfaceVertex surfaceVertex0(vertex0,0.0);
SurfaceVertex surfaceVertex1(vertex1,1.0);
SurfaceVertex surfaceVertex2(vertex2,1.0);
result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
{
SurfaceVertex surfaceVertex0(vertex0,1.0);
SurfaceVertex surfaceVertex1(vertex1,0.0);
SurfaceVertex surfaceVertex2(vertex2,0.0);
result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
}
else if(material2 == material0)
{
{
SurfaceVertex surfaceVertex0(vertex0,1.0);
SurfaceVertex surfaceVertex1(vertex1,0.0);
SurfaceVertex surfaceVertex2(vertex2,1.0);
result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
{
SurfaceVertex surfaceVertex0(vertex0,0.0);
SurfaceVertex surfaceVertex1(vertex1,1.0);
SurfaceVertex surfaceVertex2(vertex2,0.0);
surfaceVertex2.setAlpha(0.0);
result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
}
else else
{
{
SurfaceVertex surfaceVertex0(vertex0,1.0);
SurfaceVertex surfaceVertex1(vertex1,0.0);
SurfaceVertex surfaceVertex2(vertex2,0.0);
result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
{
SurfaceVertex surfaceVertex0(vertex0,0.0);
SurfaceVertex surfaceVertex1(vertex1,1.0);
SurfaceVertex surfaceVertex2(vertex2,0.0);
result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
{
SurfaceVertex surfaceVertex0(vertex0,0.0);
SurfaceVertex surfaceVertex1(vertex1,0.0);
SurfaceVertex surfaceVertex2(vertex2,1.0);
result[material2].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
}
}
/*else
{ {
std::set<uchar> materials; //FIXME - set::set is pretty slow for this as it only holds up to 3 vertices. std::set<uchar> materials; //FIXME - set::set is pretty slow for this as it only holds up to 3 vertices.
materials.insert(material0); materials.insert(material0);
@ -666,7 +730,7 @@ namespace Ogre
result[material].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); result[material].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
} }
} }*/
} }
} }

View File

@ -11,10 +11,12 @@ namespace Ogre
{ {
} }
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet) SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, float alphaToSet)
:position(positionToSet) :alpha(alphaToSet)
,position(positionToSet)
,m_uHash((position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z))
{ {
m_uHash = (position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z);
} }
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet) SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet)