* Submeshes can now be switched on and off by GeoSet ID
This commit is contained in:
parent
e960db4cd8
commit
6f86fc4e89
@ -1420,10 +1420,30 @@ void CM2Mesh::newAnimation(u32 id, s32 start, s32 end, f32 probability)
|
|||||||
a.end = end;
|
a.end = end;
|
||||||
a.probability = probability + prev_prob;
|
a.probability = probability + prev_prob;
|
||||||
Animations.push_back(a);
|
Animations.push_back(a);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CM2Mesh::setGeoSetRender(u32 id, bool render)//this sets the render status for a geoset ID
|
||||||
|
{
|
||||||
|
for(u16 i = 0; i < GeoSetID.size(); i++)
|
||||||
|
{
|
||||||
|
if(GeoSetID[i]==id)
|
||||||
|
{
|
||||||
|
GeoSetRender[i]=render;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool CM2Mesh::getGeoSetRender(u32 meshbufferNumber)//This gets the render status for a specific mesh buffer
|
||||||
|
{
|
||||||
|
if(GeoSetRender.size()>meshbufferNumber)
|
||||||
|
{
|
||||||
|
return GeoSetRender[meshbufferNumber];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end namespace scene
|
} // end namespace scene
|
||||||
|
|||||||
@ -14,7 +14,6 @@ namespace scene
|
|||||||
u32 begin;
|
u32 begin;
|
||||||
u32 end;
|
u32 end;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IAnimatedMeshSceneNode;
|
class IAnimatedMeshSceneNode;
|
||||||
class IBoneSceneNode;
|
class IBoneSceneNode;
|
||||||
|
|
||||||
@ -133,6 +132,12 @@ namespace scene
|
|||||||
//! loaders should call this after populating the mesh
|
//! loaders should call this after populating the mesh
|
||||||
virtual void finalize();
|
virtual void finalize();
|
||||||
|
|
||||||
|
SSkinMeshBuffer *createBuffer(u32 id)
|
||||||
|
{
|
||||||
|
GeoSetID.push_back(id);
|
||||||
|
GeoSetRender.push_back((id==0?true:false));//This may be changed later on when we know more about the submesh switching business
|
||||||
|
return createBuffer();
|
||||||
|
};
|
||||||
virtual SSkinMeshBuffer *createBuffer();
|
virtual SSkinMeshBuffer *createBuffer();
|
||||||
|
|
||||||
virtual SJoint *createJoint(SJoint *parent=0);
|
virtual SJoint *createJoint(SJoint *parent=0);
|
||||||
@ -146,6 +151,9 @@ namespace scene
|
|||||||
//Retrieve animation information
|
//Retrieve animation information
|
||||||
void getFrameLoop(u32 animId, s32 &start, s32 &end);
|
void getFrameLoop(u32 animId, s32 &start, s32 &end);
|
||||||
void newAnimation(u32 id, s32 start, s32 end, f32 probability);
|
void newAnimation(u32 id, s32 start, s32 end, f32 probability);
|
||||||
|
//Retrieve geoset rendering information
|
||||||
|
void setGeoSetRender(u32 id, bool render);
|
||||||
|
bool getGeoSetRender(u32 meshbufferNumber);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void checkForAnimation();
|
void checkForAnimation();
|
||||||
@ -172,8 +180,10 @@ private:
|
|||||||
core::array<SSkinMeshBuffer*> *SkinningBuffers; //Meshbuffer to skin, default is to skin localBuffers
|
core::array<SSkinMeshBuffer*> *SkinningBuffers; //Meshbuffer to skin, default is to skin localBuffers
|
||||||
|
|
||||||
core::array<SSkinMeshBuffer*> LocalBuffers;
|
core::array<SSkinMeshBuffer*> LocalBuffers;
|
||||||
|
core::array<u32> GeoSetID; //Array of Submesh Meshpart IDs used for switching Geosets on and off
|
||||||
|
core::array<bool> GeoSetRender;
|
||||||
|
|
||||||
core::array<SJoint*> AllJoints;
|
core::array<SJoint*> AllJoints;
|
||||||
core::array<SJoint*> RootJoints;
|
core::array<SJoint*> RootJoints;
|
||||||
|
|
||||||
bool HasAnimation;
|
bool HasAnimation;
|
||||||
|
|||||||
@ -115,7 +115,7 @@ void CM2MeshFileLoader::ReadViewData(io::IReadFile* file)
|
|||||||
{
|
{
|
||||||
file->read(&tempM2Submesh,sizeof(ModelViewSubmesh)-(header.version==0x100?16:0));
|
file->read(&tempM2Submesh,sizeof(ModelViewSubmesh)-(header.version==0x100?16:0));
|
||||||
M2MSubmeshes.push_back(tempM2Submesh);
|
M2MSubmeshes.push_back(tempM2Submesh);
|
||||||
DEBUG(logdebug("Submesh %u nBone: %u ofsBone: %u",i,tempM2Submesh.nBone, tempM2Submesh.ofsBone));
|
DEBUG(logdebug("Submesh %u MeshPartID %u",i,tempM2Submesh.meshpartId));
|
||||||
// std::cout<< "Submesh " <<i<<" ID "<<tempM2Submesh.meshpartId<<" starts at V/T "<<tempM2Submesh.ofsVertex<<"/"<<tempM2Submesh.ofsTris<<" and has "<<tempM2Submesh.nVertex<<"/"<<tempM2Submesh.nTris<<" V/T\n";
|
// std::cout<< "Submesh " <<i<<" ID "<<tempM2Submesh.meshpartId<<" starts at V/T "<<tempM2Submesh.ofsVertex<<"/"<<tempM2Submesh.ofsTris<<" and has "<<tempM2Submesh.nVertex<<"/"<<tempM2Submesh.nTris<<" V/T\n";
|
||||||
}
|
}
|
||||||
DEBUG(logdebug("Read %u/%u Submeshes",M2MSubmeshes.size(),currentView.Submesh.num));
|
DEBUG(logdebug("Read %u/%u Submeshes",M2MSubmeshes.size(),currentView.Submesh.num));
|
||||||
@ -716,7 +716,7 @@ for(u32 i=0;i<M2MVertices.size();i++)
|
|||||||
for(u32 i=0; i < currentView.Submesh.num;i++)//
|
for(u32 i=0; i < currentView.Submesh.num;i++)//
|
||||||
{
|
{
|
||||||
//Now, M2MTriangles refers to M2MIndices and not to M2MVertices.
|
//Now, M2MTriangles refers to M2MIndices and not to M2MVertices.
|
||||||
scene::SSkinMeshBuffer *MeshBuffer = AnimatedMesh->createBuffer();
|
scene::SSkinMeshBuffer *MeshBuffer = AnimatedMesh->createBuffer(M2MSubmeshes[i].meshpartId);
|
||||||
|
|
||||||
//Put the Indices and Vertices of the Submesh into a mesh buffer
|
//Put the Indices and Vertices of the Submesh into a mesh buffer
|
||||||
//Each Submesh contains only the Indices and Vertices that belong to it.
|
//Each Submesh contains only the Indices and Vertices that belong to it.
|
||||||
|
|||||||
@ -330,10 +330,12 @@ void CAnimatedMeshSceneNode::render()
|
|||||||
{
|
{
|
||||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
||||||
bool transparent = (rnd && rnd->isTransparent());
|
bool transparent = (rnd && rnd->isTransparent());
|
||||||
|
bool renderSubmesh = true;
|
||||||
|
if(Mesh->getMeshType() == EAMT_M2)
|
||||||
|
renderSubmesh = ((CM2Mesh*)Mesh)->getGeoSetRender(i);
|
||||||
// only render transparent buffer if this is the transparent render pass
|
// only render transparent buffer if this is the transparent render pass
|
||||||
// and solid only in solid pass
|
// and solid only in solid pass
|
||||||
if (transparent == isTransparentPass)
|
if (transparent == isTransparentPass && renderSubmesh)
|
||||||
{
|
{
|
||||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user