本文整理汇总了C++中CalBone类的典型用法代码示例。如果您正苦于以下问题:C++ CalBone类的具体用法?C++ CalBone怎么用?C++ CalBone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CalBone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void IKCharacter::pullWorldPositions( int root_id, int leaf_id )
{
CalVector root_pos;
if ( auto_root_follow )
{
// get root pos
int skel_root_id = skeleton->getCoreSkeleton()->getVectorRootCoreBoneId()[0];
root_pos = skeleton->getBone(skel_root_id)->getTranslationAbsolute();
}
// work from the leaves down to the root
deque<int> queue;
if ( leaf_id == -1 )
queue.insert( queue.begin(), leaf_bones.begin(), leaf_bones.end() );
else
queue.push_back( leaf_id );
while ( !queue.empty() )
{
int id = queue.front();
queue.pop_front();
CalBone* bone = skeleton->getBone(id);
world_positions[id] = bone->getTranslationAbsolute() - root_pos;
int parent_id = bone->getCoreBone()->getParentId();
if ( parent_id != -1 && id != root_id )
queue.push_back( parent_id );
}
}
示例2: getRotationForParentBone
/// calculate a rotation to bring the current direction vector between parent and bone
/// to the given new direction vector (non-normalized)
ofxQuaternion IKCharacter::getRotationForParentBone( int bone_id, CalVector new_parent_to_bone_direction )
{
CalCoreSkeleton* core_skel = skeleton->getCoreSkeleton();
CalBone* bone = skeleton->getBone( bone_id );
int parent_id = core_skel->getCoreBone( bone_id )->getParentId();
CalBone* parent_bone = skeleton->getBone( parent_id );
int parent_parent_id = parent_bone->getCoreBone()->getParentId();
// don't rotate the base state
if ( parent_parent_id == -1 )
return ofxQuaternion();
// new_parent_to_bone_direction is currently in world-space
// we need to bring it into the space of the parent bone
CalQuaternion bone_space_rot = bone->getRotationBoneSpace();
bone_space_rot.invert();
new_parent_to_bone_direction *= bone_space_rot;
CalVector old_dir = bone->getTranslation();
CalVector new_dir = new_parent_to_bone_direction;
old_dir.normalize();
new_dir.normalize();
// rotate from one to the other
ofxQuaternion rot;
ofxVec3f od( old_dir.x, old_dir.y, old_dir.z );
ofxVec3f nd( new_dir.x, new_dir.y, new_dir.z );
rot.makeRotate( od, nd );
// return
return rot.inverse();
}
示例3: getBoneLinesStatic
int CalSkeleton::getBoneLinesStatic(float *pLines)
{
int nrLines;
nrLines = 0;
rde::vector<CalBone *>::iterator iteratorBone;
for(iteratorBone = m_vectorBone.begin(); iteratorBone != m_vectorBone.end(); ++iteratorBone)
{
int parentId;
parentId = (*iteratorBone)->getCoreBone()->getParentId();
if(parentId != -1)
{
CalBone *pParent;
pParent = m_vectorBone[parentId];
const CalVector& translation = (*iteratorBone)->getCoreBone()->getTranslationAbsolute();
const CalVector& translationParent = pParent->getCoreBone()->getTranslationAbsolute();
*pLines++ = translationParent[0];
*pLines++ = translationParent[1];
*pLines++ = translationParent[2];
*pLines++ = translation[0];
*pLines++ = translation[1];
*pLines++ = translation[2];
nrLines++;
}
}
return nrLines;
}
示例4:
void
CalMixer::applyBoneAdjustments()
{
CalSkeleton * pSkeleton = m_pModel->getSkeleton();
std::vector<CalBone *>& vectorBone = pSkeleton->getVectorBone();
unsigned int i;
for( i = 0; i < m_numBoneAdjustments; i++ ) {
CalMixerBoneAdjustmentAndBoneId * ba = & m_boneAdjustmentAndBoneIdArray[ i ];
CalBone * bo = vectorBone[ ba->boneId_ ];
CalCoreBone * cbo = bo->getCoreBone();
if( ba->boneAdjustment_.flags_ & CalMixerBoneAdjustmentFlagMeshScale ) {
bo->setMeshScaleAbsolute( ba->boneAdjustment_.meshScaleAbsolute_ );
}
if( ba->boneAdjustment_.flags_ & CalMixerBoneAdjustmentFlagPosRot ) {
const CalVector & localPos = cbo->getTranslation();
CalVector adjustedLocalPos = localPos;
CalQuaternion adjustedLocalOri = ba->boneAdjustment_.localOri_;
static float const scale = 1.0f;
float rampValue = ba->boneAdjustment_.rampValue_;
static bool const replace = true;
static float const unrampedWeight = 1.0f;
bo->blendState( unrampedWeight,
adjustedLocalPos,
adjustedLocalOri,
scale, replace, rampValue );
}
}
}
示例5:
const std::list<int>& BoneBridgeCAL3D::GetListChildBoneID() const
{
CalBone* calBone = (CalBone*)GetCalBone();
CalCoreBone* coreBone = calBone->getCoreBone();
std::list<int>& listChildID = coreBone->getListChildId();
return listChildID;
}
示例6: calculateState
void CalBone::calculateState()
{
// check if the bone was not touched by any active animation
if(m_accumulatedWeight == 0.0f)
{
// set the bone to the initial skeleton state
m_translation = m_pCoreBone->getTranslation();
m_rotation = m_pCoreBone->getRotation();
}
// get parent bone id
int parentId;
parentId = m_pCoreBone->getParentId();
if(parentId == -1)
{
// no parent, this means absolute state == relative state
m_translationAbsolute = m_translation;
m_rotationAbsolute = m_rotation;
}
else
{
// get the parent bone
CalBone *pParent;
pParent = m_pSkeleton->getBone(parentId);
// transform relative state with the absolute state of the parent
m_translationAbsolute = m_translation;
m_translationAbsolute *= pParent->getRotationAbsolute();
m_translationAbsolute += pParent->getTranslationAbsolute();
m_rotationAbsolute = m_rotation;
m_rotationAbsolute *= pParent->getRotationAbsolute();
}
// calculate the bone space transformation
m_translationBoneSpace = m_pCoreBone->getTranslationBoneSpace();
m_translationBoneSpace *= m_rotationAbsolute;
m_translationBoneSpace += m_translationAbsolute;
m_rotationBoneSpace = m_pCoreBone->getRotationBoneSpace();
m_rotationBoneSpace *= m_rotationAbsolute;
// Generate the vertex transform. If I ever add support for bone-scaling
// to Cal3D, this step will become significantly more complex.
m_transformMatrix = m_rotationBoneSpace;
// calculate all child bones
std::list<int>::iterator iteratorChildId;
for(iteratorChildId = m_pCoreBone->getListChildId().begin(); iteratorChildId != m_pCoreBone->getListChildId().end(); ++iteratorChildId)
{
m_pSkeleton->getBone(*iteratorChildId)->calculateState();
}
}
示例7: BoneGetTransBoneSpace
/////////////////////////////////////
// Purpose: get the translation
// to bring a point into the
// bone instance space
// of given boneID
// Output: pLoc set
// Return: none
/////////////////////////////////////
void IgfxObject::BoneGetTransBoneSpace(s32 boneID, Vec3D *pLoc)
{
if(m_pCalModel)
{
CalSkeleton *pSkel = m_pCalModel->getSkeleton();
CalBone *pBone = pSkel->getBone(boneID);
CalVector cVec = pBone->getTranslationBoneSpace();
pLoc->x = cVec.x;
pLoc->y = cVec.y;
pLoc->z = cVec.z;
}
}
示例8: 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;
}
}
示例9: BoneGetRotateBoneSpace
/////////////////////////////////////
// Purpose: get the rotation
// to bring a point into the
// bone instance space
// Output: pQ set
// Return: none
/////////////////////////////////////
void IgfxObject::BoneGetRotateBoneSpace(s32 boneID, Quaternion *pQ)
{
if(m_pCalModel)
{
CalSkeleton *pSkel = m_pCalModel->getSkeleton();
CalBone *pBone = pSkel->getBone(boneID);
CalQuaternion cQuat = pBone->getRotationBoneSpace();
pQ->x = cQuat.x;
pQ->y = cQuat.y;
pQ->z = cQuat.z;
pQ->w = cQuat.w;
}
}
示例10: CalBone
bool CalSkeleton::create(CalCoreSkeleton *pCoreSkeleton)
{
if(pCoreSkeleton == 0)
{
CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
return false;
}
m_pCoreSkeleton = pCoreSkeleton;
// clone the skeleton structure of the core skeleton
rde::vector<CalCoreBone *>& vectorCoreBone = pCoreSkeleton->getVectorCoreBone();
// get the number of bones
int boneCount;
boneCount = vectorCoreBone.size();
// reserve space in the bone vector
m_vectorBone.reserve(boneCount);
// clone every core bone
int boneId;
for(boneId = 0; boneId < boneCount; boneId++)
{
CalBone *pBone;
pBone = new CalBone();
if(pBone == 0)
{
CalError::setLastError(CalError::MEMORY_ALLOCATION_FAILED, __FILE__, __LINE__);
return false;
}
// create a bone for every core bone
if(!pBone->create(vectorCoreBone[boneId]))
{
delete pBone;
return false;
}
// set skeleton in the bone instance
pBone->setSkeleton(this);
// insert bone into bone vector
m_vectorBone.push_back(pBone);
}
return true;
}
示例11: BoneGetTrans
/////////////////////////////////////
// Purpose: set the relative translation
// of the given bone
// Output: bone moved
// Return: none
/////////////////////////////////////
void IgfxObject::BoneSetTrans(s32 boneID, const Vec3D & loc)
{
if(m_pCalModel)
{
Vec3D trans; BoneGetTrans(boneID, &trans);
CalSkeleton *pSkel = m_pCalModel->getSkeleton();
CalBone *pBone = pSkel->getBone(boneID);
if(pBone)
{
pBone->setTranslation(CalVector(trans.x+loc.x, trans.y+loc.y, trans.z+loc.z));
pBone->calculateState();
}
}
}
示例12: BoneGetRotate
/////////////////////////////////////
// Purpose: set the relative rotation
// of the given bone
// Output: bone rotated
// Return: none
/////////////////////////////////////
void IgfxObject::BoneSetRotate(s32 boneID, const Quaternion & q)
{
if(m_pCalModel)
{
Quaternion quat; BoneGetRotate(boneID, &quat);
quat *= q;
CalSkeleton *pSkel = m_pCalModel->getSkeleton();
CalBone *pBone = pSkel->getBone(boneID);
if(pBone)
{
pBone->setRotation(CalQuaternion(quat.x, quat.y, quat.z, quat.w));
pBone->calculateState();
}
}
}
示例13:
core::matrix4 CCal3DSceneNode::getBoneMatrix( s32 boneId ) const
{
if ( calModel == 0 ) return core::matrix4();
CalSkeleton* skeleton = calModel->getSkeleton();
CalBone* bone = skeleton->getBone(boneId);
CalQuaternion rot = bone->getRotationAbsolute();
CalVector pos = bone->getTranslationAbsolute();
// Note: Swap Y and Z to convert to Irrlicht coordinates
core::quaternion quat = core::quaternion( rot.x, rot.y, rot.z, rot.w );
core::vector3df v = core::vector3df( pos.x, pos.y, pos.z );
core::matrix4 mat = quat.getMatrix();
mat.setTranslation(v);
return mat;
}
示例14: while
void IKCharacter::pullWorldPositions( int root_id, int leaf_id )
{
deque<int> queue;
if ( leaf_id == -1 )
queue.insert( queue.begin(), leaf_bones.begin(), leaf_bones.end() );
else
queue.push_back( leaf_id );
// work backwards up the tree
while ( !queue.empty() )
{
int id = queue.front();
queue.pop_front();
CalBone* bone = skeleton->getBone(id);
world_positions[id] = bone->getTranslationAbsolute();
int parent_id = bone->getCoreBone()->getParentId();
if ( parent_id != -1 && id != root_id )
queue.push_back( parent_id );
}
}
示例15: calculateVerticesNormalsAndTexCoords
int CalPhysique::calculateVerticesNormalsAndTexCoords(CalSubmesh *pSubmesh, float *pVertexBuffer, int NumTexCoords) const
{
// get bone vector of the skeleton
std::vector<CalBone *>& vectorBone = m_pModel->getSkeleton()->getVectorBone();
// get vertex vector of the core submesh
std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pSubmesh->getCoreSubmesh()->getVectorVertex();
// get the texture coordinate vector vector
std::vector<std::vector<CalCoreSubmesh::TextureCoordinate> >& vectorvectorTextureCoordinate = pSubmesh->getCoreSubmesh()->getVectorVectorTextureCoordinate();
int TextureCoordinateCount=(int)vectorvectorTextureCoordinate.size();
// check if the map id is valid
if(((NumTexCoords < 0) || (NumTexCoords > TextureCoordinateCount)))
{
if(TextureCoordinateCount!=0)
{
CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
return -1;
}
}
// get physical property vector of the core submesh
std::vector<CalCoreSubmesh::PhysicalProperty>& vectorPhysicalProperty = pSubmesh->getCoreSubmesh()->getVectorPhysicalProperty();
// 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();
// 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;
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( currentWeight != 0 ) {
if( blendVertex ) {
position.x += currentWeight*blendVertex->position.x;
position.y += currentWeight*blendVertex->position.y;
position.z += currentWeight*blendVertex->position.z;
normal.x += currentWeight*blendVertex->normal.x;
normal.y += currentWeight*blendVertex->normal.y;
normal.z += currentWeight*blendVertex->normal.z;
}
}
}
}
// 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 == 0)
{
x = position.x;
y = position.y;
z = position.z;
nx = normal.x;
ny = normal.y;
nz = normal.z;
}
//.........这里部分代码省略.........