Commit 81ff2ebb authored by hybrid's avatar hybrid

Provide meshbuffer level access to vertex elements which always exist.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1085 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e409667c
...@@ -105,6 +105,30 @@ namespace scene ...@@ -105,6 +105,30 @@ namespace scene
return T().getType(); return T().getType();
} }
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const
{
return Vertices[i].Pos;
}
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i)
{
return Vertices[i].Pos;
}
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const
{
return Vertices[i].Normal;
}
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i)
{
return Vertices[i].Normal;
}
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
......
...@@ -103,6 +103,18 @@ namespace scene ...@@ -103,6 +103,18 @@ namespace scene
//! recalculates the bounding box. should be called if the mesh changed. //! recalculates the bounding box. should be called if the mesh changed.
virtual void recalculateBoundingBox() = 0; virtual void recalculateBoundingBox() = 0;
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const = 0;
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i) = 0;
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const = 0;
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i) = 0;
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0; virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
......
...@@ -201,6 +201,62 @@ struct SSkinMeshBuffer : public IMeshBuffer ...@@ -201,6 +201,62 @@ struct SSkinMeshBuffer : public IMeshBuffer
} }
} }
//! returns position of vertex i
virtual const core::vector3df& getPosition(u32 i) const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Pos;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Pos;
default:
return Vertices_Standard[i].Pos;
}
}
//! returns position of vertex i
virtual core::vector3df& getPosition(u32 i)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Pos;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Pos;
default:
return Vertices_Standard[i].Pos;
}
}
//! returns normal of vertex i
virtual const core::vector3df& getNormal(u32 i) const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Normal;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Normal;
default:
return Vertices_Standard[i].Normal;
}
}
//! returns normal of vertex i
virtual core::vector3df& getNormal(u32 i)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Normal;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Normal;
default:
return Vertices_Standard[i].Normal;
}
}
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {} virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
......
...@@ -71,23 +71,11 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -71,23 +71,11 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
{ {
for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k ) for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k )
{ {
switch( frameMesh->getMeshBuffer(j)->getVertexType() ) p.pos = frameMesh->getMeshBuffer(j)->getPosition(k);
{ if( UseNormalDirection )
case video::EVT_STANDARD: p.vector = frameMesh->getMeshBuffer(j)->getNormal(k) / NormalDirectionModifier;
p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos; else
if( UseNormalDirection ) p.vector = Direction;
p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now; p.startTime = now;
...@@ -130,23 +118,11 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -130,23 +118,11 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
u32 vertexNumber = os::Randomizer::rand() % frameMesh->getMeshBuffer(randomMB)->getVertexCount(); u32 vertexNumber = os::Randomizer::rand() % frameMesh->getMeshBuffer(randomMB)->getVertexCount();
switch( frameMesh->getMeshBuffer(randomMB)->getVertexType() ) p.pos = frameMesh->getMeshBuffer(randomMB)->getPosition(vertexNumber);
{ if( UseNormalDirection )
case video::EVT_STANDARD: p.vector = frameMesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) / NormalDirectionModifier;
p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; else
if( UseNormalDirection ) p.vector = Direction;
p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now; p.startTime = now;
......
...@@ -65,23 +65,11 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -65,23 +65,11 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
{ {
for( u32 k=0; k<Mesh->getMeshBuffer(j)->getVertexCount(); ++k ) for( u32 k=0; k<Mesh->getMeshBuffer(j)->getVertexCount(); ++k )
{ {
switch( Mesh->getMeshBuffer(j)->getVertexType() ) p.pos = Mesh->getMeshBuffer(j)->getPosition(k);
{ if( UseNormalDirection )
case video::EVT_STANDARD: p.vector = Mesh->getMeshBuffer(j)->getNormal(k) / NormalDirectionModifier;
p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos; else
if( UseNormalDirection ) p.vector = Direction;
p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now; p.startTime = now;
...@@ -124,23 +112,11 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -124,23 +112,11 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
u32 vertexNumber = os::Randomizer::rand() % Mesh->getMeshBuffer(randomMB)->getVertexCount(); u32 vertexNumber = os::Randomizer::rand() % Mesh->getMeshBuffer(randomMB)->getVertexCount();
switch( Mesh->getMeshBuffer(randomMB)->getVertexType() ) p.pos = Mesh->getMeshBuffer(randomMB)->getPosition(vertexNumber);
{ if( UseNormalDirection )
case video::EVT_STANDARD: p.vector = Mesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) / NormalDirectionModifier;
p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; else
if( UseNormalDirection ) p.vector = Direction;
p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now; p.startTime = now;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment