Exemple #1
0
void RenderPart::exit()
{
	AnimationComponent* animation = nullptr;
	animation = ( m_Animations[m_CurrentStateIdx] != nullptr ) ?
		m_Animations[m_CurrentStateIdx] : m_Animations[0];
	animation->exit();
}
Exemple #2
0
void CreateRandomRobot(Game *pGame)
{
	Vector3 pos = pGame->getRandomVector(2000.0f);
	
	GameObject *pRobot = pGame->CreateObject(pos,Quaternion(1,0,0,0),"testent",eStaticMeshObject,false);
	OgreRenderInstanceComponent *pORC = dynamic_cast<OgreRenderInstanceComponent *>(pGame->CreateComponent(GameComponent::eCom_Render3D));
	if (pORC) pORC->Create("robot.mesh",pRobot,true);
	pRobot->AddComponent(pORC);
	MoverComponent *pMover = dynamic_cast<MoverComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleMover));
	pMover->setParent(pRobot);
	pMover->Init(1000.0f,70.0f,40.0f,pos,1.5f,true);
	pRobot->AddComponent(pMover);
	AnimationComponent *pAnim = dynamic_cast<AnimationComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleAnimation));
	pAnim->setParent(pRobot);
	pAnim->Init(0.001f);
	pRobot->AddComponent(pAnim);

	
	// a selector component, this allows a gameobject to know wether its selected or not
   SelectionComponent *pSelect = dynamic_cast<SelectionComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleSelection));
   pSelect->setParent(pRobot);
   pSelect->Init();
   pRobot->AddComponent(pSelect);
	
	pGame->AddGob(pRobot);
}
Exemple #3
0
void CreateCameraBox(Game *pGame)
{
	Vector3 pos;
	pos.x = 0; pos.y = 0; pos.z = 0;
	GameObject *pObj = pGame->CreateObject(pos,Quaternion(pos.x,0,0,0),"testent",eStaticMeshObject,false);
	// render mesh component
	OgreRenderInstanceComponent *pORC = dynamic_cast<OgreRenderInstanceComponent *>(pGame->CreateComponent(GameComponent::eCom_Render3D));
	if (pORC) pORC->Create("Box01.mesh",pObj,true);
	pObj->AddComponent(pORC);
	// animation handler component
	AnimationComponent *pAnim = dynamic_cast<AnimationComponent *>(pGame->CreateComponent(GameComponent::eCom_SimpleAnimation));
	pAnim->setParent(pObj);
	pAnim->Init(0.001f);
	pObj->AddComponent(pAnim);

	pGame->AddGob(pObj);

	// path controller component
	PathCameraComponent *pPath = dynamic_cast<PathCameraComponent *>(pGame->CreateComponent(GameComponent::eCom_PathCameraController));
	if(pPath)
	{
		pObj->AddComponent(pPath);
		pPath->Init();
	}

}
Exemple #4
0
bool Animator::isAnimationRunning(Entity* object, const std::string& animationName)
{
	AnimationComponent* animationComp = object->getComponent<AnimationComponent>();
	if(animationComp && animationComp->isValid())
		return animationComp->isAnimationRunning(animationName);
	return false;
}
Exemple #5
0
void Animator::launchAnimation(Entity* object, const std::string& labelName, bool flaged)
{
	AnimationComponent* animationComp = object->getComponent<AnimationComponent>();
	SkeletonComponent* skeletonComp = object->getComponent<SkeletonComponent>();
	if(animationComp && animationComp->isValid() && skeletonComp && skeletonComp->isValid())
		animationComp->launchAnimation(labelName, skeletonComp->getNbJoints(), flaged);
}
Exemple #6
0
/// Called from SceneGraph "sceneUpdate"
void Mesh::sceneUpdate(const U64 deltaTimeUS, SceneGraphNode& sgn, SceneState& sceneState) {
    if (getObjectFlag(ObjectFlag::OBJECT_FLAG_SKINNED)) {
        sgn.forEachChild([deltaTimeUS](const SceneGraphNode& child) {
            AnimationComponent* animComp = child.get<AnimationComponent>();
            // Not all submeshes are necessarily animated. (e.g. flag on the back of a character)
            if (animComp) {
                animComp->incParentTimeStamp(deltaTimeUS);
            }
        });
    }

    Object3D::sceneUpdate(deltaTimeUS, sgn, sceneState);
}
GameObject* GameObjectManager::CreateTott(const Ogre::Vector3& position, void* data){
	CharControllerDef& def = *static_cast<CharControllerDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_TOTT);
	AnimationComponent* acomp = new AnimationComponent;
	acomp->AddAnimationStates(1);
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	go->AddLateUpdate(contr);

	acomp->Init("Yomi_2Yomi.mesh", m_scene_manager);
	contr->Init(position, acomp->GetEntity(), def.step_height, def.collider_type, m_physics_engine);
	contr->SetTurnSpeed(def.turn_speed);
	contr->SetVelocity(def.velocity);
	return go;
}
Exemple #8
0
 bool deserialize(JsonNode& root, AnimationComponent& animation)
 {
    for(auto& node : root.Children())
    {
       auto& animation_info = node.second;
       if(node.first == "empty") return true;
       animation.animate(node.first, (float)animation_info["speed"].Cast<double>(),
             animation_info["loop"].Cast<bool>());
    }
    return true;
 }
