void TransitionCharacter_cl::DoRotateRight()
{
  // rotate the entity and turn the head
  float fTimeDiff = Vision::GetTimer()->GetTimeDifference();
  float fRot = fTimeDiff * 180.f;
  IncOrientation( -fRot, 0, 0 );
}
void TransitionBarbarian_cl::DoRotateLeft()
{
  // rotate the entity and turn the head
  float fTimeDiff = Vision::GetTimer()->GetTimeDifference();
  float fRot = fTimeDiff * 180.f;
  IncOrientation( fRot, 0, 0 );
}
void SimpleSkeletalAnimatedObject_cl::InitFunction()
{
  ClearData();

  SetCastShadows(TRUE);

  m_iAnimEventFootStepLeft = Vision::Animations.RegisterEvent("footstep_left");
  m_iAnimEventFootStepRight = Vision::Animations.RegisterEvent("footstep_right");

  IncOrientation(90.0f, 0.0f, 0.0f);
}
Beispiel #4
0
//Called every frame to update the simulation
void MyEntity_cl::ThinkFunction()
{
  float fTime = Vision::GetTimer()->GetTimeDifference();  // find out how much time has passed since last time
  IncOrientation( hkvVec3 ( RotateSpeed * fTime,0,0) ); // update this entity's rotation
}
void VisMouseCamera_cl::TickFunction(float fTimeDiff)
{
  hkvVec3 vMove = hkvVec3::ZeroVector();
  BOOL bUpDownMode = FALSE;

  float dx = m_pInputMap->GetTrigger(API_CAMERA_HORIZONTAL_LOOK);
  float dy = m_pInputMap->GetTrigger(API_CAMERA_VERTICAL_LOOK);

  if (m_pInputMap->GetTrigger(API_CAMERA_ACTION_1) && m_pInputMap->GetTrigger(API_CAMERA_ACTION_2))
    bUpDownMode = TRUE;
  else if (m_pInputMap->GetTrigger(API_CAMERA_ACTION_2))
    m_SpeedMode = 1;
  else if (m_pInputMap->GetTrigger(API_CAMERA_ACTION_3))
    m_SpeedMode = 2;
  else
    m_SpeedMode = 0;

  // handle keyboard status
#if !defined(_VISION_MOBILE) && !defined(_VISION_WINRT)
  if (m_pInputMap->GetTrigger(API_CAMERA_ANY_ACTION))
#endif
  {
    hkvVec3 vDir(hkvNoInitialization), vRight(hkvNoInitialization), vUp(hkvNoInitialization);
    vUp.set(0.f,0.f,1.f);
    if (GetPhysicsObject())
    {
      // local space
      vDir.set(1.f,0.f,0.f);
      vRight.set(0.f,1.f,0.f);
    } 
    else
    {
      hkvMat3 mat(hkvNoInitialization);
      GetRotationMatrix(mat);
      vDir = mat.getAxis(0);
      vRight = mat.getAxis(1);
    }

    float fMaxSpeed = m_fMoveSpeed;
    if (m_SpeedMode == 1)
      fMaxSpeed *= 3.0f;
    else if (m_SpeedMode == 2)
      fMaxSpeed *= 9.0f;

    // Accumulate move directions (multiply in order to take analog input into account).
    vMove += vDir * m_pInputMap->GetTrigger(API_CAMERA_MOVE_FORWARD);
    vMove -= vDir * m_pInputMap->GetTrigger(API_CAMERA_MOVE_BACKWARD);
    vMove -= vRight * m_pInputMap->GetTrigger(API_CAMERA_MOVE_RIGHT);
    vMove += vRight * m_pInputMap->GetTrigger(API_CAMERA_MOVE_LEFT);
    vMove += vUp *  m_pInputMap->GetTrigger(API_CAMERA_MOVE_UP);
    vMove -= vUp * m_pInputMap->GetTrigger(API_CAMERA_MOVE_DOWN);
    vMove *= fMaxSpeed;
   
    // Clamp movement, so that moving diagonally is not faster than moving straight 
    // when using digital input.
    const float fSpeed = vMove.getLength();
    if (fSpeed > fMaxSpeed)
      vMove.setLength(fMaxSpeed);
    vMove *= fTimeDiff;
  }

  if (m_pInputMap->GetTrigger(API_CAMERA_LOOK_CHANGED))
  {
    if (bUpDownMode)
    {
      IncOrientation(-dx * m_fSensitivity, 0, 0);
      vMove.z -= dy * m_fUpDownSpeed;
    }
    else
    {
      IncOrientation(-dx * m_fSensitivity, dy * m_fSensitivity, 0);                   
    }
  }

  switch(m_walkMode)
  {
  case WALK:
    // constrain vMove to the ground
    float len = vMove.getLength();
    vMove.z = 0.f;
    vMove.setLength(len);
    break;
  }

  if (GetPhysicsObject())
  {
    IncMotionDeltaLocalSpace(vMove);
  }
  else
  {
    IncPosition( vMove );
  }
}
Beispiel #6
0
void RPG_Pickup::UpdateRotation(float const deltaTime)
{
  IncOrientation(hkvVec3 (m_rotateSpeed * deltaTime,0,0));
}