当前位置: 首页>>代码示例>>C++>>正文


C++ CalSkeleton类代码示例

本文整理汇总了C++中CalSkeleton的典型用法代码示例。如果您正苦于以下问题:C++ CalSkeleton类的具体用法?C++ CalSkeleton怎么用?C++ CalSkeleton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CalSkeleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

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 );
    }
  }
}
开发者ID:bsmr-opengl,项目名称:cal3d,代码行数:28,代码来源:mixer.cpp

示例2: renderBoundingBox

void Model::renderBoundingBox()
{  

   CalSkeleton *pCalSkeleton = m_calModel->getSkeleton();

   std::vector<CalBone*> &vectorCoreBone = pCalSkeleton->getVectorBone();

   glColor3f(1.0f, 1.0f, 1.0f);
   glBegin(GL_LINES);      

   for(size_t boneId=0;boneId<vectorCoreBone.size();++boneId)
   {
      CalBoundingBox & calBoundingBox  = vectorCoreBone[boneId]->getBoundingBox();

      CalVector p[8];
      calBoundingBox.computePoints(p);

      
      glVertex3f(p[0].x,p[0].y,p[0].z);
      glVertex3f(p[1].x,p[1].y,p[1].z);

      glVertex3f(p[0].x,p[0].y,p[0].z);
      glVertex3f(p[2].x,p[2].y,p[2].z);

      glVertex3f(p[1].x,p[1].y,p[1].z);
      glVertex3f(p[3].x,p[3].y,p[3].z);

      glVertex3f(p[2].x,p[2].y,p[2].z);
      glVertex3f(p[3].x,p[3].y,p[3].z);

  	  glVertex3f(p[4].x,p[4].y,p[4].z);
      glVertex3f(p[5].x,p[5].y,p[5].z);

      glVertex3f(p[4].x,p[4].y,p[4].z);
      glVertex3f(p[6].x,p[6].y,p[6].z);

      glVertex3f(p[5].x,p[5].y,p[5].z);
      glVertex3f(p[7].x,p[7].y,p[7].z);

      glVertex3f(p[6].x,p[6].y,p[6].z);
      glVertex3f(p[7].x,p[7].y,p[7].z);

      glVertex3f(p[0].x,p[0].y,p[0].z);
      glVertex3f(p[4].x,p[4].y,p[4].z);

      glVertex3f(p[1].x,p[1].y,p[1].z);
      glVertex3f(p[5].x,p[5].y,p[5].z);

      glVertex3f(p[2].x,p[2].y,p[2].z);
      glVertex3f(p[6].x,p[6].y,p[6].z);

      glVertex3f(p[3].x,p[3].y,p[3].z);
      glVertex3f(p[7].x,p[7].y,p[7].z);  

   }

   glEnd();

}
开发者ID:bsmr-opengl,项目名称:cal3d,代码行数:59,代码来源:model.cpp

示例3: GetInstance

void CLanza::PosicionaPuntaLanza()
{
//  Mat44f worldmatrix = GetInstance()->GetMat44();
  std::string l_sName = GetInstance()->GetName();
  CRenderableAnimatedInstanceModel* model = (CRenderableAnimatedInstanceModel*)CORE->GetRenderableObjectsManager()->GetInstance(l_sName);
  CalSkeleton* skeleton = model->GetAnimatedInstanceModel()->GetModelCal3DHW()->getSkeleton();
 
  int l_HuesoManoDer = skeleton->getCoreSkeleton()->getCoreBoneId("hueso master");
  
  if(l_HuesoManoDer != -1)
  {
    CalVector l_V3Position = (CalVector)skeleton->getBone(l_HuesoManoDer)->getTranslationAbsolute();

    V3PosicionPuntaLanza.x = -l_V3Position.x;
    V3PosicionPuntaLanza.y = l_V3Position.y;
    V3PosicionPuntaLanza.z = l_V3Position.z;

      std::vector<CPhysicUserData*>	m_vImpactObjects;

    Mat44f l_t,res;
    Mat44f l_vMat44 = GetInstance()->GetMat44();

    l_t.SetIdentity();
    V3PosicionPuntaLanza.y += 1.3f;
    l_t.Translate(V3PosicionPuntaLanza);
    res.SetIdentity();
    res = l_vMat44*l_t;

    CORE->GetPhysicsManager()->OverlapSphereActor(
      0.7f
      ,res.GetPos()
      ,m_vImpactObjects
      ,PX_MSK_ALL
      ,true
    );
    if(!m_vImpactObjects.empty())
    {
      std::vector<CPhysicUserData*>::iterator l_iter = m_vImpactObjects.begin();
      for(;l_iter != m_vImpactObjects.end(); l_iter++)
      {
        if (!(*l_iter)->GetName().compare("mi_amigo"))
        { 
          //hit player
          if((res.GetPos().y > 0.2f) && (m_bActiva))  //empieza a salir la lanza
            if(CCoreFIH::GetSingletonPtr()->GetPlayer()->CollideEnemies())
            {
              CCoreFIH::GetSingletonPtr()->GetPlayer()->Hit(5);
              m_bActiva = false;
            }
          }
        }
      }
    }
}
开发者ID:BGCX261,项目名称:zombigame-svn-to-git,代码行数:54,代码来源:Lanza.cpp

