Esempio n. 1
0
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;
            }
          }
        }
      }
    }
}
Esempio n. 2
0
//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;
}
Esempio n. 3
0
void CZombie::PosicionaManoIzquierda()
{
//  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_HuesoManoIzq = skeleton->getCoreSkeleton()->getCoreBoneId("Bip01 L Finger0");
  CalVector l_V3Position = (CalVector)skeleton->getBone(l_HuesoManoIzq)->getTranslationAbsolute();

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

  PosicionaTrigger(V3PosicionManoIzquierda, m_actManoIzquierda);
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
void CZombie::PosicionaManoDerecha()
{
//  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("Bip01 R Finger0");
  CalVector l_V3Position = (CalVector)skeleton->getBone(l_HuesoManoDer)->getTranslationAbsolute();

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

  PosicionaTrigger(V3PosicionManoDerecha, m_actManoDerecha);
  //CTriggerManager* tm = CORE->GetTriggerManager();
  //tm->GetTrigger("z_inst_200 ManoDerecha")->SetPosition(m_actManoDerecha->GetPosition());
}
Esempio n. 6
0
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();
}