- 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

@ -736,7 +736,7 @@ void Renderer::renderMouse3d() {
modelRenderer->begin(true, true, false); modelRenderer->begin(true, true, false);
glColor4fv(color.ptr()); glColor4fv(color.ptr());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color.ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color.ptr());
const Model *buildingModel= building->getFirstStOfClass(scStop)->getAnimation(); Model *buildingModel= building->getFirstStOfClass(scStop)->getAnimation();
if(gui->getSelectedFacing() != CardinalDir::NORTH) { if(gui->getSelectedFacing() != CardinalDir::NORTH) {
float rotateAmount = gui->getSelectedFacing() * 90.f; float rotateAmount = gui->getSelectedFacing() * 90.f;
@ -1815,7 +1815,7 @@ void Renderer::renderObjects(const int renderFps) {
visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) { visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) {
Object *o = qCache.visibleObjectList[visibleIndex]; Object *o = qCache.visibleObjectList[visibleIndex];
const Model *objModel= o->getModel(); Model *objModel= o->getModelPtr();
const Vec3f &v= o->getConstPos(); const Vec3f &v= o->getConstPos();
if(modelRenderStarted == false) { if(modelRenderStarted == false) {
@ -2078,7 +2078,7 @@ void Renderer::renderUnits(const int renderFps) {
} }
//render //render
const Model *model= unit->getCurrentModel(); Model *model= unit->getCurrentModelPtr();
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive()); model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
modelRenderer->render(model); modelRenderer->render(model);
@ -2617,7 +2617,7 @@ void Renderer::renderMenuBackground(const MenuBackground *menuBackground){
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glTranslatef(i*2.f-4.f, -1.4f, -7.5f); glTranslatef(i*2.f-4.f, -1.4f, -7.5f);
menuBackground->getCharacterModel(i)->updateInterpolationData(menuBackground->getAnim(), true); menuBackground->getCharacterModelPtr(i)->updateInterpolationData(menuBackground->getAnim(), true);
modelRenderer->render(menuBackground->getCharacterModel(i)); modelRenderer->render(menuBackground->getCharacterModel(i));
glPopMatrix(); glPopMatrix();
} }
@ -3287,7 +3287,7 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f); glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
//render //render
const Model *model= unit->getCurrentModel(); Model *model= unit->getCurrentModelPtr();
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive()); model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive());
modelRenderer->render(model); modelRenderer->render(model);

View File

@ -85,6 +85,7 @@ public:
Texture2D *getWaterTexture() const {return waterTexture;} Texture2D *getWaterTexture() const {return waterTexture;}
const Camera *getCamera() const {return &camera;} const Camera *getCamera() const {return &camera;}
const Model *getCharacterModel(int i) const {return characterModels[i];} const Model *getCharacterModel(int i) const {return characterModels[i];}
Model *getCharacterModelPtr(int i) const {return characterModels[i];}
const Model *getMainModel() const {return mainModel;} const Model *getMainModel() const {return mainModel;}
float getFade() const {return fade;} float getFade() const {return fade;}
Vec2f getRaindropPos(int i) const {return raindropPos[i];} Vec2f getRaindropPos(int i) const {return raindropPos[i];}

View File

@ -53,6 +53,10 @@ Object::~Object(){
renderer.removeObjectFromQuadCache(this); renderer.removeObjectFromQuadCache(this);
} }
Model *Object::getModelPtr() const {
return objectType==NULL ? (resource != NULL && resource->getType() != NULL ? resource->getType()->getModel() : NULL ) : objectType->getModel(variation);
}
const Model *Object::getModel() const{ const Model *Object::getModel() const{
return objectType==NULL ? (resource != NULL && resource->getType() != NULL ? resource->getType()->getModel() : NULL ) : objectType->getModel(variation); return objectType==NULL ? (resource != NULL && resource->getType() != NULL ? resource->getType()->getModel() : NULL ) : objectType->getModel(variation);
} }

View File

@ -53,6 +53,7 @@ public:
const Vec3f & getConstPos() const {return pos;} const Vec3f & getConstPos() const {return pos;}
float getRotation() {return rotation;} float getRotation() {return rotation;}
const Model *getModel() const; const Model *getModel() const;
Model *getModelPtr() const;
bool getWalkable() const; bool getWalkable() const;
void setResource(const ResourceType *resourceType, const Vec2i &pos); void setResource(const ResourceType *resourceType, const Vec2i &pos);