示例4: 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;
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:21,代码来源:GFX_Object.cpp

示例5: GetInstance

//para calcular la posicion del humo en función del pie del zombie cuando muere
void CZombie::PosicionaPieDerecho()
{
  std::string l_sName = GetInstance()->GetName();
  CRenderableAnimatedInstanceModel* model = (CRenderableAnimatedInstanceModel*)CORE->GetRenderableObjectsManager()->GetInstance(l_sName);
  CalSkeleton* skeleton = model->GetAnimatedInstanceModel()->GetModelCal3DHW()->getSkeleton();
 
  int l_HuesoPieDer = skeleton->getCoreSkeleton()->getCoreBoneId("Bip01 R Foot");
  CalVector l_V3Position = (CalVector)skeleton->getBone(l_HuesoPieDer)->getTranslationAbsolute();

  V3PosicionPieDerecho.x = -l_V3Position.x;
  V3PosicionPieDerecho.y = l_V3Position.y;
  V3PosicionPieDerecho.z = l_V3Position.z;
}
开发者ID:BGCX261,项目名称:zombigame-svn-to-git,代码行数:14,代码来源:Zombie.cpp

示例6: 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;
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:20,代码来源:GFX_Object.cpp

示例7: 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;
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:21,代码来源:GFX_Object.cpp

示例8: 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();
        }
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:22,代码来源:GFX_Object.cpp

示例9: model_rotation

PosAndOrient Cal3dModel::getPositionForSubmodel(const std::string &bone) const {
  PosAndOrient po;
  po.orient.identity();
  po.pos = WFMath::Vector<3>(0, 0, 0);

  const std::string &mapped_bone = m_core_model->mapBoneName(bone);
  if (mapped_bone.empty()) return po;

  // Get a pointer to the bone we need from cal3d
  CalSkeleton * cs = m_calModel->getSkeleton();
  if (cs == 0) {
    return po;
  }
  CalCoreSkeleton * ccs = cs->getCoreSkeleton();
  if (ccs == 0) {
    return po;
  }
  int boneId = ccs->getCoreBoneId(mapped_bone);
  if (boneId == -1) {
    return po;
  }
  CalBone * cb1 = cs->getBone(boneId);
  if (cb1 == 0) {
    return po;
  }

  // Get the position and orientation of the bone in cal3d coordinates
  const CalQuaternion & cq = cb1->getRotationAbsolute();
  const CalVector & cv = cb1->getTranslationAbsolute();

  // Rotate the orienation into out coordinate system
  WFMath::Quaternion model_rotation(2, deg_to_rad(m_rotate));
  // The second rotation translates object coords to world coords
  // the first rotation makes the coord system compatible
  // The third rotation takes into account the model rotation to make it
  // face the right way. 
  po.orient = WFMath::Quaternion(1, WFMath::Pi / 2.0) * 
    m_core_model->getBoneRotation(bone) *
    WFMath::Quaternion(cq.w, cq.x, cq.y, cq.z).inverse() * 
    model_rotation;
    
  // Rotate the vector into our coordinate system
  po.pos = WFMath::Vector<3>(cv.x, cv.y, cv.z).rotate(model_rotation);
  return po;
}
开发者ID:bsmr-worldforge,项目名称:sear,代码行数:45,代码来源:Cal3dModel.cpp

