void AttachedTorch_cl::InitFunction() { SetVisibleBitmask( 0 ); SetCastShadows(FALSE); m_pShadowCaster = Vision::Game.CreateEntity("VisBaseEntity_cl", GetPosition(), "Data\\Vision\\Samples\\Engine\\Common\\Models\\Warrior\\TorchBottom.MODEL"); m_pShadowCaster->AttachToParent(this); m_pShadowCaster->SetVisibleBitmask( 0 ); m_pShadowCaster->SetCastShadows( FALSE ); hkvVec3 vScale(2.5f, 2.5f, 1.0f); m_pShadowCaster->SetScaling(vScale); }
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); }
void AttachedTorch_cl::Hide() { if (!m_bVisible) return; m_bVisible = false; SetVisibleBitmask( 0 ); SetCastShadows(FALSE); m_pShadowCaster->SetVisibleBitmask( 0 ); m_pShadowCaster->SetCastShadows(FALSE); V_SAFE_DISPOSEOBJECT(m_pLight); V_SAFE_DISPOSEOBJECT(m_spTorchParticles); }
// ************************************************** // 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]); }
// ************************************************** // 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]); }
void SimpleSkeletalAnimatedObject_cl::SetActivate(bool bStatus) { SetCastShadows(bStatus); SetVisibleBitmask(bStatus ? 0xffffffff : 0); if (m_pLookAtTarget != NULL) m_pLookAtTarget->SetVisibleBitmask(bStatus ? 0xffffffff : 0); if (bStatus) { SetMode(m_eSampleMode); } else { SetAnimConfig(NULL); } }
void AttachedTorch_cl::Show() { if (m_bVisible) return; m_bVisible = true; SetVisibleBitmask( 1 ); SetCastShadows(FALSE); m_pShadowCaster->SetVisibleBitmask( ENTITY_CAST_SHADOW ); m_pShadowCaster->SetCastShadows(TRUE); V_SAFE_DISPOSEOBJECT(m_pLight); if (m_spTorchParticles) { m_spTorchParticles->Dispose(); m_spTorchParticles = NULL; } m_pTorchFX = VisParticleGroupManager_cl::GlobalManager().LoadFromFile("Data\\Vision\\Samples\\Engine\\Common\\Models\\Warrior\\TorchFire.xml"); VASSERT(m_pTorchFX); m_pTorchFX->SetResourceFlag(VRESOURCEFLAG_AUTODELETE); m_pLight = new VisLightSource_cl(VIS_LIGHT_POINT, 800); VASSERT(m_pLight); m_pLight->SetMultiplier(1.5f); m_pLight->SetLightInfluenceBitMasks(0xFFFFFFFF, 0xFFFFFFFF); m_pLight->SetColor(VColorRef(255,180,105)); m_pLight->SetAttenuation(VIS_LIGHT_ATTEN_CUSTOM); #if defined(SUPPORTS_SHADOW_MAPS) && !defined(_VISION_MOBILE) && !defined( HK_ANARCHY ) VShadowMapComponentPoint* pShadowMapComponent = new VShadowMapComponentPoint(); pShadowMapComponent->SetShadowMapSize(256); pShadowMapComponent->SetShadowMappingMode(SHADOW_MAPPING_MODE_PCF8); m_pLight->AddComponent(pShadowMapComponent); #endif hkvVec3 vPdir(0.0f, -90.0f, 0.0f); m_spTorchParticles = m_pTorchFX->CreateParticleEffectInstance(GetPosition(), vPdir); }
void AnimatedWarrior_cl::InitFunction() { SetCastShadows(TRUE); SetupAnimations(); if (!m_bModelValid) return; m_pCharacterController = new vHavokCharacterController(); m_pCharacterController->Initialize(); hkvAlignedBBox bbox; GetMesh()->GetCollisionBoundingBox(bbox); float r = bbox.getSizeX() * 0.5f; m_pCharacterController->Capsule_Radius = r; m_pCharacterController->Character_Top.set(0,0,bbox.m_vMax.z - r); m_pCharacterController->Character_Bottom.set(0,0,bbox.m_vMin.z + r); m_pCharacterController->Max_Slope = 75.0f; if (!m_bEnabled) m_pCharacterController->SetEnabled(FALSE); AddComponent(m_pCharacterController); //// setup animation system // create config VDynamicMesh* pMesh = GetMesh(); VASSERT(pMesh); VisSkeleton_cl* pSkeleton = pMesh->GetSkeleton(); VASSERT(pSkeleton); // create mixer structure, we keep pointers on the mixers to add and remove inputs m_spLayerMixer = new VisAnimLayerMixerNode_cl(pSkeleton); m_pNormalizeMixer = new VisAnimNormalizeMixerNode_cl(pSkeleton); m_spLayerMixer->AddMixerInput(m_pNormalizeMixer, 1.f); //// create per bone weighting list for upper body int iBoneCount = pSkeleton->GetBoneCount(); float* fPerBoneWeightingList = new float[iBoneCount]; memset(fPerBoneWeightingList, 0, sizeof(float)*iBoneCount); // set all bone weights above the spine to 1 pSkeleton->SetBoneWeightRecursive(1.f, pSkeleton->GetBoneIndexByName("skeleton1:Spine"), fPerBoneWeightingList); int iMixerInputIndex = -1; for(int i=0; i<UPPERBODY_CONTROLCOUNT; i++) { m_spUpperBodyControls[i] = new VisSkeletalAnimControl_cl(pSkeleton, VSKELANIMCTRL_DEFAULTS); m_spUpperBodyControls[i]->AddEventListener(this); // we want to receive all events from sequence and control iMixerInputIndex = m_spLayerMixer->AddMixerInput(m_spUpperBodyControls[i], 0.f); m_spLayerMixer->ApplyPerBoneWeightingMask(iMixerInputIndex, iBoneCount, fPerBoneWeightingList); } V_SAFE_DELETE_ARRAY(fPerBoneWeightingList); // set the start animation BlendOverFullBodyAnimation(0.f, ANIMID_IDLE, 1.f, 0.f); SetFullBodyState(m_pFullBodyIdleState[FBSTATETYPE_NORMAL]); SetUpperBodyState(m_pUpperBodyIdleState); // initialize variables for upperbody fadein/fadeout m_eUpperBodyFadeState = FADESTATE_NONE; // setup neck bone for head rotation m_iHeadBoneIndex = pSkeleton->GetBoneIndexByName("skeleton1:Neck"); m_fHeadRotationAngles[0] = 0.f; m_fHeadRotationAngles[1] = 0.f; m_fHeadRotationAngles[2] = 0.f; m_bHeadInMovement = false; // setup the torch hkvVec3 vDummyOrigin; m_pTorch = (AttachedTorch_cl *) Vision::Game.CreateEntity( "AttachedTorch_cl", vDummyOrigin ); HideTorch(); // attach the torch to the bone //hkvVec3 localTranslation(-11.f, -4.5f, 25.f); hkvVec3 localTranslation(-11.f, 5.5f, 0.f); float euler[3] = {90, 0, 185}; hkvQuat localRotation; localRotation.setFromEulerAngles (euler[2], euler[1], euler[0]); // pass as roll, pitch, yaw m_pTorch->Attach(this, "skeleton1:RightHand", localRotation, localTranslation); SetEnabled(true); }
void SimpleVertexAnimatedObject_cl::InitFunction() { SetCastShadows(TRUE); SetSingleAnimationMode(); }