//----------------------------------------------------------------------------- // Name: CBipedAnimInstance::GetAnimIndex() // Desc: Returns the index of an animation set within this animation instance's // animation controller given an animation set name. //----------------------------------------------------------------------------- DWORD CXFileAnimInstance::GetAnimIndex( char sString[] ) { HRESULT hr; LPD3DXANIMATIONCONTROLLER pAC; LPD3DXANIMATIONSET pAS; DWORD dwRet = ANIMINDEX_FAIL; m_pAI->GetAnimController( & pAC ); for( DWORD i = 0; i < pAC->GetNumAnimationSets(); ++ i ) { hr = pAC->GetAnimationSet( i, & pAS ); if( FAILED( hr ) ) continue; if( pAS->GetName() && !strncmp( pAS->GetName(), sString, min( strlen( pAS->GetName() ), strlen( sString ) ) ) ) { dwRet = i; pAS->Release(); break; } pAS->Release(); } pAC->Release(); return dwRet; }
void CXModel::SetAnimation(unsigned int index) { if(index >= m_numAnimations || index == m_currentAni) return; m_currentAni = index; LPD3DXANIMATIONSET set; m_animControl->GetAnimationSet(m_currentAni, &set); unsigned long nextTrack = (m_currentTrack == 0 ? 1 : 0); // Set next track. m_animControl->SetTrackAnimationSet(nextTrack, set); set->Release(); // Take way all tracks. m_animControl->UnkeyAllTrackEvents(m_currentTrack); m_animControl->UnkeyAllTrackEvents(nextTrack); // Key current track. m_animControl->KeyTrackEnable(m_currentTrack, FALSE, m_currentTime + m_transition); m_animControl->KeyTrackSpeed(m_currentTrack, 0.0f, m_currentTime, m_transition, D3DXTRANSITION_LINEAR); m_animControl->KeyTrackWeight(m_currentTrack, 0.0f, m_currentTime, m_transition, D3DXTRANSITION_LINEAR); // Key next track. m_animControl->SetTrackEnable(nextTrack, TRUE); m_animControl->KeyTrackSpeed(nextTrack, 1.0f, m_currentTime, m_transition, D3DXTRANSITION_LINEAR); m_animControl->KeyTrackWeight(nextTrack, 1.0f, m_currentTime, m_transition, D3DXTRANSITION_LINEAR); m_currentTrack = nextTrack; }
//----------------------------------------------------------------------------- // Name: CTiny::SetIdleKey() // Desc: Initialize a new track in the animation controller for the idle // (loiter ) animation, and set up the smooth transition from the // movement animation (current track) to it (new track). // // bResetPosition controls whether we start the Loiter animation from // its beginning or current position. //----------------------------------------------------------------------------- void CTiny::SetIdleKey( bool bResetPosition ) { DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 ); LPD3DXANIMATIONCONTROLLER pAC; LPD3DXANIMATIONSET pAS; m_pAI->GetAnimController( &pAC ); pAC->GetAnimationSet( m_dwAnimIdxLoiter, &pAS ); pAC->SetTrackAnimationSet( dwNewTrack, pAS ); pAS->Release(); pAC->UnkeyAllTrackEvents( m_dwCurrentTrack ); pAC->UnkeyAllTrackEvents( dwNewTrack ); pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + IDLE_TRANSITION_TIME ); pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->SetTrackEnable( dwNewTrack, TRUE ); pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); if( bResetPosition ) pAC->SetTrackPosition( dwNewTrack, 0.0 ); m_dwCurrentTrack = dwNewTrack; pAC->Release(); }
//----------------------------------------------------------------------------- // Name: CTiny::SetMoveKey() // Desc: Initialize a new track in the animation controller for the movement // animation (run or walk), and set up the smooth transition from the idle // animation (current track) to it (new track). //----------------------------------------------------------------------------- void CTiny::SetMoveKey() { DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 ); LPD3DXANIMATIONCONTROLLER pAC; LPD3DXANIMATIONSET pAS; m_pAI->GetAnimController( &pAC ); if( m_fSpeed == m_fSpeedWalk ) pAC->GetAnimationSet( m_dwAnimIdxWalk, &pAS ); else pAC->GetAnimationSet( m_dwAnimIdxJog, &pAS ); pAC->SetTrackAnimationSet( dwNewTrack, pAS ); pAS->Release(); pAC->UnkeyAllTrackEvents( m_dwCurrentTrack ); pAC->UnkeyAllTrackEvents( dwNewTrack ); pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + MOVE_TRANSITION_TIME ); pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->SetTrackEnable( dwNewTrack, TRUE ); pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR ); m_dwCurrentTrack = dwNewTrack; pAC->Release(); }
/** * @brief * 引数に渡された名前と一致する * アニメーションセットのインデックスを返す * */ UINT AnimationManager::getAnimationSetIndex(const std::string& animationSetName) { LPD3DXANIMATIONSET pAnimationSet = 0; for (UINT i = 0; i < m_pAnimationController->GetNumAnimationSets(); ++i) { V_THROW(m_pAnimationController->GetAnimationSet(i, &pAnimationSet)); if (animationSetName == std::string(pAnimationSet->GetName())) { pAnimationSet->Release(); return i; } pAnimationSet->Release(); } return 0xffffff; }
/** * \brief Change to a different animation set * Handles transitions between animations to make it smooth and not a sudden jerk to a new position * \param index - new animation set index * \author Keith Ditchburn \date 18 July 2005 */ void CXFileEntity::SetAnimationSet(unsigned int index) { if (index==m_currentAnimationSet) return; if (index>=m_numAnimationSets) index=0; // Remember current animation m_currentAnimationSet=index; // Get the animation set from the controller LPD3DXANIMATIONSET set; m_animController->GetAnimationSet(m_currentAnimationSet, &set ); // Note: for a smooth transition between animation sets we can use two tracks and assign the new set to the track // not currently playing then insert Keys into the KeyTrack to do the transition between the tracks // tracks can be mixed together so we can gradually change into the new animation // Alternate tracks DWORD newTrack = ( m_currentTrack == 0 ? 1 : 0 ); // Assign to our track m_animController->SetTrackAnimationSet( newTrack, set ); set->Release(); // Clear any track events currently assigned to our two tracks m_animController->UnkeyAllTrackEvents( m_currentTrack ); m_animController->UnkeyAllTrackEvents( newTrack ); // Add an event key to disable the currently playing track kMoveTransitionTime seconds in the future m_animController->KeyTrackEnable( m_currentTrack, FALSE, m_currentTime + kMoveTransitionTime ); // Add an event key to change the speed right away so the animation completes in kMoveTransitionTime seconds m_animController->KeyTrackSpeed( m_currentTrack, 0.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR ); // Add an event to change the weighting of the current track (the effect it has blended with the secon track) m_animController->KeyTrackWeight( m_currentTrack, 0.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR ); // Enable the new track m_animController->SetTrackEnable( newTrack, TRUE ); // Add an event key to set the speed of the track m_animController->KeyTrackSpeed( newTrack, 1.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR ); // Add an event to change the weighting of the current track (the effect it has blended with the first track) // As you can see this will go from 0 effect to total effect(1.0f) in kMoveTransitionTime seconds and the first track goes from // total to 0.0f in the same time. m_animController->KeyTrackWeight( newTrack, 1.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR ); // Remember current track m_currentTrack = newTrack; }
DWORD CAnimationInstance::GetAnimationIndex(const char * szAnimationName) { HRESULT hr; LPD3DXANIMATIONSET pAnimSet; DWORD dwReturnIndex = ANIM_INDEX_FAIL; for( DWORD i = 0; i < m_pAnimationController->GetNumAnimationSets(); ++i) { hr = m_pAnimationController->GetAnimationSet( i, &pAnimSet); if( FAILED( hr)) continue; if( pAnimSet->GetName() && !strncmp( pAnimSet->GetName(), szAnimationName, min( strlen( pAnimSet->GetName() ), strlen( szAnimationName)))) { dwReturnIndex = i; pAnimSet->Release(); break; } pAnimSet->Release(); } return dwReturnIndex; }
double CXFileEntity::GetAnimationSetLength(unsigned int index) { if (index>=m_numAnimationSets) return 0; // Get the animation set LPD3DXANIMATIONSET set; m_animController->GetAnimationSet(m_currentAnimationSet, &set ); double pr = set->GetPeriod(); set->Release(); return pr; }
/** * \brief Get the name of the animation * Note: altered 24/09/07 to solve a D3DX memory leak caused because I was not releasing the set after getting it * \param index - the animation set index * \return the name * \author Keith Ditchburn \date 18 July 2005 */ std::string CXFileEntity::GetAnimationSetName(unsigned int index) { if (index>=m_numAnimationSets) return "Error: No set exists"; // Get the animation set LPD3DXANIMATIONSET set; m_animController->GetAnimationSet(m_currentAnimationSet, &set ); std::string nameString(set->GetName()); set->Release(); return nameString; }
void CAnimationInstance::SetAnimationRun(void) { DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0); LPD3DXANIMATIONSET pAnimSet; m_pAnimationController->GetAnimationSet( m_dwAnimIndexJog, &pAnimSet); m_pAnimationController->SetTrackAnimationSet( dwNewTrack, pAnimSet); pAnimSet->Release(); m_pAnimationController->UnkeyAllTrackEvents( m_dwCurrentTrack); m_pAnimationController->UnkeyAllTrackEvents( dwNewTrack); m_pAnimationController->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + MOVE_TRANSITION_TIME); m_pAnimationController->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR); m_pAnimationController->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR); m_pAnimationController->SetTrackEnable( dwNewTrack, TRUE); m_pAnimationController->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR); m_pAnimationController->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR); m_dwCurrentTrack = dwNewTrack; }
void stSANXFRAMEELEMENT::SetAnimation(unsigned int index,float Time,float Duration) { if((index>=this->NumAnimations)||(index==this->CurrentAnimation)) { return; } this->CurrentAnimation=index; LPD3DXANIMATIONSET AnimationSet; this->AnimationControler->GetAnimationSet(this->CurrentAnimation,&AnimationSet); unsigned long NextTrack=(this->CurrentAnimation==0?1:0); this->AnimationControler->SetTrackAnimationSet(NextTrack,AnimationSet); AnimationSet->Release(); this->AnimationControler->UnkeyAllTrackEvents(this->CurrentTrack); this->AnimationControler->UnkeyAllTrackEvents(NextTrack); this->AnimationControler->KeyTrackEnable(this->CurrentTrack,FALSE,Time+Duration); this->AnimationControler->KeyTrackSpeed(this->CurrentTrack,0.0,Time,Duration,D3DXTRANSITION_LINEAR); this->AnimationControler->KeyTrackWeight(this->CurrentTrack,0.0,Time,Duration,D3DXTRANSITION_LINEAR); this->AnimationControler->SetTrackEnable(NextTrack,TRUE); this->AnimationControler->KeyTrackSpeed(NextTrack,0.0,Time,Duration,D3DXTRANSITION_LINEAR); this->AnimationControler->KeyTrackWeight(NextTrack,0.0,Time,Duration,D3DXTRANSITION_LINEAR); this->CurrentTrack=NextTrack; }
void SkinnedComponent::ChangeAnim(int animNum) { if( CurrentAnim == animNum ) return; CurrentAnim = animNum; CurrentTime = 0; LPD3DXANIMATIONSET animSet = NULL; this->mAnimCtrl->SetTrackSpeed(0, 1.0f); this->mAnimCtrl->GetAnimationSet(animNum, &animSet); this->mAnimCtrl->SetTrackAnimationSet(0, animSet); this->mAnimCtrl->SetTrackPosition(0,CurrentTime); CurrentPeriod = (float)animSet->GetPeriod(); NumFrames = ((ID3DXKeyframedAnimationSet*)animSet)->GetNumTranslationKeys(0); NumFrames = max(NumFrames, (int)((ID3DXKeyframedAnimationSet*)animSet)->GetNumTranslationKeys(0)); NumFrames = max(NumFrames, (int)((ID3DXKeyframedAnimationSet*)animSet)->GetNumRotationKeys(0)); animSet->Release(); //RecalculateBB(); }
void XEnitity::SetAnimationSet(unsigned int index) { //m_pAnimCtrl->ResetTime(); const float MoveTransitionTime=0.25f; while (index>=m_NumAnimationSets) index-=m_NumAnimationSets; if (index==m_CurrentAnimationSet) return; m_CurrentAnimationSet=index; DWORD NewTrack = (m_CurrentTrack == 0 ? 1 : 0); LPD3DXANIMATIONSET set; m_pAnimCtrl->GetAnimationSet(m_CurrentAnimationSet, &set ); m_pAnimCtrl->SetTrackAnimationSet( NewTrack, set ); set->Release(); m_pAnimCtrl->UnkeyAllTrackEvents(m_CurrentTrack); m_pAnimCtrl->UnkeyAllTrackEvents(NewTrack); m_pAnimCtrl->KeyTrackEnable(m_CurrentTrack, FALSE, m_CurrentTime + MoveTransitionTime); m_pAnimCtrl->KeyTrackSpeed(m_CurrentTrack, 0.0f, m_CurrentTime, MoveTransitionTime, D3DXTRANSITION_LINEAR); m_pAnimCtrl->KeyTrackWeight(m_CurrentTrack, 0.0f, m_CurrentTime, MoveTransitionTime, D3DXTRANSITION_LINEAR); m_pAnimCtrl->SetTrackEnable(NewTrack, TRUE); m_pAnimCtrl->KeyTrackSpeed(NewTrack, 1.f, m_CurrentTime, MoveTransitionTime, D3DXTRANSITION_LINEAR); m_pAnimCtrl->KeyTrackWeight(NewTrack, 1.f, m_CurrentTime, MoveTransitionTime, D3DXTRANSITION_LINEAR); m_CurrentTrack = NewTrack; MessageBeep(MB_OK); return; }
//----------------------------------------------------------------------------- // Name: CBipedAnimInstance::PlayAnimation() // Desc: Initialize a new track in the animation controller for the movement // animation (run or walk), and set up the smooth transition from the idle // animation (current track) to it (new track). // Params: bContinue: If it's true,load new animation track only if sAnimName is // different from the track that is being played // note: m_szASNameTarget can be numbers, which is translated as index into the // model file's animation sets. //----------------------------------------------------------------------------- void CXFileAnimInstance::PlayAnimation(bool bContinue) { // -- return if no new animation is specified if(bContinue && strcmp(m_szASNameTarget, m_szASName) == 0) return; strcpy(m_szASName, m_szASNameTarget); // -- create new track DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 ); LPD3DXANIMATIONCONTROLLER pAC; LPD3DXANIMATIONSET pAS; m_pAI->GetAnimController( & pAC ); // TODO: use hash tablle to get the animation set // -- Get the animation set HRESULT hr; double dTransitionPeriod = MOVE_TRANSITION_TIME; if(strcmp(m_szASName, "Walk") == 0) { hr = pAC->GetAnimationSet( m_dwAnimIdxWalk, & pAS ); dTransitionPeriod = MOVE_TRANSITION_TIME; } else if(strcmp(m_szASName, "Jog") == 0) { hr = pAC->GetAnimationSet( m_dwAnimIdxJog, & pAS ); dTransitionPeriod = MOVE_TRANSITION_TIME; } else if( ('0'<= m_szASName[0]) && (m_szASName[0]<='9') ) {// if it's a number from 0~99 UINT nIndex = 0; if(('0'<= m_szASName[1]) && (m_szASName[1]<='9')) nIndex = (m_szASName[0] - '0')*10+m_szASName[1]-'0'; else nIndex = (m_szASName[0] - '0'); // use the name as the index of the animation set. hr = pAC->GetAnimationSet( nIndex, & pAS ); dTransitionPeriod = MOVE_TRANSITION_TIME; } else //if(strcmp(m_szASName, "Loiter")) { hr = pAC->GetAnimationSet( m_dwAnimIdxLoiter, & pAS ); dTransitionPeriod = IDLE_TRANSITION_TIME; } if( ! SUCCEEDED(hr) ) // failed to load { // TODO: Load default animation hr = pAC->GetAnimationSet( m_dwAnimIdxLoiter, & pAS ); dTransitionPeriod = IDLE_TRANSITION_TIME; if( ! SUCCEEDED(hr) )// failed to load the default return; } // -- Enable new track and set transition weight pAC->SetTrackAnimationSet( dwNewTrack, pAS ); pAS->Release(); pAC->UnkeyAllTrackEvents( m_dwCurrentTrack ); pAC->UnkeyAllTrackEvents( dwNewTrack ); pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + dTransitionPeriod ); pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR ); pAC->SetTrackEnable( dwNewTrack, TRUE ); pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR ); pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR ); if(!bContinue) // restart pAC->SetTrackPosition( dwNewTrack, 0.0 ); m_dwCurrentTrack = dwNewTrack; pAC->Release(); }
//----------------------------------------------------------------------------- // Name: CTiny::Report() // Desc: Add to the vector of strings, v_sReport, with useful information // about this instance of CTiny. //----------------------------------------------------------------------------- void CTiny::Report( vector <String>& v_sReport ) { WCHAR s[ 256 ]; try { swprintf_s( s, 256, L"Pos: %f, %f", m_vPos.x, m_vPos.z ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L"Facing: %f", m_fFacing ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L"Local time: %f", m_dTimeCurrent ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L"Pos Target: %f, %f", m_vPosTarget.x, m_vPosTarget.z ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L"Facing Target: %f", m_fFacingTarget ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L"Status: %s", m_bIdle ? L"Idle" : ( m_bWaiting ? L"Waiting" : L"Moving" ) ); v_sReport.push_back( String( s ) ); // report track data LPD3DXANIMATIONCONTROLLER pAC; LPD3DXANIMATIONSET pAS; D3DXTRACK_DESC td; m_pAI->GetAnimController( &pAC ); pAC->GetTrackAnimationSet( 0, &pAS ); WCHAR wstr[256]; MultiByteToWideChar( CP_ACP, 0, pAS->GetName(), -1, wstr, 256 ); swprintf_s( s, 256, L"Track 0: %s%s", wstr, m_dwCurrentTrack == 0 ? L" (current)" : L"" ); v_sReport.push_back( String( s ) ); pAS->Release(); pAC->GetTrackDesc( 0, &td ); swprintf_s( s, 256, L" Weight: %f", td.Weight ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Speed: %f", td.Speed ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Position: %f", td.Position ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Enable: %s", td.Enable ? L"true" : L"false" ); v_sReport.push_back( String( s ) ); pAC->GetTrackAnimationSet( 1, &pAS ); if( pAS ) { MultiByteToWideChar( CP_ACP, 0, pAS->GetName(), -1, wstr, 256 ); pAS->Release(); } else { swprintf_s( wstr, 256, L"n/a" ); } swprintf_s( s, 256, L"Track 1: %s%s", wstr, m_dwCurrentTrack == 1 ? L" (current)" : L"" ); v_sReport.push_back( String( s ) ); pAC->GetTrackDesc( 1, &td ); swprintf_s( s, 256, L" Weight: %f", td.Weight ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Speed: %f", td.Speed ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Position: %f", td.Position ); v_sReport.push_back( String( s ) ); swprintf_s( s, 256, L" Enable: %s", td.Enable ? L"true" : L"false" ); v_sReport.push_back( String( s ) ); if( m_bUserControl ) { swprintf_s( s, 256, L"Control: USER" ); v_sReport.push_back( String( s ) ); } else { swprintf_s( s, 256, L"Control: AUTO" ); v_sReport.push_back( String( s ) ); } pAC->Release(); } catch( ... ) { } }
GraphicsComponent * GraphicsEngine::CreateComponent(GraphicObjects object) { GraphicsComponent *comp = NULL; switch(object) { case FOSSA: { /*BlockGraphicComponent *fossa = new BlockGraphicComponent(); comp = fossa; fossa->model = modelMap["fossa"]; fossa->shader = effectMap["HackMapping"]; fossa->scale = D3DXVECTOR3(.2,.2,.2); fossa->position = D3DXVECTOR3(0,20,0); fossa->rotation = D3DXVECTOR3(0,0,0); fossa->Normal = textureMap["default"];*/ //fossa->m_vec4Color = D3DXVECTOR4(1.0f, 0.0f, 0.0f, 1.0f); SkinnedComponent *fossa = new SkinnedComponent(); comp = fossa; fossa->model = skinnedMeshMap["animations"]; fossa->shader = effectMap["SkinnedMesh"]; fossa->scale = D3DXVECTOR3(.25,.25,.25); fossa->position = D3DXVECTOR3(10,10,10); fossa->rotation = D3DXVECTOR3(0,0,0); HR(fossa->model->getAnimCtrl()->CloneAnimationController(fossa->model->getAnimCtrl()->GetMaxNumAnimationOutputs(), fossa->model->getAnimCtrl()->GetMaxNumAnimationSets(),fossa->model->getAnimCtrl()->GetMaxNumTracks(),fossa->model->getAnimCtrl()->GetMaxNumEvents(), &fossa->mAnimCtrl)); //SETUP//////////// for( unsigned i = 0; i < fossa->mAnimCtrl->GetMaxNumTracks(); i++ ) fossa->mAnimCtrl->SetTrackEnable(i, TRUE); /////////////////// //TEST PLAYING AN ANIMATION TRACK!!!! fossa->mAnimCtrl->SetTrackEnable(0, TRUE); LPD3DXANIMATIONSET animSet = NULL; //fossa->mAnimCtrl->SetTrackSpeed(0, .01f); fossa->mAnimCtrl->GetAnimationSet(2, &animSet); fossa->mAnimCtrl->SetTrackAnimationSet(0, animSet); animSet->Release(); ///////// } break; case BLOCK_STONE: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["block_stone"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->visible = true; block->Normal = textureMap["rocks_normals"]; } break; case BLOCK_ICE: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["block_ice"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->visible = true; block->Normal = textureMap["ice_normals"]; } break; case BLOCK_FAN: { /*BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["block_fan"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->visible = true; block->Normal = textureMap["default"];*/ SkinnedComponent *fan = new SkinnedComponent(); comp = fan; fan->model = skinnedMeshMap["fanblock"]; fan->shader = effectMap["SkinnedMesh"]; fan->scale = D3DXVECTOR3(.05f,.05f,.05f); fan->position = D3DXVECTOR3(10,10,10); fan->rotation = D3DXVECTOR3(0,0,0); HR(fan->model->getAnimCtrl()->CloneAnimationController(fan->model->getAnimCtrl()->GetMaxNumAnimationOutputs(), fan->model->getAnimCtrl()->GetMaxNumAnimationSets(),fan->model->getAnimCtrl()->GetMaxNumTracks(),fan->model->getAnimCtrl()->GetMaxNumEvents(), &fan->mAnimCtrl)); //SETUP//////////// for( unsigned i = 0; i < fan->mAnimCtrl->GetMaxNumTracks(); i++ ) fan->mAnimCtrl->SetTrackEnable(i, FALSE); /////////////////// //TEST PLAYING AN ANIMATION TRACK!!!! fan->mAnimCtrl->SetTrackEnable(0, TRUE); LPD3DXANIMATIONSET animSet = NULL; //fan->mAnimCtrl->SetTrackSpeed(0, .01f); fan->mAnimCtrl->GetAnimationSet(0, &animSet); fan->mAnimCtrl->SetTrackAnimationSet(0, animSet); animSet->Release(); //////////////////////////////////////////// } break; case BLOCK_TRAMPOLINE: { /*BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["block_trampoline"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->visible = true; block->Normal = textureMap["trampoline_normals"];*/ SkinnedComponent *block = new SkinnedComponent(); comp = block; block->model = skinnedMeshMap["block_trampoline"]; block->shader = effectMap["SkinnedMesh"]; block->scale = D3DXVECTOR3(.01f,.01f,.01f); block->position = D3DXVECTOR3(10,10,10); block->rotation = D3DXVECTOR3(0,0,0); //block->Normal = textureMap["trampoline_normals"]; HR(block->model->getAnimCtrl()->CloneAnimationController(block->model->getAnimCtrl()->GetMaxNumAnimationOutputs(), block->model->getAnimCtrl()->GetMaxNumAnimationSets(),block->model->getAnimCtrl()->GetMaxNumTracks(),block->model->getAnimCtrl()->GetMaxNumEvents(), &block->mAnimCtrl)); //SETUP//////////// for( unsigned i = 0; i < block->mAnimCtrl->GetMaxNumTracks(); i++ ) block->mAnimCtrl->SetTrackEnable(i, FALSE); /////////////////// //TEST PLAYING AN ANIMATION TRACK!!!! block->mAnimCtrl->SetTrackEnable(0, TRUE); LPD3DXANIMATIONSET animSet = NULL; block->mAnimCtrl->SetTrackSpeed(0, 1.f); block->mAnimCtrl->GetAnimationSet(0, &animSet); block->mAnimCtrl->SetTrackAnimationSet(0, animSet); animSet->Release(); block->ChangeAnimSpeed(.3f); block->ChangeAnim(0); //////////////////////////////////////////// } break; case BLOCK_SAND: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["block_sand"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->visible = true; block->Normal = textureMap["sand_normals"]; } break; case DIGIBLOCK: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["digiblock"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["default"]; } break; case RIGIDBLOCK: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["rigidblock"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["default"]; } break; case JEWEL: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel_off"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case JEWEL_1: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel1"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case JEWEL_2: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel2"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case JEWEL_3: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel3"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case JEWEL_4: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel4"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case JEWEL_5: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["jewel5"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["jewelNorm"]; } break; case HUB_FLOOR: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["hub_floor"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["rocks_normals"]; } break; case HUB_WALL1: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["hub_wall1"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["default"]; } break; case HUB_WALL2: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["hub_wall2"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["default"]; } break; case HUB_WALL3: { BlockGraphicComponent *block = new BlockGraphicComponent(); comp = block; block->model = modelMap["hub_wall3"]; block->shader = effectMap["HackMapping"]; block->scale = D3DXVECTOR3(1,1,1); block->position = D3DXVECTOR3(0,0,0); block->rotation = D3DXVECTOR3(0,0,0); block->Normal = textureMap["default"]; } break; default: return NULL; } comp->type = object; ComponentList.push_back(comp); return comp; }