예제 #1
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();
	}

}
예제 #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);
}
예제 #3
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;
}
예제 #4
0
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;
}
예제 #5
0
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;
}
예제 #6
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;
};
예제 #7
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;
}