View File

@ -636,6 +636,16 @@ void Unit::setVisible(const bool visible) {
// =============================== Render related ================================== // =============================== Render related ==================================
Model *Unit::getCurrentModelPtr() const {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
}
return currSkill->getAnimation();
}
const Model *Unit::getCurrentModel() const{ const Model *Unit::getCurrentModel() const{
if(currSkill == NULL) { if(currSkill == NULL) {
char szBuf[4096]=""; char szBuf[4096]="";

View File

@ -392,6 +392,7 @@ public:
//render related //render related
const Model *getCurrentModel() const; const Model *getCurrentModel() const;
Model *getCurrentModelPtr() const;
Vec3f getCurrVector() const; Vec3f getCurrVector() const;
Vec3f getCurrVectorFlat() const; Vec3f getCurrVectorFlat() const;

View File

@ -29,6 +29,7 @@ void ObjectType::init(int modelCount, int objectClass, bool walkable, int height
void ObjectType::loadModel(const string &path){ void ObjectType::loadModel(const string &path){
Model *model= Renderer::getInstance().newModel(rsGame); Model *model= Renderer::getInstance().newModel(rsGame);
model->setIsStaticModel(true);
model->load(path); model->load(path);
color= Vec3f(0.f); color= Vec3f(0.f);
if(model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) { if(model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {

View File

@ -56,7 +56,7 @@ public:
int getResourceNumber() const {return resourceNumber;} int getResourceNumber() const {return resourceNumber;}
int getInterval() const {return interval;} int getInterval() const {return interval;}
int getDefResPerPatch() const {return defResPerPatch;} int getDefResPerPatch() const {return defResPerPatch;}
const Model *getModel() const {return model;} Model *getModel() const {return model;}
bool getRecoup_cost() const { return recoup_cost;} bool getRecoup_cost() const { return recoup_cost;}
static ResourceClass strToRc(const string &s); static ResourceClass strToRc(const string &s);

View File

@ -98,7 +98,7 @@ public:
int getEpCost() const {return mpCost;} int getEpCost() const {return mpCost;}
int getSpeed() const {return speed;} int getSpeed() const {return speed;}
int getAnimSpeed() const {return animSpeed;} int getAnimSpeed() const {return animSpeed;}
const Model *getAnimation() const {return animation;} Model *getAnimation() const {return animation;}
StaticSound *getSound() const {return sounds.getRandSound();} StaticSound *getSound() const {return sounds.getRandSound();}
float getSoundStartTime() const {return soundStartTime;} float getSoundStartTime() const {return soundStartTime;}

View File

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

View File

@ -25,6 +25,8 @@ using std::string;
using std::map; using std::map;
using std::pair; using std::pair;
//#define ENABLE_VBO_CODE
namespace Shared{ namespace Graphics{ namespace Shared{ namespace Graphics{
class Model; class Model;
@ -50,6 +52,7 @@ private:
uint32 frameCount; uint32 frameCount;
uint32 vertexCount; uint32 vertexCount;
uint32 indexCount; uint32 indexCount;
uint32 texCoordFrameCount;
//vertex data //vertex data
Vec3f *vertices; Vec3f *vertices;
@ -71,6 +74,12 @@ private:
InterpolationData *interpolationData; InterpolationData *interpolationData;
TextureManager *textureManager; 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: public:
//init & end //init & end
Mesh(); Mesh();
@ -87,6 +96,12 @@ public:
uint32 getIndexCount() const {return indexCount;} uint32 getIndexCount() const {return indexCount;}
uint32 getTriangleCount() const; uint32 getTriangleCount() const;
#if defined(ENABLE_VBO_CODE)
uint32 getVBOVertices() const { return m_nVBOVertices;}
uint32 getVBOTexCoords() const { return m_nVBOTexCoords;}
void BuildVBOs();
#endif
//data //data
const Vec3f *getVertices() const {return vertices;} const Vec3f *getVertices() const {return vertices;}
const Vec3f *getNormals() const {return normals;} const Vec3f *getNormals() const {return normals;}
@ -109,8 +124,8 @@ public:
//interpolation //interpolation
void buildInterpolationData(); void buildInterpolationData();
void updateInterpolationData(float t, bool cycle) const; void updateInterpolationData(float t, bool cycle);
void updateInterpolationVertices(float t, bool cycle) const; void updateInterpolationVertices(float t, bool cycle);
//load //load
void loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad); void loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad);
@ -139,6 +154,13 @@ private:
uint32 meshCount; uint32 meshCount;
Mesh *meshes; Mesh *meshes;
float lastTData;
bool lastCycleData;
float lastTVertex;
bool lastCycleVertex;
bool isStaticModel;
public: public:
//constructor & destructor //constructor & destructor
Model(); Model();
@ -147,8 +169,8 @@ public:
virtual void end()= 0; virtual void end()= 0;
//data //data
void updateInterpolationData(float t, bool cycle) const; void updateInterpolationData(float t, bool cycle);
void updateInterpolationVertices(float t, bool cycle) const; void updateInterpolationVertices(float t, bool cycle);
void buildShadowVolumeData() const; void buildShadowVolumeData() const;
//get //get
@ -168,6 +190,9 @@ public:
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;} void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
void deletePixels(); void deletePixels();
bool getIsStaticModel() const { return isStaticModel; }
void setIsStaticModel(bool value) { isStaticModel = value; }
private: private:
void buildInterpolationData() const; void buildInterpolationData() const;
}; };

View File

@ -104,7 +104,7 @@ void ModelRendererGl::render(const Model *model) {
//render every mesh //render every mesh
for(uint32 i=0; i<model->getMeshCount(); ++i) { for(uint32 i=0; i<model->getMeshCount(); ++i) {
renderMesh(model->getMesh(i)); renderMesh(model->getMesh(i),model->getIsStaticModel());
} }
//assertions //assertions
@ -118,7 +118,7 @@ void ModelRendererGl::renderNormalsOnly(const Model *model) {
//render every mesh //render every mesh
for(uint32 i=0; i<model->getMeshCount(); ++i) { for(uint32 i=0; i<model->getMeshCount(); ++i) {
renderMeshNormals(model->getMesh(i)); renderMeshNormals(model->getMesh(i),model->getIsStaticModel());
} }
//assertions //assertions
@ -127,7 +127,7 @@ void ModelRendererGl::renderNormalsOnly(const Model *model) {
// ===================== PRIVATE ======================= // ===================== PRIVATE =======================
void ModelRendererGl::renderMesh(const Mesh *mesh) { void ModelRendererGl::renderMesh(const Mesh *mesh, bool isStaticModel) {
//assertions //assertions
assertGl(); assertGl();
@ -178,6 +178,48 @@ void ModelRendererGl::renderMesh(const Mesh *mesh) {
//assertions //assertions
assertGl(); assertGl();
#if defined(ENABLE_VBO_CODE)
if(isStaticModel == true) {
//vertices
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOVertices() );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL ); // Set The Vertex Pointer To The Vertex Buffer
//normals
if(renderNormals) {
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, mesh->getInterpolationData()->getNormals());
}
else{
glDisableClientState(GL_NORMAL_ARRAY);
}
//tex coords
if(renderTextures && mesh->getTexture(mtDiffuse) != NULL ) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOTexCoords() );
if(duplicateTexCoords) {
glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//glTexCoordPointer(2, GL_FLOAT, 0, mesh->getTexCoords());
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer
}
glActiveTexture(GL_TEXTURE0);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//glTexCoordPointer(2, GL_FLOAT, 0, mesh->getTexCoords());
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer
}
else {
if(duplicateTexCoords) {
glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
glActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
else
#endif
{
//vertices //vertices
glVertexPointer(3, GL_FLOAT, 0, mesh->getInterpolationData()->getVertices()); glVertexPointer(3, GL_FLOAT, 0, mesh->getInterpolationData()->getVertices());
@ -210,6 +252,7 @@ void ModelRendererGl::renderMesh(const Mesh *mesh) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
} }
}
//draw model //draw model
glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, mesh->getIndices()); glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, mesh->getIndices());
@ -218,7 +261,7 @@ void ModelRendererGl::renderMesh(const Mesh *mesh) {
assertGl(); assertGl();
} }
void ModelRendererGl::renderMeshNormals(const Mesh *mesh) { void ModelRendererGl::renderMeshNormals(const Mesh *mesh,bool isStaticModel) {
glBegin(GL_LINES); glBegin(GL_LINES);
for(unsigned int i= 0; i<mesh->getIndexCount(); ++i){ for(unsigned int i= 0; i<mesh->getIndexCount(); ++i){

View File

@ -84,9 +84,6 @@ void InterpolationData::updateVertices(float t, bool cycle) {
if(iterFind != cacheVertices.end()) { if(iterFind != cacheVertices.end()) {
std::map<bool, Vec3f *>::iterator iterFind2 = iterFind->second.find(cycle); std::map<bool, Vec3f *>::iterator iterFind2 = iterFind->second.find(cycle);
if(iterFind2 != iterFind->second.end()) { if(iterFind2 != iterFind->second.end()) {
//for(uint32 j=0; j< vertexCount; ++j){
// vertices[j] = iterFind2->second[j];
//}
memcpy(vertices,iterFind2->second,sizeof(Vec3f) * vertexCount); memcpy(vertices,iterFind2->second,sizeof(Vec3f) * vertexCount);
return; return;
} }
@ -130,9 +127,6 @@ void InterpolationData::updateNormals(float t, bool cycle){
if(iterFind != cacheNormals.end()) { if(iterFind != cacheNormals.end()) {
std::map<bool, Vec3f *>::iterator iterFind2 = iterFind->second.find(cycle); std::map<bool, Vec3f *>::iterator iterFind2 = iterFind->second.find(cycle);
if(iterFind2 != iterFind->second.end()) { if(iterFind2 != iterFind->second.end()) {
//for(uint32 j=0; j< vertexCount; ++j){
// normals[j] = iterFind2->second[j];
//}
memcpy(normals,iterFind2->second,sizeof(Vec3f) * vertexCount); memcpy(normals,iterFind2->second,sizeof(Vec3f) * vertexCount);
return; return;
} }

View File

@ -18,6 +18,13 @@
#include "interpolation.h" #include "interpolation.h"
#include "conversion.h" #include "conversion.h"
#include "util.h" #include "util.h"
#if defined(ENABLE_VBO_CODE)
#include "opengl.h"
#endif
#include "leak_dumper.h" #include "leak_dumper.h"
using namespace Shared::Platform; using namespace Shared::Platform;
@ -39,6 +46,7 @@ Mesh::Mesh() {
frameCount= 0; frameCount= 0;
vertexCount= 0; vertexCount= 0;
indexCount= 0; indexCount= 0;
texCoordFrameCount = 0;
vertices= NULL; vertices= NULL;
normals= NULL; normals= NULL;
@ -94,14 +102,36 @@ void Mesh::buildInterpolationData(){
interpolationData= new InterpolationData(this); interpolationData= new InterpolationData(this);
} }
void Mesh::updateInterpolationData(float t, bool cycle) const{ void Mesh::updateInterpolationData(float t, bool cycle) {
interpolationData->update(t, cycle); interpolationData->update(t, cycle);
} }
void Mesh::updateInterpolationVertices(float t, bool cycle) const{ void Mesh::updateInterpolationVertices(float t, bool cycle) {
interpolationData->updateVertices(t, cycle); interpolationData->updateVertices(t, cycle);
} }
#if defined(ENABLE_VBO_CODE)
void Mesh::BuildVBOs() {
// Generate And Bind The Vertex Buffer
glGenBuffersARB( 1, &m_nVBOVertices ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices ); // Bind The Buffer
// Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, getVertexCount() * 3 * sizeof(float), vertices, GL_STATIC_DRAW_ARB );
// Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB( 1, &m_nVBOTexCoords ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords ); // Bind The Buffer
// Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, getVertexCount() * 2 * sizeof(float), texCoords, GL_STATIC_DRAW_ARB );
// Our Copy Of The Data Is No Longer Necessary, It Is Safe In The Graphics Card
delete [] vertices; vertices = NULL;
delete [] texCoords; texCoords = NULL;
}
#endif
// ==================== load ==================== // ==================== load ====================
void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) { void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
@ -123,6 +153,7 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,boo
frameCount= meshHeader.vertexFrameCount; frameCount= meshHeader.vertexFrameCount;
vertexCount= meshHeader.pointCount; vertexCount= meshHeader.pointCount;
indexCount= meshHeader.indexCount; indexCount= meshHeader.indexCount;
texCoordFrameCount = meshHeader.texCoordFrameCount;
init(); init();
@ -176,6 +207,7 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,boo
frameCount= meshHeader.vertexFrameCount; frameCount= meshHeader.vertexFrameCount;
vertexCount= meshHeader.pointCount; vertexCount= meshHeader.pointCount;
indexCount= meshHeader.indexCount; indexCount= meshHeader.indexCount;
texCoordFrameCount = meshHeader.texCoordFrameCount;
init(); init();
@ -366,10 +398,16 @@ Model::Model(){
meshCount= 0; meshCount= 0;
meshes= NULL; meshes= NULL;
textureManager= NULL; textureManager= NULL;
lastTData = -1;
lastCycleData = -1;
lastTVertex = -1;
lastCycleVertex = -1;
isStaticModel = false;
} }
Model::~Model(){ Model::~Model(){
delete [] meshes; delete [] meshes;
meshes = NULL;
} }
// ==================== data ==================== // ==================== data ====================
@ -380,16 +418,24 @@ void Model::buildInterpolationData() const{
} }
} }
void Model::updateInterpolationData(float t, bool cycle) const{ void Model::updateInterpolationData(float t, bool cycle) {
if(lastTData != t || lastCycleData != cycle) {
for(unsigned int i=0; i<meshCount; ++i){ for(unsigned int i=0; i<meshCount; ++i){
meshes[i].updateInterpolationData(t, cycle); meshes[i].updateInterpolationData(t, cycle);
} }
lastTData = t;
lastCycleData = cycle;
}
} }
void Model::updateInterpolationVertices(float t, bool cycle) const{ void Model::updateInterpolationVertices(float t, bool cycle) {
if(lastTVertex != t || lastCycleVertex != cycle) {
for(unsigned int i=0; i<meshCount; ++i){ for(unsigned int i=0; i<meshCount; ++i){
meshes[i].updateInterpolationVertices(t, cycle); meshes[i].updateInterpolationVertices(t, cycle);
} }
lastTVertex = t;
lastCycleVertex = cycle;
}
} }
// ==================== get ==================== // ==================== get ====================
@ -493,7 +539,6 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
//version 4 //version 4
if(fileHeader.version == 4) { if(fileHeader.version == 4) {
//model header //model header
ModelHeader modelHeader; ModelHeader modelHeader;
readBytes = fread(&modelHeader, sizeof(ModelHeader), 1, f); readBytes = fread(&modelHeader, sizeof(ModelHeader), 1, f);
@ -508,6 +553,15 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
meshes[i].load(dir, f, textureManager,deletePixMapAfterLoad); meshes[i].load(dir, f, textureManager,deletePixMapAfterLoad);
meshes[i].buildInterpolationData(); meshes[i].buildInterpolationData();
} }
#if defined(ENABLE_VBO_CODE)
if(isStaticModel == true) {
this->updateInterpolationData(0.f, true);
for(uint32 i=0; i<meshCount; ++i){
meshes[i].BuildVBOs();
}
}
#endif
} }
//version 3 //version 3
else if(fileHeader.version==3){ else if(fileHeader.version==3){
@ -518,16 +572,33 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
meshes[i].loadV3(dir, f, textureManager,deletePixMapAfterLoad); meshes[i].loadV3(dir, f, textureManager,deletePixMapAfterLoad);
meshes[i].buildInterpolationData(); meshes[i].buildInterpolationData();
} }
#if defined(ENABLE_VBO_CODE)
if(isStaticModel == true) {
this->updateInterpolationData(0.f, true);
for(uint32 i=0; i<meshCount; ++i){
meshes[i].BuildVBOs();
}
}
#endif
} }
//version 2 //version 2
else if(fileHeader.version==2) { else if(fileHeader.version==2) {
readBytes = fread(&meshCount, sizeof(meshCount), 1, f); readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
meshes= new Mesh[meshCount]; meshes= new Mesh[meshCount];
for(uint32 i=0; i<meshCount; ++i){ for(uint32 i=0; i<meshCount; ++i){
meshes[i].loadV2(dir, f, textureManager,deletePixMapAfterLoad); meshes[i].loadV2(dir, f, textureManager,deletePixMapAfterLoad);
meshes[i].buildInterpolationData(); meshes[i].buildInterpolationData();
} }
#if defined(ENABLE_VBO_CODE)
if(isStaticModel == true) {
this->updateInterpolationData(0.f, true);
for(uint32 i=0; i<meshCount; ++i){
meshes[i].BuildVBOs();
}
}
#endif
} }
else { else {
throw runtime_error("Invalid model version: "+ intToStr(fileHeader.version)); throw runtime_error("Invalid model version: "+ intToStr(fileHeader.version));