void CAnimationComponent::InitializeAnimationData()
{
#ifndef IARESERVER
	CAssetManager*	assetManager = CGame::GetInstance()->GetAssestManager();
	CDeformer*		newDeformer = nullptr;
	CInterpolator*	newInterpolator	= nullptr;

	// Tell the asset manager to load the animations for this models if it hasn't already
	bool loadedAnimations = assetManager->HasModelAnimationFrames( m_modelTag );
	if( loadedAnimations == false )
	{
		for( unsigned it = 0; it < keyframeCount; it++ )
		{
			//assetManager->LoadAnimationFromBinary( m_modelTag, animationFileNames[ it ] );
			assetManager->LoadAnimationFromFBX( m_modelTag, animationFileNames[ it ], this );
		}
	}

	//Grab the animation data from the AssetManager based on the name of the mesh
	keyframes		= assetManager->GetModelAnimationFrames( m_modelTag );
	keyframeCount = keyframes->size();
	//Create Deformer per animation
	//Create Interpolator per animation
	//set deformer/interpolator data members;
	if (keyframeCount > 0)
	{

		for (unsigned fIt = 0; fIt < keyframeCount; fIt++)
		{
			newDeformer = new CDeformer();
			newInterpolator = new CInterpolator();
			m_pDeformers.push_back(newDeformer);
			m_pInterpolators.push_back(newInterpolator);

			m_pInterpolators[fIt]->SetAnimation((*keyframes)[fIt]);
			// m_pInterpolators[ fIt ]->SetTime( 0.0f );

			std::vector<CMesh>* m = assetManager->GetMeshes(m_modelTag);
			CMesh* mesh = &m->front();

			m_pDeformers[fIt]->SetMesh(mesh);
		}

		CMesh*		mesh = m_pDeformers[0]->GetMesh();
		vertCount = mesh->GetVerts().size();
		indexCount = mesh->GetIndices().size();
		std::vector<UniqueVertex>& modelVertices = mesh->GetVerts();

		m_vIndices = new std::vector < unsigned > ;
		std::vector<unsigned int>& ind = mesh->GetIndices();
		(*m_vIndices) = ind;

		// The normals and texture coordinates aren't changing so just set them once during initialization
		vector< std::vector< CMesh::JointInfluence >> vec = mesh->GetInfluences();
		for (unsigned vIt = 0; vIt < vertCount; vIt++)
		{
			AnimVert vert;
			vert.vertInfo = modelVertices[vIt].vertInfo;
			jointInfo joint;
			ZeroMemory(&joint, sizeof(jointInfo));
			for (size_t i = 0; i < vec[vIt].size(); i++)
			{
				joint.joint_Index[i] = (float)(vec[vIt][i].joint_index);
				joint.weight[i] = vec[vIt][i].weight;
			}
			vert.boneInfo = joint;
			m_animatedVerts.push_back(vert);
		}
	}
	LoadTexture(this->GetModelTag(), &textureInfo);
#endif
}
Example #2
0
/*****************************************************************
* CSkeleton()			Skeleton Constructor that initializes the data members
*
* Ins:					CObjectManager*
*						CAnimationManager*
*
* Outs:					None
*
* Returns:				void
*
* Mod. Date:		    08/20/2015
* Mod. Initials:	    NS
*****************************************************************/
CSkeleton::CSkeleton(CObjectManager* _manager, CAnimationManager* _animManager, CDayNight* _dayNight, CSkeletonController* skeletonController) : CBoid(10.0f, 500.0f, "Skeleton")
{
	// Drop Shadow Creation //
	CMesh cDropShadow;

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(1);
	cDropShadow.GetIndices().push_back(2);

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(2);
	cDropShadow.GetIndices().push_back(3);

	cDropShadow.GetVertices().push_back
		({
			{ -100.0f, 3.0f, 100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 100.0f, 3.0f, 100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 100.0f, 3.0f, -100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 1 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ -100.0f, 3.0f, -100.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 1 }
	});

	m_cDropShadow = new CRenderMesh(&cDropShadow, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS());
	m_cDropShadow->SetTexture(L"../Game/Assets/Art/2D/Textures/Shadow.dds");
	m_cDropShadow->GetTransparent() = true;
	m_cDropShadow->GetRender() = false;

	GRAPHICS->AddRenderMesh(m_cDropShadow);

	// Initilize Managers
#if _DEBUG
	m_pPathPlanner = new CPathFinding("SkeletonNavGraph", _manager, false);

#else
	m_pPathPlanner = new CPathFinding("SkeletonNavGraph", _manager, false);

#endif

	m_pDayNight = _dayNight;
	m_fScale = 1.0f;
	
	m_pAssetManager = CAssetManager::GetInstance();
	m_bPoweringUp = false;
	//Set the Animation Manager
	m_cpAnimationManager = _animManager;
	m_cpAnimations = new CAnimation[eAnimCount];

	m_cpSkeletonController = skeletonController;
	// Set the object manager
	m_cpObjectManager = _manager;
	m_bBuffed = false;

	TPointLight tempLight;
	tempLight.m_fRadius = 0.0f;
	tempLight.m_fColor[0] = 1.0f;
	tempLight.m_fColor[1] = 0.0f;
	tempLight.m_fColor[2] = 0.0f;
	tempLight.m_fBrightness = 2.5f;
	tempLight.m_fPosition[0] = 0.0f;
	tempLight.m_fPosition[1] = 0.0f;
	tempLight.m_fPosition[2] = 0.0f;
	tempLight.m_fPosition[3] = 1.0f;
	AddLight(tempLight);

	m_bHit = false;

	// Load the asset
	/*CMesh* m_cShieldMesh = m_pAssetManager->GetMesh(CAssetManager::eMeshType::SkeletonShield)[0];
	m_cShieldRender[0] = new CRenderMesh(m_cShieldMesh, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Shield2_Diffuse.dds");
	m_cShieldRender[1] = new CRenderMesh(m_cShieldMesh, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Shield2_Diffuse.dds");*/

	CMesh* m_cMesh = CAssetManager::GetInstance()->GetPrefabMesh("RemnantMesh");
	// Create a render mesh for the object

	m_cpRenderMesh = new CAnimationMesh(m_cMesh, GRAPHICS->GetSkinningVS(), GRAPHICS->GetNormalMapPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/RemnantDiffuse.dds");
	m_cpRenderMesh->SetNormals(L"../Game/Assets/Art/2D/Normal Maps/RemnantNormal.dds");
	// Set the animation mesh
	m_cpSword = new CSkeletonSword;

	XMMATRIX mSkele = XMMatrixIdentity();
	XMStoreFloat4x4(&m_mSkeleLocal, mSkele);

	//	AttachToJoint(m_cpSword->S(), LEFT_HAND);
	m_cpRenderMesh->GetRender() = false;

	m_cpAnimations[eRunAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantRun");
	m_cpAnimations[eRunAnim].SetLooping(true);

	

	m_cpAnimations[eBlockWalkAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantRun");
	m_cpAnimations[eBlockWalkAnim].SetLooping(true);

	m_cpAnimations[eAttackAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantLightAttack1");
	m_cpAnimations[eAttackAnim].SetLooping(false);
	m_cpAnimations[eAttackAnim].SetScale(1.33f);

	m_cpAnimations[eDeathAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantDeath1");
	m_cpAnimations[eDeathAnim].SetLooping(false);

	m_cpAnimations[eHurtAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantHurt");
	m_cpAnimations[eHurtAnim].SetLooping(false);
	m_cpAnimations[eHurtAnim].SetScale(1.0f);

	m_cpAnimations[eHurt2Anim] = CAssetManager::GetInstance()->GetAnimation("RemnantHurt");
	m_cpAnimations[eHurt2Anim].SetLooping(false);

	m_cpAnimations[eSpawnAnim] = CAssetManager::GetInstance()->GetAnimation("RemnantSpawn1");
	m_cpAnimations[eSpawnAnim].SetLooping(false);
	m_cpAnimations[eSpawnAnim].SetScale(0.0f);

	m_pParticleManager = new CParticleManager(_manager);
	m_unParticleEmitters[eBoneParticle] = m_pParticleManager->LoadEmitter("BoneFragment.xml");
	m_unParticleEmitters[eDustParticle] = m_pParticleManager->LoadEmitter("BoneDust.xml");
	m_unParticleEmitters[eFadeAway] = m_pParticleManager->LoadEmitter("EnemyFadeAway.xml");

	for (unsigned int animation = 0; animation < eAnimCount; animation++)
	{
		m_cpAnimations[animation].SetAnimMesh((CAnimationMesh*)m_cpRenderMesh);
		m_cpAnimations[animation].IntializeAnimation();
	}

	// Add the starting animation
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eSpawnAnim]);

	// Set the current animaton
	m_unCurrAnim = eSpawnAnim;

	// Add collision box
	AddCollider(new CCollider(true, new CAABB(XMFLOAT3(m_mWorld._41, 55.0f, m_mWorld._43), XMFLOAT3(90.0f, 90.f, 90.f)), false));
	CCapsule* theCapsule = new CCapsule({ m_mWorld._41, 45.0f, m_mWorld._43 }, { m_mWorld._41, 240.0f, m_mWorld._43 }, 45.0f);
	AddCollider(new CCollider(true, theCapsule));

	((CAABB*)m_pvColliders[0]->GetBounds())->SetCenter({ m_mWorld._41, m_mWorld._42, m_mWorld._43 });


	// Create the attack instance
	AttachToJoint(m_cpSword->GetRenderMesh(), "RightHand");
	GRAPHICS->AddRenderMesh(m_cpSword->GetRenderMesh());
	m_cpAttack = new CAttack(this, CAssetManager::GetInstance()->GetPrefabMesh("OrcDagger"), &m_cpSword->GetRenderMesh()->GetPositionMatrix(), 20, "SkeletonAttack");
	m_cpAttack->SetParent(this);

	// Add the object to start attacking.
	CAddObjectMessage* addObj = new CAddObjectMessage(m_cpAttack, CObjectManager::Dynamic);

	// Send the message
	addObj->Send();

	SetWorldVelocity(XMFLOAT3(0.0f, 0.0f, 0.0f));

	
	GRAPHICS->AddRenderMesh(m_cpRenderMesh);
	GRAPHICS->AddLight(&m_vtPointLights[0]);


	m_ipCurrentState = SPAWN;
	EnterSubState();

	m_cpTheLoot = new CBone(m_cpObjectManager, this);
	m_cpThePowder = new CGunpowder(m_cpObjectManager, this);
}
Example #3
0
CMinotaur::CMinotaur(const XMFLOAT3& spawnPosition, CObjectManager* _manager, CAnimationManager* _animManager) : CBoid(15.0f, 300.0f, "Minotaur")
{
	// Drop Shadow Creation //
	CMesh cDropShadow;

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(1);
	cDropShadow.GetIndices().push_back(2);

	cDropShadow.GetIndices().push_back(0);
	cDropShadow.GetIndices().push_back(2);
	cDropShadow.GetIndices().push_back(3);

	cDropShadow.GetVertices().push_back
		({
			{ -400.0f, 3.0f, 400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 400.0f, 3.0f, 400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 0 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ 400.0f, 3.0f, -400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 1, 1 }
	});

	cDropShadow.GetVertices().push_back
		({
			{ -400.0f, 3.0f, -400.0f, 1.0f },
			{ 0.0f, 1.0f, 0.0f, 1.0f },
			{ 0, 1 }
	});

	m_cDropShadow = new CRenderMesh(&cDropShadow, GRAPHICS->GetStandardVS(), GRAPHICS->GetStandardPS());
	m_cDropShadow->SetTexture(L"../Game/Assets/Art/2D/Textures/Shadow.dds");
	m_cDropShadow->GetTransparent() = true;
	m_cDropShadow->GetRender() = false;
	GRAPHICS->AddRenderMesh(m_cDropShadow);

	XMStoreFloat4x4(&m_mWorld, XMMatrixTranslation(spawnPosition.x, spawnPosition.y, spawnPosition.z));
	m_tSpawnPosition = spawnPosition;
	m_pPathPlanner = new CPathFinding("MinotaurNavGraph", _manager, false);

	CNavGraph* cNavGraph = CNavGraphManager::GetReference().GetNavGraph("MinotaurNavGraph");

	int unNodes[2];
	unNodes[0] = rand() % cNavGraph->GetNodes().size();
	unNodes[1] = rand() % cNavGraph->GetNodes().size();
	if (unNodes[1] == unNodes[0])
	{
		unNodes[1]++;
	}

	m_vWaypoints.push_back(unNodes[0]);
	m_vWaypoints.push_back(unNodes[1]);



	//m_pSteering = new CSteeringManager(this);

	m_pAssetManager = CAssetManager::GetInstance();
	m_cpAnimationManager = _animManager;
	m_cpObjectManager = _manager;
	m_pPlayer = m_cpObjectManager->GetPlayer();
	CMesh* m_cMesh = m_pAssetManager->GetPrefabMesh("minotaur");
	m_cpRenderMesh = new CAnimationMesh(m_cMesh, GRAPHICS->GetSkinningVS(), GRAPHICS->GetStandardPS(), nullptr, nullptr, nullptr, L"../Game/Assets/Art/2D/Textures/Minotaur.dds");
	m_cpRenderMesh->GetRender() = false;
	GRAPHICS->AddRenderMesh(m_cpRenderMesh);

	enum EMinotaurAnimation{ eIdleAnim, eRunAnim, eTellAnim, eChargeAnim, eStompAnim, eDeathAnim, eEnrageAnim, eStunnedAnim, eAnimCount };

	m_cpAnimations[eIdleAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurIdle");
	m_cpAnimations[eRunAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurRun");
	m_cpAnimations[eTellAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurTell");
	m_cpAnimations[eChargeAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurCharge");
	m_cpAnimations[eStompAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurStomp");
	m_cpAnimations[eDeathAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurDeath");
	m_cpAnimations[eEnrageAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurEnrage");
	m_cpAnimations[eStunnedAnim] = CAssetManager::GetInstance()->GetAnimation("MinotaurHurt");





	for (unsigned int animation = 0; animation < eAnimCount; animation++)
	{
		m_cpAnimations[animation].SetAnimMesh((CAnimationMesh*)m_cpRenderMesh);

	}
	//m_cpAnimationManager->AddAnimation(&m_cpAnimations[eRunAnim]);
	/*m_cpAnimationManager->AddAnimation(&m_cpAnimations[eWalkAnim]);
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eRunAnim]);
	m_cpAnimationManager->AddAnimation(&m_cpAnimations[eStompAnim]);*/




	CCapsule*  pCapsule = new CCapsule(XMFLOAT3(spawnPosition.x, 90.0f, spawnPosition.z), XMFLOAT3(spawnPosition.x, 250.0f, spawnPosition.z), 90.0f);
	CCollider* pCapCollider = new CCollider(true, pCapsule, true, false);
	CCollider* pBoxCollider = new CCollider(true, new CAABB(float3(spawnPosition.x, 250.0f, spawnPosition.z), float3(250.0f, 250.0f, 250.0f)), false, false);

	CCollider* pZoneCollider = new CCollider(true, new CAABB(float3(spawnPosition.x, 250.0f, spawnPosition.z), float3(2500.0f, 250.0f, 2500.0f)), true, false);

	


	m_pMinotaurZone = new CMinotaurZone();

	m_pMinotaurZone->AddCollider(pZoneCollider);
	pBoxCollider->GetBounds()->UpdatePosition(spawnPosition);
	AddCollider(pBoxCollider);
	AddCollider(pCapCollider);



	m_pParticleManager = new CParticleManager(_manager);
	m_unParticleEmitters[eBloodParticle] = m_pParticleManager->LoadEmitter("BloodDrop.xml");
	m_unParticleEmitters[eBloodString] = m_pParticleManager->LoadEmitter("BloodString.xml");
	m_unParticleEmitters[eBloodMist] = m_pParticleManager->LoadEmitter("BloodMist.xml");
	m_unParticleEmitters[eBloodMist2] = m_pParticleManager->LoadEmitter("BloodMist.xml");
	m_unParticleEmitters[eStompDustOut] = m_pParticleManager->LoadEmitter("MinotaurStompDust1.xml");
	m_unParticleEmitters[eStompDustUp] = m_pParticleManager->LoadEmitter("MinotaurStompDust2.xml");
	m_unParticleEmitters[eStepDust] = m_pParticleManager->LoadEmitter("MinoStepDust.xml");
	m_unParticleEmitters[eChargeParticle] = m_pParticleManager->LoadEmitter("MinoCharge.xml");
	m_pParticleManager->GetEmitter(m_unParticleEmitters[eChargeParticle])->GetParent() = this;
	m_pParticleManager->GetEmitter(m_unParticleEmitters[eChargeParticle])->Stop();

	m_pStates[ePatrolState] = new CMinotaurPatrol;
	m_pStates[eHostileState] = new CMinotaurHostile;
	m_pStates[eDeadState] = new CMinotaurDead;


	m_unCurrAnim = -1;
	m_nCurrState = ePatrolState;
	//Activate();

}