Refactoring work... Argh, this is hard!
This commit is contained in:
parent
47bb4b016d
commit
adfdb3062f
@ -82,7 +82,7 @@ namespace Ogre
|
|||||||
void generateLevelVolume(void);
|
void generateLevelVolume(void);
|
||||||
|
|
||||||
std::map<uchar, SurfacePatch> generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ) const;
|
std::map<uchar, SurfacePatch> generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ) const;
|
||||||
void mergeVertices6(std::vector< std::vector<SurfaceVertex> >& vertexData, std::vector< std::vector<SurfaceTriangle> >& indexData) const;
|
//void mergeVertices6(std::vector< std::vector<SurfaceVertex> >& vertexData, std::vector< std::vector<SurfaceTriangle> >& indexData) const;
|
||||||
bool verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<SurfaceVertex>& vertexData) const;
|
bool verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<SurfaceVertex>& vertexData) const;
|
||||||
|
|
||||||
void doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value);
|
void doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef __SurfacePatch_H__
|
#ifndef __SurfacePatch_H__
|
||||||
#define __SurfacePatch_H__
|
#define __SurfacePatch_H__
|
||||||
|
|
||||||
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SurfaceVertex.h"
|
#include "SurfaceVertex.h"
|
||||||
@ -16,12 +17,17 @@ namespace Ogre
|
|||||||
|
|
||||||
void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2);
|
void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2);
|
||||||
|
|
||||||
const std::vector<SurfaceVertex>& getVertexArray();
|
/*const std::vector<SurfaceVertex> getVertexArray();
|
||||||
const std::vector<SurfaceTriangle>& getTriangleArray();
|
const std::vector<SurfaceTriangle> getTriangleArray();*/
|
||||||
|
|
||||||
|
void getVertexAndIndexData(std::vector<SurfaceVertex>& vertexData, std::vector<uint>& indexData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SurfaceVertex> m_vecVertices;
|
std::list<SurfaceVertex> m_listVertices;
|
||||||
std::vector<SurfaceTriangle> m_vecTriangles;
|
std::list<SurfaceTriangle> m_listTriangles;
|
||||||
|
|
||||||
|
std::vector<SurfaceVertex> m_vecVertexData;
|
||||||
|
std::vector<uint> m_vecIndexData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace Ogre
|
|||||||
SurfacePatchRenderable(const String& material = "BaseWhiteNoLighting");
|
SurfacePatchRenderable(const String& material = "BaseWhiteNoLighting");
|
||||||
~SurfacePatchRenderable(void);
|
~SurfacePatchRenderable(void);
|
||||||
|
|
||||||
void setGeometry(std::vector<SurfaceVertex> verticesToSet, std::vector<SurfaceTriangle> indicesToSet);
|
void setGeometry(std::vector<SurfaceVertex> verticesToSet, std::vector<uint> indicesToSet);
|
||||||
|
|
||||||
Real getSquaredViewDepth(const Camera *cam) const;
|
Real getSquaredViewDepth(const Camera *cam) const;
|
||||||
Real getBoundingRadius(void) const;
|
Real getBoundingRadius(void) const;
|
||||||
|
@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
|
|
||||||
#include "OgreVector3.h"
|
#include "OgreVector3.h"
|
||||||
|
|
||||||
|
#include "SurfaceVertex.h"
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class SurfaceTriangle
|
class SurfaceTriangle
|
||||||
@ -31,18 +33,18 @@ namespace Ogre
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//FIXME - maybe these should be short?
|
//FIXME - maybe these should be short?
|
||||||
ulong v0;
|
/*ulong v0;
|
||||||
ulong v1;
|
ulong v1;
|
||||||
ulong v2;
|
ulong v2;*/
|
||||||
|
std::list<SurfaceVertex>::iterator v0;
|
||||||
|
std::list<SurfaceVertex>::iterator v1;
|
||||||
|
std::list<SurfaceVertex>::iterator v2;
|
||||||
|
|
||||||
SurfaceTriangle()
|
SurfaceTriangle()
|
||||||
:v0(0)
|
|
||||||
,v1(0)
|
|
||||||
,v2(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceTriangle(uint v0ToSet, uint v1ToSet, uint v2ToSet)
|
SurfaceTriangle(std::list<SurfaceVertex>::iterator v0ToSet, std::list<SurfaceVertex>::iterator v1ToSet, std::list<SurfaceVertex>::iterator v2ToSet)
|
||||||
:v0(v0ToSet)
|
:v0(v0ToSet)
|
||||||
,v1(v1ToSet)
|
,v1(v1ToSet)
|
||||||
,v2(v2ToSet)
|
,v2(v2ToSet)
|
||||||
|
@ -33,6 +33,10 @@ namespace Ogre
|
|||||||
Vector3 normal;
|
Vector3 normal;
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
||||||
|
SurfaceVertex()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SurfaceVertex(Vector3 positionToSet)
|
SurfaceVertex(Vector3 positionToSet)
|
||||||
:position(positionToSet)
|
:position(positionToSet)
|
||||||
{
|
{
|
||||||
@ -50,21 +54,21 @@ namespace Ogre
|
|||||||
return ((position - rhs).length() < 0.01);
|
return ((position - rhs).length() < 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*bool operator < (const Vertex& rhs) const
|
bool operator < (const SurfaceVertex& rhs) const
|
||||||
{
|
{
|
||||||
if(z < rhs.z)
|
if(position.z < rhs.position.z)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(y < rhs.y)
|
if(position.y < rhs.position.y)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(x < rhs.x)
|
if(position.x < rhs.position.x)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -74,7 +78,7 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,17 +354,17 @@ namespace Ogre
|
|||||||
//for(uint meshCt = 1; meshCt < 256; ++meshCt)
|
//for(uint meshCt = 1; meshCt < 256; ++meshCt)
|
||||||
for(std::map<uchar, SurfacePatch>::iterator iterSurfacePatch = mapSurfacePatch.begin(); iterSurfacePatch != mapSurfacePatch.end(); ++iterSurfacePatch)
|
for(std::map<uchar, SurfacePatch>::iterator iterSurfacePatch = mapSurfacePatch.begin(); iterSurfacePatch != mapSurfacePatch.end(); ++iterSurfacePatch)
|
||||||
{
|
{
|
||||||
/*if(indexData[meshCt].size() == 0)
|
std::vector<SurfaceVertex> vertexData;
|
||||||
{
|
std::vector<uint> indexData;
|
||||||
continue;
|
iterSurfacePatch->second.getVertexAndIndexData(vertexData, indexData);
|
||||||
}*/
|
|
||||||
std::map<uchar,SurfacePatchRenderable*>::iterator iterSurface = m_mapSurfaces[regionX][regionY][regionZ].find(iterSurfacePatch->first);
|
std::map<uchar,SurfacePatchRenderable*>::iterator iterSurface = m_mapSurfaces[regionX][regionY][regionZ].find(iterSurfacePatch->first);
|
||||||
if(iterSurface == m_mapSurfaces[regionX][regionY][regionZ].end())
|
if(iterSurface == m_mapSurfaces[regionX][regionY][regionZ].end())
|
||||||
{
|
{
|
||||||
//We have to create the surface
|
//We have to create the surface
|
||||||
SurfacePatchRenderable* surface = new SurfacePatchRenderable(materialMap->getMaterialAtIndex(iterSurfacePatch->first));
|
SurfacePatchRenderable* surface = new SurfacePatchRenderable(materialMap->getMaterialAtIndex(iterSurfacePatch->first));
|
||||||
//surface->setGeometry(vertexData[meshCt],indexData[meshCt]);
|
//surface->setGeometry(vertexData[meshCt],indexData[meshCt]);
|
||||||
surface->setGeometry(iterSurfacePatch->second.getVertexArray(),iterSurfacePatch->second.getTriangleArray());
|
surface->setGeometry(vertexData, indexData);
|
||||||
|
|
||||||
m_mapSurfaces[regionX][regionY][regionZ].insert(std::make_pair(iterSurfacePatch->first,surface));
|
m_mapSurfaces[regionX][regionY][regionZ].insert(std::make_pair(iterSurfacePatch->first,surface));
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ namespace Ogre
|
|||||||
{
|
{
|
||||||
//We just update the existing surface
|
//We just update the existing surface
|
||||||
//iterSurface->second->setGeometry(vertexData[meshCt],indexData[meshCt]);
|
//iterSurface->second->setGeometry(vertexData[meshCt],indexData[meshCt]);
|
||||||
iterSurface->second->setGeometry(iterSurfacePatch->second.getVertexArray(),iterSurfacePatch->second.getTriangleArray());
|
iterSurface->second->setGeometry(vertexData, indexData);
|
||||||
sceneNode->attachObject(iterSurface->second);
|
sceneNode->attachObject(iterSurface->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -560,6 +560,8 @@ namespace Ogre
|
|||||||
vertexData.resize(256);
|
vertexData.resize(256);
|
||||||
indexData.resize(256);
|
indexData.resize(256);
|
||||||
|
|
||||||
|
std::map<uchar, SurfacePatch> result;
|
||||||
|
|
||||||
//Used later to check if vertex has already been added
|
//Used later to check if vertex has already been added
|
||||||
long int vertexIndices[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][10];
|
long int vertexIndices[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][10];
|
||||||
//uchar materialAtPosition[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1]; //FIXME - do we really need this? Can't we just get it from the volume...
|
//uchar materialAtPosition[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1]; //FIXME - do we really need this? Can't we just get it from the volume...
|
||||||
@ -754,19 +756,42 @@ namespace Ogre
|
|||||||
|
|
||||||
//vertexScaled values are always integers and so can be used as indices.
|
//vertexScaled values are always integers and so can be used as indices.
|
||||||
//FIXME - these integer values can just be obtained by using floor()?
|
//FIXME - these integer values can just be obtained by using floor()?
|
||||||
long int index;
|
/*long int index;
|
||||||
unsigned int vertexScaledX;
|
unsigned int vertexScaledX;
|
||||||
unsigned int vertexScaledY;
|
unsigned int vertexScaledY;
|
||||||
unsigned int vertexScaledZ;
|
unsigned int vertexScaledZ;*/
|
||||||
|
|
||||||
SurfaceTriangle triangle; //Triangle to be created...
|
//SurfaceTriangle triangle; //Triangle to be created...
|
||||||
|
|
||||||
for(std::set<uchar>::iterator materialsIter = materials.begin(); materialsIter != materials.end(); ++materialsIter)
|
for(std::set<uchar>::iterator materialsIter = materials.begin(); materialsIter != materials.end(); ++materialsIter)
|
||||||
{
|
{
|
||||||
uchar material = *materialsIter;
|
uchar material = *materialsIter;
|
||||||
|
|
||||||
|
SurfaceVertex surfaceVertex0(vertex0);
|
||||||
|
if(material0 == material)
|
||||||
|
surfaceVertex0.alpha = 1.0;
|
||||||
|
else
|
||||||
|
surfaceVertex0.alpha = 0.0;
|
||||||
|
surfaceVertex0.normal = Vector3(1.0,1.0,1.0);
|
||||||
|
|
||||||
|
SurfaceVertex surfaceVertex1(vertex1);
|
||||||
|
if(material1 == material)
|
||||||
|
surfaceVertex1.alpha = 1.0;
|
||||||
|
else
|
||||||
|
surfaceVertex1.alpha = 0.0;
|
||||||
|
surfaceVertex1.normal = Vector3(1.0,1.0,1.0);
|
||||||
|
|
||||||
|
SurfaceVertex surfaceVertex2(vertex2);
|
||||||
|
if(material2 == material)
|
||||||
|
surfaceVertex2.alpha = 1.0;
|
||||||
|
else
|
||||||
|
surfaceVertex2.alpha = 0.0;
|
||||||
|
surfaceVertex2.normal = Vector3(1.0,1.0,1.0);
|
||||||
|
|
||||||
|
result[material].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2);
|
||||||
|
|
||||||
//Get scaled values for vertex 0
|
//Get scaled values for vertex 0
|
||||||
vertexScaledX = static_cast<unsigned int>((vertex0.x * 2.0) + 0.5);
|
/*vertexScaledX = static_cast<unsigned int>((vertex0.x * 2.0) + 0.5);
|
||||||
vertexScaledY = static_cast<unsigned int>((vertex0.y * 2.0) + 0.5);
|
vertexScaledY = static_cast<unsigned int>((vertex0.y * 2.0) + 0.5);
|
||||||
vertexScaledZ = static_cast<unsigned int>((vertex0.z * 2.0) + 0.5);
|
vertexScaledZ = static_cast<unsigned int>((vertex0.z * 2.0) + 0.5);
|
||||||
vertexScaledX %= OGRE_REGION_SIDE_LENGTH*2+1;
|
vertexScaledX %= OGRE_REGION_SIDE_LENGTH*2+1;
|
||||||
@ -847,7 +872,7 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add the triangle
|
//Add the triangle
|
||||||
indexData[material].push_back(triangle);
|
indexData[material].push_back(triangle);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -859,7 +884,7 @@ namespace Ogre
|
|||||||
//Compute normals
|
//Compute normals
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
for(uint materialCt = 0; materialCt < 256; materialCt++)
|
/*for(uint materialCt = 0; materialCt < 256; materialCt++)
|
||||||
{
|
{
|
||||||
for(uint vertexCt = 0; vertexCt < vertexData[materialCt].size(); ++vertexCt)
|
for(uint vertexCt = 0; vertexCt < vertexData[materialCt].size(); ++vertexCt)
|
||||||
{
|
{
|
||||||
@ -943,7 +968,7 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//Decimate mesh
|
//Decimate mesh
|
||||||
@ -953,7 +978,7 @@ namespace Ogre
|
|||||||
//mergeVertices6(vertexData, indexData);
|
//mergeVertices6(vertexData, indexData);
|
||||||
//Ogre::LogManager::getSingleton().logMessage("After merge: vertices = " + Ogre::StringConverter::toString(vertexData[4].size()) + ", triangles = " + Ogre::StringConverter::toString(indexData[4].size()/3));
|
//Ogre::LogManager::getSingleton().logMessage("After merge: vertices = " + Ogre::StringConverter::toString(vertexData[4].size()) + ", triangles = " + Ogre::StringConverter::toString(indexData[4].size()/3));
|
||||||
|
|
||||||
std::map<uchar, SurfacePatch> result;
|
/*std::map<uchar, SurfacePatch> result;
|
||||||
for(uint materialCt = 1; materialCt < 256; materialCt++)
|
for(uint materialCt = 1; materialCt < 256; materialCt++)
|
||||||
{
|
{
|
||||||
if(indexData[materialCt].size() == 0)
|
if(indexData[materialCt].size() == 0)
|
||||||
@ -973,11 +998,13 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.insert(std::make_pair(materialCt, surfacePatch));
|
result.insert(std::make_pair(materialCt, surfacePatch));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BLAH
|
||||||
|
|
||||||
void PolyVoxSceneManager::mergeVertices6(std::vector< std::vector<SurfaceVertex> >& vertexData, std::vector< std::vector<SurfaceTriangle> >& indexData) const
|
void PolyVoxSceneManager::mergeVertices6(std::vector< std::vector<SurfaceVertex> >& vertexData, std::vector< std::vector<SurfaceTriangle> >& indexData) const
|
||||||
{
|
{
|
||||||
for(uint material = 1; material < 256; ++material)
|
for(uint material = 1; material < 256; ++material)
|
||||||
@ -1092,6 +1119,8 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool PolyVoxSceneManager::verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<SurfaceVertex>& vertexData) const
|
bool PolyVoxSceneManager::verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<SurfaceVertex>& vertexData) const
|
||||||
{
|
{
|
||||||
//FIXME - specially handle the case where they are all the same.
|
//FIXME - specially handle the case where they are all the same.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "SurfacePatch.h"
|
#include "SurfacePatch.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
SurfacePatch::SurfacePatch()
|
SurfacePatch::SurfacePatch()
|
||||||
@ -14,23 +16,60 @@ namespace Ogre
|
|||||||
{
|
{
|
||||||
SurfaceTriangle triangle;
|
SurfaceTriangle triangle;
|
||||||
|
|
||||||
m_vecVertices.push_back(v0);
|
m_listVertices.push_back(v0);
|
||||||
triangle.v0 = m_vecVertices.size()-1;
|
triangle.v0 = m_listVertices.end();
|
||||||
m_vecVertices.push_back(v1);
|
triangle.v0--;
|
||||||
triangle.v1 = m_vecVertices.size()-1;
|
|
||||||
m_vecVertices.push_back(v2);
|
|
||||||
triangle.v2 = m_vecVertices.size()-1;
|
|
||||||
|
|
||||||
m_vecTriangles.push_back(triangle);
|
m_listVertices.push_back(v1);
|
||||||
|
triangle.v1 = m_listVertices.end();
|
||||||
|
triangle.v1--;
|
||||||
|
|
||||||
|
m_listVertices.push_back(v2);
|
||||||
|
triangle.v2 = m_listVertices.end();
|
||||||
|
triangle.v2--;
|
||||||
|
|
||||||
|
m_listTriangles.push_back(triangle);
|
||||||
|
|
||||||
|
/*m_vecVertexData.push_back(v0);
|
||||||
|
m_vecIndexData.push_back(m_vecVertexData.size()-1);
|
||||||
|
m_vecVertexData.push_back(v1);
|
||||||
|
m_vecIndexData.push_back(m_vecVertexData.size()-1);
|
||||||
|
m_vecVertexData.push_back(v2);
|
||||||
|
m_vecIndexData.push_back(m_vecVertexData.size()-1);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<SurfaceVertex>& SurfacePatch::getVertexArray()
|
/*const std::vector<SurfaceVertex> SurfacePatch::getVertexArray()
|
||||||
{
|
{
|
||||||
return m_vecVertices;
|
std::vector<SurfaceVertex> vertexArray;
|
||||||
|
vertexArray.resize(m_listVertices.size());
|
||||||
|
std::copy(m_listVertices.begin(), m_listVertices.end(), vertexArray.begin());
|
||||||
|
return vertexArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<SurfaceTriangle>& SurfacePatch::getTriangleArray()
|
const std::vector<SurfaceTriangle> SurfacePatch::getTriangleArray()
|
||||||
{
|
{
|
||||||
return m_vecTriangles;
|
std::vector<SurfaceTriangle> triangleArray;
|
||||||
|
triangleArray.resize(m_listTriangles.size());
|
||||||
|
std::copy(m_listTriangles.begin(), m_listTriangles.end(), triangleArray.begin());
|
||||||
|
return triangleArray;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void SurfacePatch::getVertexAndIndexData(std::vector<SurfaceVertex>& vertexData, std::vector<uint>& indexData)
|
||||||
|
{
|
||||||
|
vertexData.clear();
|
||||||
|
indexData.clear();
|
||||||
|
|
||||||
|
for(std::list<SurfaceTriangle>::iterator iterTriangles = m_listTriangles.begin(); iterTriangles != m_listTriangles.end(); ++iterTriangles)
|
||||||
|
{
|
||||||
|
vertexData.push_back(*(iterTriangles->v0));
|
||||||
|
indexData.push_back(vertexData.size()-1);
|
||||||
|
vertexData.push_back(*(iterTriangles->v1));
|
||||||
|
indexData.push_back(vertexData.size()-1);
|
||||||
|
vertexData.push_back(*(iterTriangles->v2));
|
||||||
|
indexData.push_back(vertexData.size()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*vertexData = m_vecVertexData;
|
||||||
|
indexData = m_vecIndexData;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ namespace Ogre
|
|||||||
delete mRenderOp.indexData;
|
delete mRenderOp.indexData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfacePatchRenderable::setGeometry(std::vector<SurfaceVertex> verticesToSet, std::vector<SurfaceTriangle> indicesToSet)
|
void SurfacePatchRenderable::setGeometry(std::vector<SurfaceVertex> verticesToSet, std::vector<uint> indicesToSet)
|
||||||
{
|
{
|
||||||
|
|
||||||
//LogManager::getSingleton().logMessage("In setGeometry()");
|
//LogManager::getSingleton().logMessage("In setGeometry()");
|
||||||
@ -28,7 +28,7 @@ namespace Ogre
|
|||||||
mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST; // OT_LINE_LIST, OT_LINE_STRIP
|
mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST; // OT_LINE_LIST, OT_LINE_STRIP
|
||||||
mRenderOp.useIndexes = true;
|
mRenderOp.useIndexes = true;
|
||||||
mRenderOp.indexData->indexStart = 0;
|
mRenderOp.indexData->indexStart = 0;
|
||||||
mRenderOp.indexData->indexCount = indicesToSet.size()*3;
|
mRenderOp.indexData->indexCount = indicesToSet.size();
|
||||||
|
|
||||||
//LogManager::getSingleton().logMessage("Finished initialisaing stuff");
|
//LogManager::getSingleton().logMessage("Finished initialisaing stuff");
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace Ogre
|
|||||||
HardwareIndexBufferSharedPtr ibuf =
|
HardwareIndexBufferSharedPtr ibuf =
|
||||||
HardwareBufferManager::getSingleton().createIndexBuffer(
|
HardwareBufferManager::getSingleton().createIndexBuffer(
|
||||||
HardwareIndexBuffer::IT_16BIT, // type of index
|
HardwareIndexBuffer::IT_16BIT, // type of index
|
||||||
mRenderOp.indexData->indexCount * 3, // number of indexes
|
mRenderOp.indexData->indexCount, // number of indexes
|
||||||
HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage
|
HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage
|
||||||
false); // no shadow buffer
|
false); // no shadow buffer
|
||||||
|
|
||||||
@ -105,12 +105,12 @@ namespace Ogre
|
|||||||
unsigned short* pIdx = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_DISCARD));
|
unsigned short* pIdx = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_DISCARD));
|
||||||
for(int i = 0; i < indicesToSet.size(); i++)
|
for(int i = 0; i < indicesToSet.size(); i++)
|
||||||
{
|
{
|
||||||
*pIdx = indicesToSet[i].v0;
|
*pIdx = indicesToSet[i];
|
||||||
pIdx++;
|
pIdx++;
|
||||||
*pIdx = indicesToSet[i].v1;
|
/**pIdx = indicesToSet[i].v1;
|
||||||
pIdx++;
|
pIdx++;
|
||||||
*pIdx = indicesToSet[i].v2;
|
*pIdx = indicesToSet[i].v2;
|
||||||
pIdx++;
|
pIdx++;*/
|
||||||
}
|
}
|
||||||
ibuf->unlock();
|
ibuf->unlock();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user