- a little bit of plumbing for VBO's for static models (currently disabled via # define)

- small small speed improvement when calculating interpolations
This commit is contained in:
Mark Vejvoda
2011-01-18 07:52:06 +00:00
parent 55d213435a
commit c54e6dbf5d
14 changed files with 214 additions and 63 deletions

View File

@@ -42,8 +42,8 @@ public:
private:
void renderMesh(const Mesh *mesh);
void renderMeshNormals(const Mesh *mesh);
void renderMesh(const Mesh *mesh, bool isStaticModel);
void renderMeshNormals(const Mesh *mesh, bool isStaticModel);
};
}}}//end namespace

View File

@@ -25,6 +25,8 @@ using std::string;
using std::map;
using std::pair;
//#define ENABLE_VBO_CODE
namespace Shared{ namespace Graphics{
class Model;
@@ -39,7 +41,7 @@ class TextureManager;
// Part of a 3D model
// =====================================================
class Mesh{
class Mesh {
private:
//mesh data
Texture2D *textures[meshTextureCount];
@@ -50,6 +52,7 @@ private:
uint32 frameCount;
uint32 vertexCount;
uint32 indexCount;
uint32 texCoordFrameCount;
//vertex data
Vec3f *vertices;
@@ -71,6 +74,12 @@ private:
InterpolationData *interpolationData;
TextureManager *textureManager;
#if defined(ENABLE_VBO_CODE)
// Vertex Buffer Object Names
uint32 m_nVBOVertices; // Vertex VBO Name
uint32 m_nVBOTexCoords; // Texture Coordinate VBO Name
#endif
public:
//init & end
Mesh();
@@ -87,6 +96,12 @@ public:
uint32 getIndexCount() const {return indexCount;}
uint32 getTriangleCount() const;
#if defined(ENABLE_VBO_CODE)
uint32 getVBOVertices() const { return m_nVBOVertices;}
uint32 getVBOTexCoords() const { return m_nVBOTexCoords;}
void BuildVBOs();
#endif
//data
const Vec3f *getVertices() const {return vertices;}
const Vec3f *getNormals() const {return normals;}
@@ -109,8 +124,8 @@ public:
//interpolation
void buildInterpolationData();
void updateInterpolationData(float t, bool cycle) const;
void updateInterpolationVertices(float t, bool cycle) const;
void updateInterpolationData(float t, bool cycle);
void updateInterpolationVertices(float t, bool cycle);
//load
void loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
@@ -130,7 +145,7 @@ private:
// 3D Model, than can be loaded from a g3d file
// =====================================================
class Model{
class Model {
private:
TextureManager *textureManager;
@@ -139,6 +154,13 @@ private:
uint32 meshCount;
Mesh *meshes;
float lastTData;
bool lastCycleData;
float lastTVertex;
bool lastCycleVertex;
bool isStaticModel;
public:
//constructor & destructor
Model();
@@ -147,8 +169,8 @@ public:
virtual void end()= 0;
//data
void updateInterpolationData(float t, bool cycle) const;
void updateInterpolationVertices(float t, bool cycle) const;
void updateInterpolationData(float t, bool cycle);
void updateInterpolationVertices(float t, bool cycle);
void buildShadowVolumeData() const;
//get
@@ -168,6 +190,9 @@ public:
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
void deletePixels();
bool getIsStaticModel() const { return isStaticModel; }
void setIsStaticModel(bool value) { isStaticModel = value; }
private:
void buildInterpolationData() const;
};