示例10: GetAABB

/////////////////////////////////////
// Purpose:	get the object's axis
//			aligned bounding box
//			(model space)
// Output:	pMin and pMax set
// Return:	none
/////////////////////////////////////
void IgfxObject::GetAABB(Vec3D *pMin, Vec3D *pMax)
{
    if(m_pCalModel)
    {
        CalSkeleton *pSkel = m_pCalModel->getSkeleton();
        pSkel->getBoneBoundingBox((f32*)(*pMin), (f32*)(*pMax));
    }
    else
    {
        gfxMesh *pMesh = m_mdl->GetXMesh();

        if(pMesh)
        {
            *pMin = pMesh->mins;
            *pMax = pMesh->maxs;
        }
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:25,代码来源:GFX_Object.cpp

示例11: 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();
        }
    }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:24,代码来源:GFX_Object.cpp

示例12:

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;
}
开发者ID:F-22,项目名称:blender2cal3d,代码行数:19,代码来源:CCal3DSceneNode.cpp

示例13: Update

                void TextureModel::Update(){
                    CoreAnimation*	pAnimation	=	(CoreAnimation*)m_pObject;
                    if(pAnimation){
                        pAnimation->update(GetGlobalSetting().m_ShaderParam.m_fEngineTimeDelta*m_fAnimationSpeed);
                    
                        CalSkeleton*	pSkel			=	pAnimation->getSkeleton();
                        std::vector<CalBone*>&	lstBone	=	pSkel->getVectorBone();
                        UInt	uiBoneCount	=	lstBone.size();
                        static	Float44 g_TempBoneMatrix[256];
                        for(UInt i=0;i<uiBoneCount;i++){
                            const	CalQuaternion&	q	=	lstBone[i]->getRotationBoneSpace();
                            const	CalVector&		v	=	lstBone[i]->getTranslationBoneSpace();
     						Float44	m(Float4(q.w,q.x,q.y,q.z));
     						Float3*	pP	=	(Float3*)&v;
                            static Float3 vScale(1,1,1);
     						g_TempBoneMatrix[i]	=	Float44(*pP,vScale,Float4(q));//(m.transpose();
     						//g_TempBoneMatrix[i].(*pP);
// 							Float44	m(Float4(q.w,q.x,q.y,q.z));
// 								
// 							m[3][0]	=	v.x;
// 							m[3][1]	=	v.y;
// 							m[3][2]	=	v.z;
                    //		g_TempBoneMatrix[i]	=	m;//.transpose();
                        }
// 						Render::ITexture::LockRectOption	option;
// 						option.pData	=	NULL;
// 						option.pitch	=	1024*16;
// 						if(m_pTempBoneTexture->Lock(&option)){
// 							memcpy(option.pData,&g_TempBoneMatrix[0],sizeof(Float44)*uiBoneCount);
// 							m_pTempBoneTexture->UnLock();
// 							
// 	
// 						}
    
                        //UpdateAttachObject();
                    }
                }
开发者ID:ingeyu,项目名称:airengine,代码行数:37,代码来源:AirEngineCharacterTextureAnimationModel.cpp

示例14: GetAABBWorld

