本文整理汇总了C++中CalBone::getTransformMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ CalBone::getTransformMatrix方法的具体用法?C++ CalBone::getTransformMatrix怎么用?C++ CalBone::getTransformMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CalBone
的用法示例。
在下文中一共展示了CalBone::getTransformMatrix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BoneGetTransformMtx
/////////////////////////////////////
// Purpose: get the given bone's
// bone space transformation
// Output: pMtx filled
// Return: none
/////////////////////////////////////
void IgfxObject::BoneGetTransformMtx(s32 boneID, Matrix *pMtx)
{
if(m_pCalModel)
{
CalSkeleton *pSkel = m_pCalModel->getSkeleton();
CalBone *pBone = pSkel->getBone(boneID);
CalMatrix cMtx = pBone->getTransformMatrix();
pMtx->_11 = cMtx.dxdx; pMtx->_21 = cMtx.dydx; pMtx->_31 = cMtx.dzdx; pMtx->_41 = 0;
pMtx->_12 = cMtx.dxdy; pMtx->_22 = cMtx.dydy; pMtx->_32 = cMtx.dzdy; pMtx->_42 = 0;
pMtx->_13 = cMtx.dxdz; pMtx->_23 = cMtx.dydz; pMtx->_33 = cMtx.dzdz; pMtx->_43 = 0;
pMtx->_14 = 0; pMtx->_24 = 0; pMtx->_34 = 0; pMtx->_44 = 1;
}
}
示例2: calculateVerticesNormalsAndTexCoords
//.........这里部分代码省略.........
z = 0.0f;
// initialize normal
float nx, ny, nz;
nx = 0.0f;
ny = 0.0f;
nz = 0.0f;
// blend together all vertex influences
int influenceId;
int influenceCount=(int)vertex.vectorInfluence.size();
if(influenceCount == 0)
{
x = position.x;
y = position.y;
z = position.z;
nx = normal.x;
ny = normal.y;
nz = normal.z;
}
else
{
for(influenceId = 0; influenceId < influenceCount; ++influenceId)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform vertex with current state of the bone
CalVector v(position);
v *= pBone->getTransformMatrix();
v += pBone->getTranslationBoneSpace();
x += influence.weight * v.x;
y += influence.weight * v.y;
z += influence.weight * v.z;
// transform normal with current state of the bone
CalVector n(normal);
n *= pBone->getTransformMatrix();
nx += influence.weight * n.x;
ny += influence.weight * n.y;
nz += influence.weight * n.z;
}
}
// save vertex position
if(hasSpringsAndInternalData)
{
// get the pgysical property of the vertex
CalCoreSubmesh::PhysicalProperty& physicalProperty = vectorPhysicalProperty[vertexId];
// assign new vertex position if there is no vertex weight
if(physicalProperty.weight == 0.0f)
{
pVertexBuffer[0] = x * m_axisFactorX;
pVertexBuffer[1] = y * m_axisFactorY;
pVertexBuffer[2] = z * m_axisFactorZ;
}
}
else
{
示例3: calculateVertices
//.........这里部分代码省略.........
}
// Check for spring case
bool hasSpringsAndInternalData =
(pSubmesh->getCoreSubmesh()->getSpringCount() > 0) &&
pSubmesh->hasInternalData();
// calculate all submesh vertices
int vertexId;
for(vertexId = 0; vertexId < vertexCount; ++vertexId)
{
// get the vertex
CalCoreSubmesh::Vertex& vertex = vectorVertex[vertexId];
// blend the morph targets
CalVector position=vertex.position;
{
int morphTargetId;
for(morphTargetId=0; morphTargetId < morphTargetCount;++morphTargetId)
{
CalCoreSubMorphTarget::BlendVertex const * blendVertex =
vectorSubMorphTarget[morphTargetId]->getBlendVertex(vertexId);
float morphScale = morphTargetScaleArray[ morphTargetId ];
if( blendVertex )
{
position.x += morphScale * blendVertex->position.x;
position.y += morphScale * blendVertex->position.y;
position.z += morphScale * blendVertex->position.z;
}
}
}
// initialize vertex
float x, y, z;
x = 0.0f;
y = 0.0f;
z = 0.0f;
// blend together all vertex influences
size_t influenceCount=vertex.vectorInfluence.size();
if(influenceCount == 0)
{
x = position.x;
y = position.y;
z = position.z;
}
else
{
for(size_t influenceId = 0; influenceId < influenceCount; ++influenceId)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform vertex with current state of the bone
CalVector v(position);
v *= pBone->getTransformMatrix();
v += pBone->getTranslationBoneSpace();
x += influence.weight * v.x;
y += influence.weight * v.y;
z += influence.weight * v.z;
}
}
// save vertex position
if(hasSpringsAndInternalData)
{
// get the physical property of the vertex
CalCoreSubmesh::PhysicalProperty& physicalProperty = vectorPhysicalProperty[vertexId];
// assign new vertex position if there is no vertex weight
if(physicalProperty.weight == 0.0f)
{
pVertexBuffer[0] = x * m_axisFactorX;
pVertexBuffer[1] = y * m_axisFactorY;
pVertexBuffer[2] = z * m_axisFactorZ;
}
}
else
{
pVertexBuffer[0] = x * m_axisFactorX;
pVertexBuffer[1] = y * m_axisFactorY;
pVertexBuffer[2] = z * m_axisFactorZ;
}
// next vertex position in buffer
pVertexBuffer = (float *)(((char *)pVertexBuffer) + stride) ;
}
return vertexCount;
}
示例4: calculateVerticesAndNormals
//.........这里部分代码省略.........
}
// initialize vertex
float x, y, z;
x = 0.0f;
y = 0.0f;
z = 0.0f;
// initialize normal
float nx, ny, nz;
nx = 0.0f;
ny = 0.0f;
nz = 0.0f;
// blend together all vertex influences
int influenceId;
int influenceCount=(int)vertex.vectorInfluence.size();
if(influenceCount > 1)
{
mustNormalize = true; // If multiple influences, normalize the normals!
}
for(influenceId = 0; influenceId < influenceCount; ++influenceId)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform vertex with current state of the bone
CalVector v(position);
v *= pBone->getTransformMatrix();
v += pBone->getTranslationBoneSpace();
x += influence.weight * v.x;
y += influence.weight * v.y;
z += influence.weight * v.z;
// transform normal with current state of the bone
CalVector n(normal);
n *= pBone->getTransformMatrix();
nx += influence.weight * n.x;
ny += influence.weight * n.y;
nz += influence.weight * n.z;
}
// save vertex position
if(hasSpringsAndInternalData)
{
mustNormalize = true;
// get the physical property of the vertex
CalCoreSubmesh::PhysicalProperty& physicalProperty = vectorPhysicalProperty[vertexId];
// assign new vertex position if there is no vertex weight
if(physicalProperty.weight == 0.0f)
{
pVertexBuffer[0] = x * m_axisFactorX;
pVertexBuffer[1] = y * m_axisFactorY;
pVertexBuffer[2] = z * m_axisFactorZ;
}
}
else
{
pVertexBuffer[0] = x * m_axisFactorX;
pVertexBuffer[1] = y * m_axisFactorY;
pVertexBuffer[2] = z * m_axisFactorZ;
}
// re-normalize normal if necessary
if (m_Normalize && mustNormalize)
{
nx/= m_axisFactorX;
ny/= m_axisFactorY;
nz/= m_axisFactorZ;
float scale;
scale = (float)( 1.0f / sqrt(nx * nx + ny * ny + nz * nz));
pVertexBuffer[3] = nx * scale;
pVertexBuffer[4] = ny * scale;
pVertexBuffer[5] = nz * scale;
}
else
{
pVertexBuffer[3] = nx;
pVertexBuffer[4] = ny;
pVertexBuffer[5] = nz;
}
// next vertex position in buffer
pVertexBuffer = (float *)(((char *)pVertexBuffer) + stride) ;
}
return vertexCount;
}
示例5: calculateNormals
int CalPhysique::calculateNormals(CalSubmesh *pSubmesh, float *pNormalBuffer, int stride) const
{
if(stride <= 0)
{
stride = 3*sizeof(float);
}
// get bone vector of the skeleton
std::vector<CalBone *>& vectorBone = m_pModel->getSkeleton()->getVectorBone();
// get vertex vector of the submesh
std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pSubmesh->getCoreSubmesh()->getVectorVertex();
// get the number of vertices
int vertexCount;
vertexCount = pSubmesh->getVertexCount();
// get the sub morph target vector from the core sub mesh
std::vector<CalCoreSubMorphTarget*>& vectorSubMorphTarget =
pSubmesh->getCoreSubmesh()->getVectorCoreSubMorphTarget();
// get the number of morph targets
int morphTargetCount = pSubmesh->getMorphTargetWeightCount();
// calculate normal for all submesh vertices
int vertexId;
for(vertexId = 0; vertexId < vertexCount; ++vertexId)
{
// get the vertex
CalCoreSubmesh::Vertex& vertex = vectorVertex[vertexId];
// blend the morph targets
CalVector normal=vertex.normal;
{
int morphTargetId;
for(morphTargetId=0; morphTargetId < morphTargetCount;++morphTargetId)
{
CalCoreSubMorphTarget::BlendVertex const * blendVertex =
vectorSubMorphTarget[morphTargetId]->getBlendVertex(vertexId);
float currentWeight = pSubmesh->getMorphTargetWeight(morphTargetId);
if( blendVertex ) {
normal.x += currentWeight*blendVertex->normal.x;
normal.y += currentWeight*blendVertex->normal.y;
normal.z += currentWeight*blendVertex->normal.z;
}
}
}
// initialize normal
float nx, ny, nz;
nx = 0.0f;
ny = 0.0f;
nz = 0.0f;
// blend together all vertex influences
int influenceId;
int influenceCount=(int)vertex.vectorInfluence.size();
if(influenceCount == 0)
{
nx = normal.x;
ny = normal.y;
nz = normal.z;
}
else
{
for(influenceId = 0; influenceId < influenceCount; ++influenceId)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform normal with current state of the bone
CalVector v(normal);
v *= pBone->getTransformMatrix();
nx += influence.weight * v.x;
ny += influence.weight * v.y;
nz += influence.weight * v.z;
}
}
// re-normalize normal if necessary
if (m_Normalize)
{
nx/= m_axisFactorX;
ny/= m_axisFactorY;
nz/= m_axisFactorZ;
float scale;
scale = (float)( 1.0f / sqrt(nx * nx + ny * ny + nz * nz));
pNormalBuffer[0] = nx * scale;
pNormalBuffer[1] = ny * scale;
pNormalBuffer[2] = nz * scale;
//.........这里部分代码省略.........
示例6: calculateTangentSpaces
int CalPhysique::calculateTangentSpaces(CalSubmesh *pSubmesh, int mapId, float *pTangentSpaceBuffer, int stride) const
{
if((mapId < 0) || (mapId >= (int)pSubmesh->getCoreSubmesh()->getVectorVectorTangentSpace().size())) return false;
if(stride <= 0)
{
stride = 4*sizeof(float);
}
// get bone vector of the skeleton
std::vector<CalBone *>& vectorBone = m_pModel->getSkeleton()->getVectorBone();
// get vertex vector of the submesh
std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pSubmesh->getCoreSubmesh()->getVectorVertex();
// get tangent space vector of the submesh
std::vector<CalCoreSubmesh::TangentSpace>& vectorTangentSpace = pSubmesh->getCoreSubmesh()->getVectorVectorTangentSpace()[mapId];
// get the number of vertices
int vertexCount;
vertexCount = pSubmesh->getVertexCount();
// calculate normal for all submesh vertices
int vertexId;
for(vertexId = 0; vertexId < vertexCount; vertexId++)
{
CalCoreSubmesh::TangentSpace& tangentSpace = vectorTangentSpace[vertexId];
// get the vertex
CalCoreSubmesh::Vertex& vertex = vectorVertex[vertexId];
// initialize tangent
float tx, ty, tz;
tx = 0.0f;
ty = 0.0f;
tz = 0.0f;
// blend together all vertex influences
int influenceId;
int influenceCount=(int)vertex.vectorInfluence.size();
for(influenceId = 0; influenceId < influenceCount; influenceId++)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform normal with current state of the bone
CalVector v(tangentSpace.tangent);
v *= pBone->getTransformMatrix();
tx += influence.weight * v.x;
ty += influence.weight * v.y;
tz += influence.weight * v.z;
}
// re-normalize tangent if necessary
if (m_Normalize)
{
float scale;
tx/= m_axisFactorX;
ty/= m_axisFactorY;
tz/= m_axisFactorZ;
scale = (float)( 1.0f / sqrt(tx * tx + ty * ty + tz * tz));
pTangentSpaceBuffer[0] = tx * scale;
pTangentSpaceBuffer[1] = ty * scale;
pTangentSpaceBuffer[2] = tz * scale;
}
else
{
pTangentSpaceBuffer[0] = tx;
pTangentSpaceBuffer[1] = ty;
pTangentSpaceBuffer[2] = tz;
}
pTangentSpaceBuffer[3] = tangentSpace.crossFactor;
// next vertex position in buffer
pTangentSpaceBuffer = (float *)(((char *)pTangentSpaceBuffer) + stride) ;
}
return vertexCount;
}
示例7: calculateVertex
CalVector CalPhysique::calculateVertex(CalSubmesh *pSubmesh, int vertexId)
{
// get bone vector of the skeleton
std::vector<CalBone *>& vectorBone = m_pModel->getSkeleton()->getVectorBone();
// get vertex of the core submesh
std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pSubmesh->getCoreSubmesh()->getVectorVertex();
// get physical property vector of the core submesh
//std::vector<CalCoreSubmesh::PhysicalProperty>& vectorPhysicalProperty = pSubmesh->getCoreSubmesh()->getVectorPhysicalProperty();
// get the sub morph target vector from the core sub mesh
std::vector<CalCoreSubMorphTarget*>& vectorSubMorphTarget =
pSubmesh->getCoreSubmesh()->getVectorCoreSubMorphTarget();
// get the number of morph targets
int morphTargetCount = pSubmesh->getMorphTargetWeightCount();
// get the vertex
CalCoreSubmesh::Vertex& vertex = vectorVertex[vertexId];
// blend the morph targets
CalVector position=vertex.position;
{
int morphTargetId;
for(morphTargetId=0; morphTargetId < morphTargetCount;++morphTargetId)
{
CalCoreSubMorphTarget::BlendVertex blendVertex;
vectorSubMorphTarget[morphTargetId]->getBlendVertex(vertexId, blendVertex);
float currentWeight = pSubmesh->getMorphTargetWeight(morphTargetId);
position.x += currentWeight*blendVertex.position.x;
position.y += currentWeight*blendVertex.position.y;
position.z += currentWeight*blendVertex.position.z;
}
}
// initialize vertex
float x, y, z;
x = 0.0f;
y = 0.0f;
z = 0.0f;
// blend together all vertex influences
int influenceId;
int influenceCount=(int)vertex.vectorInfluence.size();
if(influenceCount == 0)
{
x = position.x;
y = position.y;
z = position.z;
}
else
{
for(influenceId = 0; influenceId < influenceCount; ++influenceId)
{
// get the influence
CalCoreSubmesh::Influence& influence = vertex.vectorInfluence[influenceId];
// get the bone of the influence vertex
CalBone *pBone;
pBone = vectorBone[influence.boneId];
// transform vertex with current state of the bone
CalVector v(position);
v *= pBone->getTransformMatrix();
v += pBone->getTranslationBoneSpace();
x += influence.weight * v.x;
y += influence.weight * v.y;
z += influence.weight * v.z;
}
}
/*
// save vertex position
if(pSubmesh->getCoreSubmesh()->getSpringCount() > 0 && pSubmesh->hasInternalData())
{
// get the pgysical property of the vertex
CalCoreSubmesh::PhysicalProperty& physicalProperty = vectorPhysicalProperty[vertexId];
// assign new vertex position if there is no vertex weight
if(physicalProperty.weight == 0.0f)
{
pVertexBuffer[0] = x;
pVertexBuffer[1] = y;
pVertexBuffer[2] = z;
}
}
else
{
pVertexBuffer[0] = x;
pVertexBuffer[1] = y;
pVertexBuffer[2] = z;
}
*/
// return the vertex
//.........这里部分代码省略.........