// **************************************************
//            OVERRIDDEN ENTITY FUNCTIONS
// **************************************************
void TransitionBarbarian_cl::InitFunction()
{
  if (!HasMesh())
    return;

  SetCastShadows(TRUE);
  
  // Setup all animation sequences
	SetupAnimations();
  if (!m_bModelValid)
    return;

  if( !m_pPhys)
  {
    m_pPhys = new vHavokCharacterController();
    m_pPhys->Initialize();

    hkvAlignedBBox bbox;
    VDynamicMesh *pMesh = GetMesh();
    pMesh->GetCollisionBoundingBox(bbox);

    float r = bbox.getSizeX() * 0.5f;
    m_pPhys->Capsule_Radius = r;
    m_pPhys->Character_Top.set(0,0,bbox.m_vMax.z - r);
    m_pPhys->Character_Bottom.set(0,0,bbox.m_vMin.z + r);

    m_pPhys->Max_Slope = 75.0f;
    AddComponent(m_pPhys);
    //	pPhys->SetDebugRendering(TRUE);
  }
 
  // Get Model
  VDynamicMesh* pModel = GetMesh();
	VASSERT(pModel);

  // Transition table to use
  VTransitionTable *pTable = VTransitionManager::GlobalManager().LoadTransitionTable(pModel,"Barbarian.vTransition");
  VASSERT(pTable && pTable->IsLoaded());

	// Setup the state machine component and pass the filename of the transition file
  // in which the transitions between the various animation states are defined.
	m_pStateMachine = new VTransitionStateMachine();
  m_pStateMachine->Init(this, pTable);
	AddComponent(m_pStateMachine);

	// Set initial state
	m_pStateMachine->SetState(m_pSkeletalSequenceList[ANIMID_IDLE]);
}
Пример #2
0
// **************************************************
//            OVERRIDDEN ENTITY FUNCTIONS
// **************************************************
void TransitionCharacter_cl::InitFunction()
{
  SetCastShadows(TRUE);
  
  // Setup all animation sequences
	SetupAnimations();
  if (!m_bModelValid)
    return;
	
	// Setup Physics object for offset delta
#ifdef USE_HAVOK

	vHavokCharacterController *pPhys = new vHavokCharacterController();
	pPhys->Initialize();

	hkvAlignedBBox bbox;
	GetMesh()->GetCollisionBoundingBox(bbox);

  float r = bbox.getSizeX() * 0.5f;
	pPhys->Capsule_Radius = r;
	pPhys->Character_Top.set(0,0,bbox.m_vMax.z - r);
  pPhys->Character_Bottom.set(0,0,bbox.m_vMin.z + r);

 	pPhys->Max_Slope = 75.0f;
	AddComponent(pPhys);
	//pPhys->SetDebugRendering(TRUE);

#endif //USE_HAVOK
	
  // Get Model
  VDynamicMesh* pMesh = GetMesh();
	VASSERT(pMesh);

  // Transition table to use
  VTransitionTable *pTable = VTransitionManager::GlobalManager().LoadTransitionTable(pMesh,"Models\\Warrior\\WarriorEvents.vTransition");
  VASSERT(pTable && pTable->IsLoaded());

	// Setup the state machine component and pass the filename of the transition file
  // in which the transitions between the various animation states are defined.
	m_pStateMachine = new VTransitionStateMachine();
  m_pStateMachine->SetTransitionTable(pTable);

	AddComponent(m_pStateMachine);

	// Set initial state
	m_pStateMachine->SetState(m_spSkeletalSequenceList[ANIMID_IDLE]);
}