GameObject* GameObjectManager::CreatePlayer(const Ogre::Vector3& position, void* data){
	CharControllerDef& def = *static_cast<CharControllerDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_PLAYER);
	AnimationComponent* acomp = new AnimationComponent;
	acomp->AddAnimationStates(2);
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	go->AddLateUpdate(contr);
	FollowCameraComponent* fcc = new FollowCameraComponent;
	go->AddComponent(fcc);
	go->AddUpdateable(fcc);
	PlayerInputComponent* pccomp = new PlayerInputComponent;
	go->AddComponent(pccomp);
	go->AddUpdateable(pccomp);
	ChildSceneNodeComponent* csnc = new ChildSceneNodeComponent;
	go->AddComponent(csnc);
	Sound2DComponent* sound2D = new Sound2DComponent;
	go->AddComponent(sound2D);
	Sound3DComponent* sound3D = new Sound3DComponent;
	go->AddComponent(sound3D);
	Music2DComponent* music2D = new Music2DComponent;
	go->AddComponent(music2D);

	acomp->Init("Yomi_2Yomi.mesh", m_scene_manager);
	contr->Init(position, acomp->GetEntity(), def.step_height, def.collider_type, m_physics_engine);
	contr->SetTurnSpeed(def.turn_speed);
	contr->SetVelocity(def.velocity);
	contr->HasFollowCam(true);
	pccomp->Init(m_input_manager);
	sound2D->Init(m_sound_manager);
	sound3D->Init(m_sound_manager);
	music2D->Init(m_sound_manager);
	fcc->Init(m_scene_manager, m_viewport, true);
	fcc->GetCamera()->setNearClipDistance(0.1f);
	fcc->GetCamera()->setFarClipDistance(100);
	csnc->Init(Ogre::Vector3(0.0f, 0.0f, 1.0f), "CreateBubble", acomp->GetSceneNode());
	return go;
}
Exemple #10
0
GameObject* GameObjectManager::CreateTott(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	static int tott_counter = 0;
	Ogre::String tott_id = "Tott" + NumberToString(tott_counter);
	TottDef& def = *static_cast<TottDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_TOTT, tott_id);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	TottAIComponent* ai_comp = new TottAIComponent;
	go->AddComponent(ai_comp);
	go->AddUpdateable(ai_comp);
	AnimationComponent* acomp = new AnimationComponent;
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	
	node_comp->Init(position, m_scene_manager);
	node_comp->SetId(tott_id);
	def.node_name = node_comp->GetSceneNode()->getName();
	acomp->Init(def.mesh_name, m_scene_manager);
	

	
	if (def.type_name == "Hidehog"){
		acomp->AddAnimationState("Run", true);
	}
	else if (def.type_name == "Kittyshroom"){
		acomp->AddAnimationState("walk", true);
	}
	else if (def.type_name == "Nightcap"){
		acomp->AddAnimationState("walk", true);
	}
	else if (def.type_name == "Shroomfox"){
		acomp->AddAnimationState("idle", true);
	}
	else{
		acomp->AddAnimationState("Run", true);
	}
	ai_comp->Init(def.ai_states);
	m_sound_manager->GetTottNode(node_comp->GetSceneNode()->getName());
	contr->Init(position, m_physics_engine, def.character_controller);
	contr->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	contr->GetRigidbody()->setActivationState(DISABLE_DEACTIVATION);
	acomp->GetEntity()->setRenderingDistance(100.0f);
	tott_counter++;
	return go;
}
Exemple #11
0
void Animator::animate(Entity* object, float step)
{
	AnimationComponent* animationComp = object->getComponent<AnimationComponent>();
	SkeletonComponent* skeletonComp = object->getComponent<SkeletonComponent>();
	if(!skeletonComp || !skeletonComp->isValid())
		return;

	if(!animationComp || !animationComp->isValid())
	{
		skeletonComp->initToBindPose();
		return;
	}

	animationComp->updateAnimations(step);

	if(!animationComp->isAnimationRunning())
		return;

	std::vector<JointPose> blendPose(skeletonComp->getNbJoints());
	animationComp->blendAnimations(blendPose);
	animationComp->cleanAnimationTracks(step);

	skeletonComp->computePose(blendPose);
}
Exemple #12
0
GameObject* GameObjectManager::CreateQuestTott(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	static int quest_tott_counter = 0;
	Ogre::String tott_id = "Tott" + NumberToString(quest_tott_counter);
	TottDef& def = *static_cast<TottDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_QUEST_TOTT, tott_id);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	TottAIComponent* ai_comp = new TottAIComponent;
	go->AddComponent(ai_comp);
	go->AddUpdateable(ai_comp);
	AnimationComponent* acomp = new AnimationComponent;
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	ChildSceneNodeComponent* child_node = new ChildSceneNodeComponent;
	go->AddComponent(child_node);
	MeshRenderComponent* spbubble = new MeshRenderComponent;
	go->AddComponent(spbubble);
	SyncedTriggerComponent* trcomp = new SyncedTriggerComponent;
	go->AddComponent(trcomp);
	go->AddUpdateable(trcomp);
	TottController* tott_contr = new TottController;
	go->AddComponent(tott_contr);
	go->AddUpdateable(tott_contr);
	
	node_comp->Init(position, m_scene_manager);
	node_comp->SetId(tott_id);
	def.node_name = node_comp->GetSceneNode()->getName();
	acomp->Init(def.mesh_name, m_scene_manager);
	
	child_node->Init(Ogre::Vector3(0,def.speech_bubble_y,0), "speech_bubble", node_comp->GetSceneNode());
	child_node->SetId("speech_bubble");
	spbubble->Init(def.quest_item_mesh_name, m_scene_manager, "speech_bubble");
	child_node->GetNode()->attachObject(spbubble->GetEntity());
	spbubble->GetEntity()->setCastShadows(false);
	child_node->GetNode()->setScale(0,0,0);

	if (def.type_name == "Hidehog"){
		acomp->AddAnimationState("Run", true);
	}
	else if (def.type_name == "Kittyshroom"){
		acomp->AddAnimationState("walk", true);
	}
	else if (def.type_name == "Nightcap"){
		acomp->AddAnimationState("walk", true);
	}
	else if (def.type_name == "Shroomfox"){
		acomp->AddAnimationState("idle", true);
	}
	else{
		acomp->AddAnimationState("Run", true);
	}
	ai_comp->Init(def.ai_states);
	m_sound_manager->GetTottNode(node_comp->GetSceneNode()->getName());
	contr->Init(position, m_physics_engine, def.character_controller);
	contr->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	contr->GetRigidbody()->setActivationState(DISABLE_DEACTIVATION);

	tott_contr->Init(m_physics_engine, m_scene_manager, def.idle_anim, def.excited_anim, def.quest_item);

	TriggerDef trdef;
	trdef.body_type = STATIC_BODY;
	trdef.collider_type = COLLIDER_SPHERE;
	trdef.collision_filter.filter = COL_WORLD_TRIGGER;
	trdef.collision_filter.mask = COL_PLAYER;
	trdef.mass = 1.0f;
	trdef.radius = 4.0f;

	trcomp->Init(position, m_physics_engine, &trdef);
	acomp->GetEntity()->setRenderingDistance(100.0f);
	quest_tott_counter++;
	return go;
};
Exemple #13
0
GameObject* GameObjectManager::CreatePlayer(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	PlayerDef& def = *static_cast<PlayerDef*>(data);
	CharacterControllerDef& char_def = *def.character_contr;
	GameObject* go = new GameObject(GAME_OBJECT_PLAYER, "player");
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	AnimationComponent* acomp = new AnimationComponent;
	go->AddComponent(acomp);
	go->AddUpdateable(acomp);
	MeshRenderComponent* staff_mesh_comp = new MeshRenderComponent;
	go->AddComponent(staff_mesh_comp);
	CharacterController* contr = new CharacterController;
	go->AddComponent(contr);
	go->AddUpdateable(contr);
	FollowCameraComponent* fcc = new FollowCameraComponent;
	go->AddComponent(fcc);
	go->AddUpdateable(fcc);
	PlayerInputComponent* pccomp = new PlayerInputComponent;
	go->AddComponent(pccomp);
	go->AddUpdateable(pccomp);
	ChildSceneNodeComponent* csnc = new ChildSceneNodeComponent;
	go->AddComponent(csnc);
	Sound2DComponent* sound2D = new Sound2DComponent;
	go->AddComponent(sound2D);
	Sound3DComponent* sound3D = new Sound3DComponent;
	go->AddComponent(sound3D);
	Music2DComponent* music2D = new Music2DComponent;
	go->AddComponent(music2D);
	Music3DComponent* music3D = new Music3DComponent;
	go->AddComponent(music3D);
	CountableResourceGUI* gui = new CountableResourceGUI;
	go->AddComponent(gui);
	go->AddUpdateable(gui);
	TriggerComponent* tc = new TriggerComponent;
	go->AddComponent(tc);
	PlayerRaycastCollisionComponent* prcc = new PlayerRaycastCollisionComponent;
	go->AddComponent(prcc);
	TutorialGraphicsComponent* tutorial = new TutorialGraphicsComponent;
	go->AddComponent(tutorial);
	go->AddUpdateable(tutorial);
	/*
	TriggerComponent* camera_tc = new TriggerComponent;
	go->AddComponent(camera_tc);
	RaycastComponent* camera_rc = new RaycastComponent;
	go->AddComponent(camera_rc);
	CameraRaycastCollisionComponent* camera_rcc = new CameraRaycastCollisionComponent;
	go->AddComponent(camera_rcc);
	//RigidbodyComponent* camera_rb = new RigidbodyComponent;
	*/
	if (def.level_id == "try"){
		tutorial->Init("Level1", def.level_id);
	}
	else{
		tutorial->Init("Level2", def.level_id);
	}

	go->SetId("Player");

	node_comp->Init(position, m_scene_manager);
	node_comp->SetId("player_node");
	
	if(char_def.mesh == "" || char_def.mesh == "Yomi_2Yomi.mesh") char_def.mesh = "Yomi.mesh";
	acomp->Init(char_def.mesh, m_scene_manager, node_comp->GetId(), true);
	acomp->AddAnimationState("Base_Idle");
	acomp->AddAnimationState("Top_Idle");
	//acomp->GetEntity()->setMaterialName("_YomiFBXASC039sFBXASC032staffMaterial__191");

	TriggerDef tdef;
	tdef.body_type = STATIC_BODY;
	tdef.collider_type = COLLIDER_SPHERE;
	tdef.radius = 0.1f;
	tdef.collision_filter.filter = COL_NOTHING;
	tdef.collision_filter.mask = COL_NOTHING;

	tc->Init(position, m_physics_engine, tdef);
	tc->SetId("btrig");
	contr->Init(position, m_physics_engine, char_def);
	contr->HasFollowCam(true);
	contr->SetId("body");
	contr->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	sound2D->Init(m_sound_manager);
	sound3D->Init(m_sound_manager);
	music2D->Init(m_sound_manager);
	music3D->Init(m_sound_manager);
	gui->Init(def.level_id);
	csnc->Init(Ogre::Vector3(0.0f, char_def.offset.y, 1.0f), "CreateBubble", node_comp->GetSceneNode());
	m_sound_manager->GetYomiNode(node_comp->GetSceneNode()->getName());
	prcc->Init(m_physics_engine);
	prcc->SetCustomVariables(VariableManager::GetSingletonPtr()->GetAsFloat("Bounce_Jump_Mod"));

	fcc->SetNode(node_comp->GetSceneNode());
	fcc->Init(position, m_scene_manager, m_viewport, true);
	fcc->SetMovementSpeed(2.5f);

	fcc->SetPhysEngine(m_physics_engine);
	fcc->SetCustomVariables(
		//VariableManager::GetSingletonPtr()->GetAsInt("Camera_Inverted_Controller_Sticks"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Zoom_Speed"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Stick_Rotation_Acceleration"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Change_Angle_After_Player"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Start_Distance"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Camera_Start_Pitch")
		);
	staff_mesh_comp->Init("Staff.mesh", m_scene_manager, Ogre::StringUtil::BLANK);
	acomp->GetEntity()->attachObjectToBone("CATRigLArmDigit21", staff_mesh_comp->GetEntity(), Ogre::Quaternion(1.0f, 1.0f, 0.7f, 0.0f), Ogre::Vector3(0.01f, -0.02f, 0.0f));
	pccomp->Init(m_input_manager, m_sound_manager, m_physics_engine, m_message_system);
	pccomp->SetCustomVariables(
		VariableManager::GetSingletonPtr()->GetAsFloat("Bubble_Min_Size"),
		VariableManager::GetSingletonPtr()->GetAsFloat("Bubble_Max_Size"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("On_Bubble_Speed_Mod"), 
		VariableManager::GetSingletonPtr()->GetAsFloat("In_Bubble_Speed_Mod"),
		def.level_id
		);
	return go;
}
Exemple #14
0
//---------------------------------------------------------------------------
bool Avatar::update(float deltaT)
{
	if (_update(deltaT))
	{
		// we can't extract mount points from the derived avatar type
		// until it's fully initialized, so we need to do this here in 
		// update() as opposed to in initialize()

		// check components for an AnimationComponent
		AnimationComponent* pAnim = 0;
		if (findComponents(AnimationComponent::getClassDef(), (Component**)&pAnim))
		{
			// and then, if we have a valid animation blender...
			AnimationBlender* pBlender = pAnim->getBlender();
			if (pBlender)
			{
				// and then, if it has mounts but our mount data is empty...
				size_t numMP = pBlender->getNumMountPoints();
				if (numMP)
				{
					if (m_mountPoints.size() == 0)
					{
						// then we can fill in our data structure
						for (size_t i=0; i<numMP; ++i)
						{
							const AnimationBlender::MountPointData* pData = 
								pBlender->getMountPoint(i);

							MountPoint mp;
							mp.m_index = i;
							mp.m_boneIndex = pData->m_boneIndex;
							mp.m_transform = pData->m_transform;
							mp.m_pSlot = 0;
							m_mountPoints[pData->m_name] = mp;
						}

						// now get a list of all of the EquipmentSlotComponents 
						// configured for us; we need to associate each component 
						// with a mount point
						ComponentList list;
						findComponents(EquipmentSlotComponent::getClassDef(), list);
						for (ComponentList::iterator it=list.begin(); it != list.end(); ++it)
						{
							EquipmentSlotComponent* pSlot = static_cast<EquipmentSlotComponent*>(*it);
							MountPoints::iterator mp = m_mountPoints.find(pSlot->getMountPoint());
							if (mp != m_mountPoints.end())
								mp->second.m_pSlot = pSlot;
							else
							{
								// log a mismatch
								String msg("Could not find mount point '");
								msg += pSlot->getMountPoint();
								msg += String("' in avatar: ");
								msg += getName();

								Environment::get().pLogger->logMessage(msg);
							}
						}

						// and finally, clear up our mount backlog, if any
						for (size_t i=0; i<m_delayedMounts.size(); ++i)
						{
							addToSlot(m_delayedMounts[i].pMountable, m_delayedMounts[i].slotId);
						}
						m_delayedMounts.clear();
					}
					else
					{
						// we can update our mount point transforms
						for (size_t i=0; i<numMP; ++i)
						{
							const AnimationBlender::MountPointData* pData = 
								pBlender->getMountPoint(i);

							MountPoints::iterator it = m_mountPoints.find(pData->m_name);
							if (it != m_mountPoints.end())
							{
								it->second.m_transform = pData->m_transform;
								it->second.m_pSlot->setTransform(pData->m_transform);
							}
						}
					}
				}
			}
		}

		// update our mounted objects
		for (MountPoints::iterator it = m_mountPoints.begin();
			it != m_mountPoints.end(); ++it)
		{
			EquipmentSlotComponent* pComp = it->second.m_pSlot;
			if (pComp)
			{
				size_t nEquip = pComp->getNumEquipment();
				for (size_t j=0; j<nEquip; ++j)
				{
					Mountable* pMounted = pComp->getEquipment(j);
					if (pMounted)
						pMounted->update(deltaT);
				}
			}
		}

		// Avatars might have camera components too
		CameraInterfaceComponent* pCamComp;
		if (findComponents(
			CameraInterfaceComponent::getClassDef(), (Component**)&pCamComp))
		{
			pCamComp->update(deltaT);
		}

		return ZoneObject::update(deltaT);
	}

	return false;
}
Exemple #15
0
void Animator::stopAnimation(Entity* object, const std::string& labelName)
{
	AnimationComponent* animationComp = object->getComponent<AnimationComponent>();
	if(animationComp && animationComp->isValid())
		animationComp->stopAnimation(labelName);
}