/////////////////////////////////////
// Purpose:	get the object's axis
//			aligned bounding box
//			(world space)
// Output:	pMin and pMax set
// Return:	none
/////////////////////////////////////
void IgfxObject::GetAABBWorld(Vec3D *pMin, Vec3D *pMax)
{
    Vec3D sMin, sMax;

    if(m_pCalModel)
    {
        CalSkeleton *pSkel = m_pCalModel->getSkeleton();
        pSkel->getBoneBoundingBox((f32*)(*pMin), (f32*)(*pMax));
    }
    else
    {
        gfxMesh *pMesh = m_mdl->GetXMesh();

        if(pMesh)
        {
            *pMin = pMesh->mins;
            *pMax = pMesh->maxs;
        }
    }

    //set to world
    _ComputeWrldMtx();

    Vec3DTransformCoord(pMin, &m_wrldMtx[FXMTX_NORMAL], &sMin);
    Vec3DTransformCoord(pMax, &m_wrldMtx[FXMTX_NORMAL], &sMax);

    //set the AABB again
    if(sMin.x < sMax.x) { pMin->x = sMin.x; pMax->x = sMax.x; }
    else { pMax->x = sMin.x; pMin->x = sMax.x; }

    if(sMin.y < sMax.y) { pMin->y = sMin.y; pMax->y = sMax.y; }
    else { pMax->y = sMin.y; pMin->y = sMax.y; }

    if(sMin.z < sMax.z) { pMin->z = sMin.z; pMax->z = sMax.z; }
    else { pMax->z = sMin.z; pMin->z = sMax.z; }
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:43,代码来源:GFX_Object.cpp

示例15: updateSkeleton

void CalMixer::updateSkeleton()
{
  // get the skeleton we need to update
  CalSkeleton *pSkeleton;
  pSkeleton = m_pModel->getSkeleton();
  if(pSkeleton == 0) return;

  // clear the skeleton state
  pSkeleton->clearState();

  // get the bone vector of the skeleton
  std::vector<CalBone *>& vectorBone = pSkeleton->getVectorBone();

  // loop through all animation actions
  std::list<CalAnimationAction *>::iterator iteratorAnimationAction;
  for(iteratorAnimationAction = m_listAnimationAction.begin(); iteratorAnimationAction != m_listAnimationAction.end(); ++iteratorAnimationAction)
  {
    // get the core animation instance
    CalCoreAnimation *pCoreAnimation;
    pCoreAnimation = (*iteratorAnimationAction)->getCoreAnimation();

    // Ask the animation for the pose at the given time
    std::vector<CalTransform> pose;
    pose.resize(pCoreAnimation->getTrackCount());
    pCoreAnimation->getPose((*iteratorAnimationAction)->getTime(), pose);

    // Blend the pose into the current bone states
    for (unsigned bone_id = 0; bone_id < pSkeleton->getCoreSkeleton()->getVectorCoreBone().size(); ++bone_id)
    {
      int track_number = pCoreAnimation->getTrackAssignment(bone_id);

      // Skip this bone if the bone does not have a track assigned in the animation
      if (track_number == -1)
      {
        continue;
      }

      // Blend the animation pose with the skeleton
      CalBone* pBone = vectorBone[bone_id];
      pBone->blendState((*iteratorAnimationAction)->getWeight(), pose[track_number].getTranslation(), pose[track_number].getRotation());
    }
  }

  // lock the skeleton state
  pSkeleton->lockState();

  // loop through all animation cycles
  std::list<CalAnimationCycle *>::iterator iteratorAnimationCycle;
  for(iteratorAnimationCycle = m_listAnimationCycle.begin(); iteratorAnimationCycle != m_listAnimationCycle.end(); ++iteratorAnimationCycle)
  {
    // get the core animation instance
    CalCoreAnimation *pCoreAnimation;
    pCoreAnimation = (*iteratorAnimationCycle)->getCoreAnimation();

    // calculate adjusted time
    float animationTime;
    if((*iteratorAnimationCycle)->getState() == CalAnimation::STATE_SYNC)
    {
      if(m_animationDuration == 0.0f)
      {
        animationTime = 0.0f;
      }
      else
      {
        animationTime = m_animationTime * pCoreAnimation->getDuration() / m_animationDuration;
      }
    }
    else
    {
      animationTime = (*iteratorAnimationCycle)->getTime();
    }

    // Ask the animation for the pose at the given time
    std::vector<CalTransform> pose;
    pose.resize(pCoreAnimation->getTrackCount());
    pCoreAnimation->getPose(animationTime, pose);

    // Blend the pose into the current bone states
    for (unsigned index = 0; index < pose.size(); ++index)
    {
      int track_number = pCoreAnimation->getTrackAssignment(index);

      // Skip this bone if the bone does not have a track assigned in the animation
      if (track_number == -1)
      {
        continue;
      }

      CalBone* pBone = vectorBone[index];
      pBone->blendState((*iteratorAnimationCycle)->getWeight(), pose[track_number].getTranslation(), pose[track_number].getRotation());
    }
  }

  // lock the skeleton state
  pSkeleton->lockState();

  // let the skeleton calculate its final state
  pSkeleton->calculateState();
}
开发者ID:ingeyu,项目名称:airengine,代码行数:99,代码来源:mixer.cpp


注:本文中的CalSkeleton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。