Add support for tangent meshes when converting to bullet
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10693 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5dda0e97a1
commit
18ead10df9
@ -154,7 +154,7 @@ void ThreeDAnimation::createPhysicsBody(const std::string &shape)
|
|||||||
if (mb->getVertexType() != video::EVT_STANDARD &&
|
if (mb->getVertexType() != video::EVT_STANDARD &&
|
||||||
mb->getVertexType() != video::EVT_2TCOORDS)
|
mb->getVertexType() != video::EVT_2TCOORDS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "WARNING: Physics::convertTrack: Ignoring type '%d'!\n",
|
fprintf(stderr, "WARNING: ThreeDAnimation::createPhysicsBody: Ignoring type '%d'!\n",
|
||||||
mb->getVertexType());
|
mb->getVertexType());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -515,9 +515,10 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
|||||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||||
// FIXME: take translation/rotation into account
|
// FIXME: take translation/rotation into account
|
||||||
if (mb->getVertexType() != video::EVT_STANDARD &&
|
if (mb->getVertexType() != video::EVT_STANDARD &&
|
||||||
mb->getVertexType() != video::EVT_2TCOORDS)
|
mb->getVertexType() != video::EVT_2TCOORDS &&
|
||||||
|
mb->getVertexType() != video::EVT_TANGENTS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "WARNING: Physics::convertTrack: Ignoring type '%d'!\n",
|
fprintf(stderr, "WARNING: Tracl::convertTrackToBullet: Ignoring type '%d'!\n",
|
||||||
mb->getVertexType());
|
mb->getVertexType());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -573,29 +574,45 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
|||||||
material );
|
material );
|
||||||
} // for j
|
} // for j
|
||||||
}
|
}
|
||||||
else
|
else if (mb->getVertexType() == video::EVT_2TCOORDS)
|
||||||
{
|
{
|
||||||
if (mb->getVertexType() == video::EVT_2TCOORDS)
|
irr::video::S3DVertex2TCoords* mbVertices = (video::S3DVertex2TCoords*)mb->getVertices();
|
||||||
|
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
||||||
{
|
{
|
||||||
irr::video::S3DVertex2TCoords* mbVertices = (video::S3DVertex2TCoords*)mb->getVertices();
|
for(unsigned int k=0; k<3; k++)
|
||||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
|
||||||
{
|
{
|
||||||
for(unsigned int k=0; k<3; k++)
|
int indx=mbIndices[j+k];
|
||||||
{
|
core::vector3df v = mbVertices[indx].Pos;
|
||||||
int indx=mbIndices[j+k];
|
mat.transformVect(v);
|
||||||
core::vector3df v = mbVertices[indx].Pos;
|
vertices[k]=v;
|
||||||
mat.transformVect(v);
|
normals[k]=mbVertices[indx].Normal;
|
||||||
vertices[k]=v;
|
} // for k
|
||||||
normals[k]=mbVertices[indx].Normal;
|
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
||||||
} // for k
|
vertices[2], normals[0],
|
||||||
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
normals[1], normals[2],
|
||||||
vertices[2], normals[0],
|
material );
|
||||||
normals[1], normals[2],
|
} // for j
|
||||||
material );
|
|
||||||
} // for j
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (mb->getVertexType() == video::EVT_TANGENTS)
|
||||||
|
{
|
||||||
|
irr::video::S3DVertexTangents* mbVertices = (video::S3DVertexTangents*)mb->getVertices();
|
||||||
|
for(unsigned int j=0; j<mb->getIndexCount(); j+=3)
|
||||||
|
{
|
||||||
|
for(unsigned int k=0; k<3; k++)
|
||||||
|
{
|
||||||
|
int indx=mbIndices[j+k];
|
||||||
|
core::vector3df v = mbVertices[indx].Pos;
|
||||||
|
mat.transformVect(v);
|
||||||
|
vertices[k]=v;
|
||||||
|
normals[k]=mbVertices[indx].Normal;
|
||||||
|
} // for k
|
||||||
|
if(tmesh) tmesh->addTriangle(vertices[0], vertices[1],
|
||||||
|
vertices[2], normals[0],
|
||||||
|
normals[1], normals[2],
|
||||||
|
material );
|
||||||
|
} // for j
|
||||||
|
}
|
||||||
|
|
||||||
} // for i<getMeshBufferCount
|
} // for i<getMeshBufferCount
|
||||||
|
|
||||||
} // convertTrackToBullet
|
} // convertTrackToBullet
|
||||||
|
Loading…
Reference in New Issue
Block a user