Ejemplo n.º 1
0
GameObject* GameObjectManager::CreatePlane(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	GameObject* go = new GameObject(GAME_OBJECT_PLANE);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	RigidbodyComponent* rc = new RigidbodyComponent;
	go->AddComponent(rc);

	node_comp->Init(position, m_scene_manager);
	PlaneDef& plane_def = *static_cast<PlaneDef*>(data);
	mrc->Init(plane_def.plane_name, m_scene_manager);
	mrc->GetEntity()->setMaterialName(plane_def.material_name);
	mrc->GetEntity()->setCastShadows(false);

	RigidBodyDef def;
	def.body_type = STATIC_BODY;
	def.collider_type = COLLIDER_TRIANGLE_MESH_SHAPE;
	def.friction = plane_def.friction;
	def.restitution = plane_def.restitution;
	def.mass = 0.0f;
	def.collision_filter.filter = COL_WORLD_STATIC;
	def.collision_filter.mask = COL_PLAYER | COL_BUBBLE | COL_TOTT;
	rc->Init(position, mrc->GetEntity(), m_physics_engine, def);
	rc->GetCollisionDef().flag = COLLISION_FLAG_STATIC;
	return go;
}
Ejemplo n.º 2
0
GameObject* GameObjectManager::CreateQuestItem(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	
	GameObject* tott = *static_cast<GameObject**>(data);
	//Ogre::SceneNode* node = static_cast<NodeComponent*>(tott->GetComponent(COMPONENT_NODE))->GetSceneNode();
	//TottDef tott_def = static_cast<TottController*>(tott->GetComponent(COMPONENT_CHARACTER_CONTROLLER))->m_def;
	QuestItemDef& quest_item_def = *static_cast<QuestItemDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_QUEST_ITEM);
	DestroyCallbackComponent* dcc = new DestroyCallbackComponent;
	go->AddComponent(dcc);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	RigidbodyComponent* rc = new RigidbodyComponent;
	go->AddComponent(rc);
	RotationComponent* rot_comp = new RotationComponent;
	go->AddComponent(rot_comp);
	go->AddUpdateable(rot_comp);
	StringComponent* string_comp = new StringComponent;
	go->AddComponent(string_comp);


	string_comp->Init(quest_item_def.id);
	std::function<void()> func = [&] { IEvent evt; evt.m_type = EVT_QUEST_ITEM_REMOVE; m_message_system->Notify(&evt); };
	dcc->Init(func);

	std::ostringstream stream;
	stream << "Quest_Item_" << m_quest_item_iterations;
	m_quest_item_iterations++;
	Ogre::String quest_item_id = stream.str();

	node_comp->Init(position, m_scene_manager);
	node_comp->SetId(quest_item_id);
	mrc->Init(quest_item_def.mesh_name, m_scene_manager);
	
	RigidBodyDef body_def;
	body_def.body_type = DYNAMIC_BODY;
	body_def.collider_type = COLLIDER_SPHERE;
	body_def.friction = 1.0;
	body_def.mass = 1.0f;
	body_def.collision_filter.filter = COL_QUESTITEM;
	body_def.collision_filter.mask = COL_PLAYER | COL_TOTT | COL_WORLD_STATIC | COL_BUBBLE;
	body_def.sync_orientation = false;
	rc->Init(position,  mrc->GetEntity(), m_physics_engine, body_def);
	rc->GetRigidbody()->setGravity(btVector3(0.0f, -0.3f, 0.0f));
	rc->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	rc->GetRigidbody()->setActivationState(DISABLE_DEACTIVATION);
	rc->GetRigidbody()->setDamping(0.5, 0.5);
	rc->SetId(quest_item_id);
	rot_comp->Init(node_comp->GetSceneNode(), VariableManager::GetSingletonPtr()->GetAsFloat("QuestItemRotationSpeed"));

	return go;
};
Ejemplo n.º 3
0
GameObject* GameObjectManager::CreateSpeechBubble(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	//Ogre::SceneNode* node = *static_cast<Ogre::SceneNode**>(data);

	std::ostringstream stream;
	stream << "Speech_Bubble_" << m_speech_bubble_iterations;
	m_speech_bubble_iterations++;
	Ogre::String spbubble_id = stream.str();

	GameObject* tott = *static_cast<GameObject**>(data);
	Ogre::SceneNode* node = static_cast<NodeComponent*>(tott->GetComponent(COMPONENT_NODE))->GetSceneNode();
	TottDef tott_def = static_cast<TottController*>(tott->GetComponent(COMPONENT_CHARACTER_CONTROLLER))->m_def;

	static_cast<TottController*>(tott->GetComponent(COMPONENT_CHARACTER_CONTROLLER))->SetSpeechBubble(spbubble_id);

	GameObject* go = new GameObject(GAME_OBJECT_SPEECH_BUBBLE, spbubble_id);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	SyncedTriggerComponent* trc = new SyncedTriggerComponent;
	go->AddComponent(trc);
	go->AddUpdateable(trc);
	SpeechBubbleComponent* sbcomp = new SpeechBubbleComponent;
	go->AddComponent(sbcomp);
	go->AddUpdateable(sbcomp);



	node_comp->Init(node, m_scene_manager);
	node_comp->SetId(spbubble_id);
	mrc->Init("PratBubblaCherry.mesh", m_scene_manager, node_comp->GetSceneNode()->getName());//, node->getName());
	sbcomp->Init(node, m_scene_manager, tott);
	
	/*
	node_comp->Init(position, m_scene_manager);
	mrc->Init("PratBubbla.mesh", m_scene_manager);//, m_temp_node->getName());//, node->getName());
	sbcomp->Init(m_temp_node, m_scene_manager);
	*/

	TriggerDef trdef;
	trdef.body_type = DYNAMIC_BODY;
	trdef.collider_type = COLLIDER_SPHERE;
	trdef.mass = 0.0f;
	trdef.radius = 2.5f;
	trdef.collision_filter.filter = COL_WORLD_TRIGGER;
	trdef.collision_filter.mask = COL_PLAYER;
	trc->Init(position, m_physics_engine, &trdef);

	return go;
};
Ejemplo n.º 4
0
GameObject* GameObjectManager::CreatePlane(const Ogre::Vector3& position, void* data){
	GameObject* go = new GameObject(GAME_OBJECT_PLANE);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	RigidbodyComponent* rc = new RigidbodyComponent;
	go->AddComponent(rc);
	
	PlaneDef& plane_def = *static_cast<PlaneDef*>(data);
	mrc->Init(plane_def.plane_name, m_scene_manager);
	mrc->GetEntity()->setMaterialName(plane_def.material_name);
	rc->Init(position, mrc->GetEntity(), m_physics_engine, 0.0f, COLLIDER_TRIANGLE_MESH_SHAPE, STATIC_BODY);
	rc->GetRigidbody()->setRestitution(0.5);
	rc->GetRigidbody()->setFriction(0.5f);
	return go;
}
Ejemplo n.º 5
0
GameObject* GameObjectManager::CreatePinkBubble(const Ogre::Vector3& position, void* data){
	GameObject* go = new GameObject(GAME_OBJECT_BLUE_BUBBLE);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	RigidbodyComponent* rc = new RigidbodyComponent;
	go->AddComponent(rc);

	mrc->Init("sphere.mesh", m_scene_manager);
	Ogre::Vector3 scale(0.002,0.002,0.002);
	mrc->GetSceneNode()->setScale(scale);
	//mrc->GetEntity()->setMaterialName();
	rc->Init(position,  mrc->GetEntity(), m_physics_engine, 1.0f, COLLIDER_SPHERE, DYNAMIC_BODY);
	rc->GetRigidbody()->setGravity(btVector3(0.0f, 0.0f, 0.0f));
	rc->GetRigidbody()->setLinearFactor(btVector3(1,0,1));
	return go;
}
Ejemplo n.º 6
0
GameObject* GameObjectManager::CreatePinkBubble(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	BubbleDef& def = *static_cast<BubbleDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_PINK_BUBBLE);
	BubbleController* bc = new BubbleController;
	go->AddComponent(bc);
	go->AddUpdateable(bc);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	Point2PointConstraintComponent* cons = new Point2PointConstraintComponent;
	go->AddComponent(cons);

	RigidbodyComponent* rc = new RigidbodyComponent;
	go->AddComponent(rc);

	node_comp->Init(position, m_scene_manager);
	mrc->Init("PinkBubble.mesh", m_scene_manager);
	mrc->GetEntity()->setRenderQueueGroup(60);
	Ogre::Vector3 scale(def.start_scale);
	node_comp->GetSceneNode()->setScale(scale);
	
	//bc->SetCustomVariables(VariableManager::GetSingletonPtr()->GetAsFloat("Pink_Bubble_Life_Time"));

	//mrc->GetEntity()->setMaterialName("PinkBubble");
	RigidBodyDef body_def;
	body_def.body_type = DYNAMIC_BODY;
	body_def.collider_type = COLLIDER_SPHERE;
	body_def.friction = def.friction;
	body_def.mass = 1.0f;
	body_def.collision_filter.filter = COL_BUBBLE;
	body_def.collision_filter.mask = COL_PLAYER | COL_TOTT | COL_BUBBLE | COL_WORLD_STATIC | COL_QUESTITEM;
	rc->Init(position,  mrc->GetEntity(), m_physics_engine, body_def);
	rc->GetRigidbody()->setGravity(btVector3(0.0f, 0.0f, 0.0f));
	//rc->GetRigidbody()->setLinearFactor(btVector3(1,0,1));
	rc->GetRigidbody()->setContactProcessingThreshold(btScalar(0));
	rc->GetRigidbody()->setActivationState(DISABLE_DEACTIVATION);
	//rc->GetRigidbody()->setDamping(0.5, 0.5);
	rc->SetId("body");
	cons->Init(m_physics_engine,rc->GetRigidbody(), def.connection_body, btVector3(0,0,0), btVector3(0,0,0));
	bc->Init(m_physics_engine, m_message_system, VariableManager::GetSingletonPtr()->GetAsFloat("OnBubbleImpulse"), VariableManager::GetSingletonPtr()->GetAsFloat("OnBubbleMaxVelocity"), def.start_scale);
	this->CheckBubbleSize();
	m_bubbles.push_back(go);
	return go;
}
Ejemplo n.º 7
0
GameObject* GameObjectManager::CreateLeaf(const Ogre::Vector3& position, void* data, const Ogre::String& id){
	ParticleDef& particleDef = *static_cast<ParticleDef*>(data);
	GameObject* go = new GameObject(GAME_OBJECT_LEAF);
	ParticleComponent* particle = new ParticleComponent;
	go->AddComponent(particle);
	NodeComponent* node_comp = new NodeComponent;
	go->AddComponent(node_comp);
	MeshRenderComponent* mrc = new MeshRenderComponent;
	go->AddComponent(mrc);
	BobbingComponent* bc = new BobbingComponent;
	go->AddComponent(bc);
	go->AddUpdateable(bc);
	TriggerComponent* stc = new TriggerComponent;
	go->AddComponent(stc);


	Ogre::Vector3 scale = Ogre::Vector3(0.6f);
	node_comp->Init(position, m_scene_manager);
	node_comp->GetSceneNode()->setPosition(Ogre::Vector3(position));
	node_comp->GetSceneNode()->setScale(scale);
	mrc->Init("Collectable_Leaf.mesh", m_scene_manager);
	mrc->GetEntity()->setMaterialName("CollectibleLeaf");
	bc->Init(node_comp->GetSceneNode());

	std::ostringstream stream;
	stream << "Leaf_" << m_leaf_iterations;
	m_leaf_iterations++;
	Ogre::String leaf_id = stream.str();

	particle->Init(m_scene_manager, leaf_id, particleDef.particle_name, node_comp->GetSceneNode()->getPosition(), node_comp->GetSceneNode());
	//particle->CreateParticle(node_comp->GetSceneNode(), node_comp->GetSceneNode()->getPosition(), Ogre::Vector3(0,-1.8f,0));

	TriggerDef trdef;
	trdef.body_type = STATIC_BODY;
	trdef.collider_type = COLLIDER_SPHERE;
	trdef.mass = 0.0f;
	trdef.radius = 0.4f;
	trdef.collision_filter.filter = COL_WORLD_TRIGGER;
	trdef.collision_filter.mask = COL_PLAYER;
	stc->Init(position, m_physics_engine, trdef);

	return go;
}
Ejemplo n.º 8
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;
};
Ejemplo n.º 9
0
bool SceneSerializer::DeserializeMeshRenderComponent(XMLReader& reader, SharedGameObject& objectToAdd)
{
	if(reader.NodeHasAttributes())
	{
		MeshRenderComponent* mesh = new MeshRenderComponent();

		//Attach even if model loading failed
		objectToAdd->AttachComponent(mesh);

		bool modelLoaded = false;
		std::string currAttr;

		do 
		{
			currAttr = reader.GetCurrentAttributeName();
			if(currAttr == Enabled)
			{
				//Assume enabled is true unless explicitly otherwise
				bool enabledVal = true;
				reader.GetBoolValue(enabledVal, true);
				mesh->enabled = enabledVal;
			}
			else if(currAttr == EntityName)
			{
				modelLoaded = mesh->LoadModel(reader.GetStringValue(true));
				//If errors loading model, Log it
				if(!modelLoaded)
					Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(
						"Mesh Render Component Deserialization Error: Mesh Not Loaded", Ogre::LML_CRITICAL);
			}
		} while (reader.MoveToNextAttribute());

		if(reader.MoveToChildNode())
		{
			do 
			{
				long long currentID = -1;
				std::string currentMaterial = "";

				do 
				{
					if (reader.GetCurrentAttributeName() == SubentityID)
					{
						if(!reader.GetLongValue(currentID, true))
							currentID = -1;
					}
					else if(reader.GetCurrentAttributeName() == SubentityMaterial)
						currentMaterial = reader.GetStringValue(true);

					if(currentID != -1 && currentMaterial != "")
						mesh->entity->getSubEntity(currentID)->setMaterialName(currentMaterial);

				} while (reader.MoveToNextAttribute());

			} while (reader.MoveToNextSiblingNode());
		}

		reader.PopNode();

		return modelLoaded;
	}

	return false;
}
Ejemplo n.º 10
0
void ArenaBuilder::CreateProbendingPhysXData(IScene* scene)
{
	PhysXDataManager* dataMan = PhysXDataManager::GetSingletonPtr();

	dataMan->CreateMaterial(1.0f, 1.0f, 0.0f, "101000");
	dataMan->CreateMaterial(0.5f, 0.5f, 0.5f, "050505");

	SharedGameObject temp = std::make_shared<GameObject>(scene);
	//Water PhysX Data
	ShapeDefinition waterShapeDef = ShapeDefinition(true);
	waterShapeDef.SetPlaneGeometry();
	waterShapeDef.AddMaterial("050505");
	waterShapeDef.SetFilterFlags(ArenaData::WATER);
	dataMan->CreateShape(waterShapeDef, "BasicPlane");

	//Arena Surface PhysX Data
	MeshRenderComponent* arenaSurfaceMesh = new MeshRenderComponent();
	temp->AttachComponent(arenaSurfaceMesh);
	arenaSurfaceMesh->LoadModel("ProbendArenaSurface.mesh");
	std::shared_ptr<MeshInfo> arenaSurfaceMeshInfo = arenaSurfaceMesh->GetMeshInfo();
	ShapeDefinition arenaSurfaceShapeDef = ShapeDefinition(false);
	arenaSurfaceShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(arenaSurfaceMeshInfo, "ArenaSurfaceMesh"),
		physx::PxVec3(2.0f, 1.0f, 2.0f));
	arenaSurfaceShapeDef.AddMaterial("101000");
	arenaSurfaceShapeDef.SetFilterFlags(ArenaData::ARENA_SURFACE);
	dataMan->CreateShape(arenaSurfaceShapeDef, "ArenaSurfaceShape");

	//Arena Pillars PhysX Data
	MeshRenderComponent* arenaPillarMesh =new MeshRenderComponent();
	temp->AttachComponent(arenaPillarMesh);
	arenaPillarMesh->LoadModel("ProbendPillar.mesh");
	ShapeDefinition arenaPillarShapeDef = ShapeDefinition();
	arenaPillarShapeDef.SetBoxGeometry(HelperFunctions::OgreToPhysXVec3(arenaPillarMesh->GetHalfExtents()));
	arenaPillarShapeDef.AddMaterial("101000");
	arenaPillarShapeDef.SetFilterFlags(ArenaData::PILLAR);
	dataMan->CreateShape(arenaPillarShapeDef, "ArenaPillarShape");

	//Arena Walls PhysX Data
	MeshRenderComponent* arenaWallMesh =new MeshRenderComponent();
	temp->AttachComponent(arenaWallMesh);
	arenaWallMesh->LoadModel("BasicPlane");
	Ogre::Vector3 originalPlaneSize = arenaWallMesh->GetHalfExtents();

	temp->SetScale(1.0f, 10.0f, 12.5f);
	Ogre::Vector3 planeSize = arenaWallMesh->GetHalfExtents();
	ShapeDefinition arenaWallShapeDef = ShapeDefinition();
	arenaWallShapeDef.SetBoxGeometry(physx::PxVec3(0.2f, planeSize.y, planeSize.z));
	arenaWallShapeDef.AddMaterial("101000");
	arenaWallShapeDef.SetFilterFlags(ArenaData::WALL);
	dataMan->CreateShape(arenaWallShapeDef, "ArenaWallShapeMedium");

	temp->SetScale(1.0f, 10.0f, 19.0f);
	planeSize = arenaWallMesh->GetHalfExtents();
	arenaWallShapeDef = ShapeDefinition();
	arenaWallShapeDef.SetBoxGeometry(physx::PxVec3(0.2f, planeSize.y, planeSize.z));
	arenaWallShapeDef.AddMaterial("101000");
	arenaWallShapeDef.SetFilterFlags(ArenaData::WALL);
	dataMan->CreateShape(arenaWallShapeDef, "ArenaWallShapeLarge");

	temp->SetScale(1.0f, 10.0f, 10.0f);
	planeSize = arenaWallMesh->GetHalfExtents();
	arenaWallShapeDef = ShapeDefinition();
	arenaWallShapeDef.SetBoxGeometry(physx::PxVec3(0.2f, planeSize.y, planeSize.z));
	arenaWallShapeDef.AddMaterial("101000");
	arenaWallShapeDef.SetFilterFlags(ArenaData::WALL);
	dataMan->CreateShape(arenaWallShapeDef, "ArenaWallShapeSmall");

	MeshRenderComponent* lowerPlatformMesh = new MeshRenderComponent();
	temp->AttachComponent(lowerPlatformMesh);
	temp->SetScale(2.0f, 1.0f, 1.0f);
	lowerPlatformMesh->LoadModel("ProbendLowerPlatform.mesh");	
	ShapeDefinition lowerPlatformShape = ShapeDefinition();
	lowerPlatformShape.SetBoxGeometry(HelperFunctions::OgreToPhysXVec3(lowerPlatformMesh->GetHalfExtents()));
	lowerPlatformShape.AddMaterial("101000");
	lowerPlatformShape.SetFilterFlags(ArenaData::PLATFORM);
	dataMan->CreateShape(lowerPlatformShape, "ArenaLowerPlatformShape");

	temp->SetScale(1.0f, 1.0f, 1.0f);

	//Zone Trigger Shapes 
	//Zone 1 Pieces
	MeshRenderComponent* z1p1 = new MeshRenderComponent();
	temp->AttachComponent(z1p1);
	z1p1->LoadModel("ProbendArenaZone1P1.mesh");
	std::shared_ptr<MeshInfo> z1p1MeshInfo = z1p1->GetMeshInfo();
	ShapeDefinition z1p1ShapeDef = ShapeDefinition(true);
	z1p1ShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(z1p1MeshInfo, "Z1P1Mesh"),
		physx::PxVec3(2.0f, 8.0f, 2.0f));
	z1p1ShapeDef.AddMaterial("101000");
	z1p1ShapeDef.SetFilterFlags(ArenaData::ZONE_TRIGGER);
	dataMan->CreateShape(z1p1ShapeDef, "Z1P1Shape");

	MeshRenderComponent* z1p2 = new MeshRenderComponent();
	temp->AttachComponent(z1p2);
	z1p2->LoadModel("ProbendArenaZone1P2.mesh");
	std::shared_ptr<MeshInfo> z1p2MeshInfo = z1p2->GetMeshInfo();
	ShapeDefinition z1p2ShapeDef = ShapeDefinition(true);
	z1p2ShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(z1p2MeshInfo, "Z1P2Mesh"),
		physx::PxVec3(2.0f, 8.0f, 2.0f));
	z1p2ShapeDef.AddMaterial("101000");
	z1p2ShapeDef.SetFilterFlags(ArenaData::ZONE_TRIGGER);
	dataMan->CreateShape(z1p2ShapeDef, "Z1P2Shape");

	//Zone 2 Pieces
	MeshRenderComponent* z2p1 = new MeshRenderComponent();
	temp->AttachComponent(z2p1);
	z2p1->LoadModel("ProbendArenaZone2P1.mesh");
	std::shared_ptr<MeshInfo> z2p1MeshInfo = z2p1->GetMeshInfo();
	ShapeDefinition z2p1ShapeDef = ShapeDefinition(true);
	z2p1ShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(z2p1MeshInfo, "Z2P1Mesh"),
		physx::PxVec3(2.20f, 8.0f, 2.0f));
	z2p1ShapeDef.AddMaterial("101000");
	z2p1ShapeDef.SetFilterFlags(ArenaData::ZONE_TRIGGER);
	dataMan->CreateShape(z2p1ShapeDef, "Z2P1Shape");

	MeshRenderComponent* z2p2 = new MeshRenderComponent();
	temp->AttachComponent(z2p2);
	z2p2->LoadModel("ProbendArenaZone2P2.mesh");
	std::shared_ptr<MeshInfo> z2p2MeshInfo = z2p2->GetMeshInfo();
	ShapeDefinition z2p2ShapeDef = ShapeDefinition(true);
	z2p2ShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(z2p2MeshInfo, "Z2P2Mesh"),
		physx::PxVec3(2.0f, 8.0f, 2.0f));
	z2p2ShapeDef.AddMaterial("101000");
	z2p2ShapeDef.SetFilterFlags(ArenaData::ZONE_TRIGGER);
	dataMan->CreateShape(z2p2ShapeDef, "Z2P2Shape");

	//Zone 3 Pieces
	MeshRenderComponent* z3 = new MeshRenderComponent();
	temp->AttachComponent(z3);
	z3->LoadModel("ProbendArenaZone3.mesh");
	std::shared_ptr<MeshInfo> z3MeshInfo = z3->GetMeshInfo();
	ShapeDefinition z3ShapeDef = ShapeDefinition(true);
	z3ShapeDef.SetConvexMeshGeometry(dataMan->CookConvexMesh(z3MeshInfo, "Z3Mesh"),
		physx::PxVec3(2.150f, 8.0f, 2.10f));
	z3ShapeDef.AddMaterial("101000");
	z3ShapeDef.SetFilterFlags(ArenaData::ZONE_TRIGGER);
	dataMan->CreateShape(z3ShapeDef, "Z3Shape");
}
Ejemplo n.º 11
0
void ArenaBuilder::GenerateProbendingArena(IScene* scene)
{
	using namespace physx;

#pragma region Water
	///Create the water plane
	SharedGameObject waterObject = std::make_shared<GameObject>(scene, "WaterPlane");
	MeshRenderComponent* waterMesh = new MeshRenderComponent();
	waterObject->AttachComponent(waterMesh);
	waterMesh->LoadModel("BasicPlane");
	waterMesh->SetMaterial("Examples/Water1");
	RigidBodyComponent* waterRigid = new RigidBodyComponent();
	
	waterObject->AttachComponent(waterRigid);
	Ogre::Quaternion rot = Ogre::Quaternion(Ogre::Radian(Ogre::Degree(90.0f)), Ogre::Vector3(0, 0, 1));
	waterRigid->CreateRigidBody(RigidBodyComponent::STATIC);//, physx::PxVec3(0.0f, -5.0f, 0.0f), physx::PxQuat(rot.x, rot.y, rot.z, rot.w));
	waterRigid->AttachShape("BasicPlane");
	//waterRigid->CreateDebugDraw();

	waterObject->SetWorldTransform(Ogre::Vector3(0.0f, -5.0f, 0.0f), rot, Ogre::Vector3(50.0f, 50.0f, 50.0f));
	waterObject->Start();

	scene->AddGameObject(waterObject);

#pragma endregion

#pragma region ArenaSurface
	SharedGameObject arenaSurface = std::make_shared<GameObject>(scene, "ProbendArenaSurface");
	MeshRenderComponent* arenaSurfaceMesh = new MeshRenderComponent();
	arenaSurface->AttachComponent(arenaSurfaceMesh);
	arenaSurfaceMesh->LoadModel("ProbendArenaSurface.mesh");

	RigidBodyComponent* arenaSurfaceRigid = new RigidBodyComponent();
	arenaSurface->AttachComponent(arenaSurfaceRigid);
	arenaSurfaceRigid->CreateRigidBody(RigidBodyComponent::STATIC);
	arenaSurfaceRigid->AttachShape("ArenaSurfaceShape");
	arenaSurfaceRigid->CreateDebugDraw();

	arenaSurface->Start();
	scene->AddGameObject(arenaSurface);

#pragma endregion

#pragma region Pillars
	//////////////////////PILLARS//////////////////////

	//RL indicates Red Left from Red perspective
	SharedGameObject arenaPillarRL = std::make_shared<GameObject>(scene, "ProbendPillarRL");
	MeshRenderComponent* arenaPillarMesh = new MeshRenderComponent();
	arenaPillarRL->AttachComponent(arenaPillarMesh);
	arenaPillarMesh->LoadModel("ProbendPillar.mesh");

	RigidBodyComponent* arenaPillarRigid = new RigidBodyComponent();
	arenaPillarRL->AttachComponent(arenaPillarRigid);
	arenaPillarRigid->CreateRigidBody(RigidBodyComponent::STATIC);

	arenaPillarRigid->AttachShape("ArenaPillarShape");
	arenaPillarRigid->CreateDebugDraw();

	//Set transform as calculated by Ogitor
	arenaPillarRL->SetWorldTransform(Ogre::Vector3(5.9f, -2.85f, 2.15f), 
		Ogre::Quaternion(0.0f, -0.254602f, 0.0f, 0.967046f), Ogre::Vector3(1.0f));

	arenaPillarRL->Start();
	scene->AddGameObject(arenaPillarRL);

	SharedGameObject arenaPillarRR = arenaPillarRL->Clone(); 
	arenaPillarRR->SetWorldTransform(Ogre::Vector3(5.9f, -2.85f, -2.15f), 
		Ogre::Quaternion(0.0f, 0.258819f, 0.0f, 0.967046f), Ogre::Vector3(1.0f));

	arenaPillarRR->Start();
	scene->AddGameObject(arenaPillarRR);

	SharedGameObject arenaPillarCR = arenaPillarRL->Clone();
	arenaPillarCR->SetWorldTransform(Ogre::Vector3(0.0f, -2.85f, -4.3f), 
		Ogre::Quaternion(0.0f, -0.700909f, 0.0f, 0.71325f), Ogre::Vector3(1.0f));

	arenaPillarCR->Start();
	scene->AddGameObject(arenaPillarCR);

	SharedGameObject arenaPillarCL = arenaPillarRL->Clone();
	arenaPillarCL->SetWorldTransform(Ogre::Vector3(0.0f, -2.85f, 4.3f), 
		Ogre::Quaternion(0.0f, -0.700909f, 0.0f, 0.71325f), Ogre::Vector3(1.0f));

	arenaPillarCL->Start();
	scene->AddGameObject(arenaPillarCL);

	SharedGameObject arenaPillarBR = arenaPillarRL->Clone();
	arenaPillarBR->SetWorldTransform(Ogre::Vector3(-5.9f, -2.85f, -2.15f), 
		Ogre::Quaternion(0.0f, -0.258819f, 0.0f, 0.965926f), Ogre::Vector3(1.0f));

	arenaPillarBR->Start();
	scene->AddGameObject(arenaPillarBR);

	SharedGameObject arenaPillarBL = arenaPillarRL->Clone();
	arenaPillarBL->SetWorldTransform(Ogre::Vector3(-5.9f, -2.85f, 2.15f), 
		Ogre::Quaternion(0.0f, 0.258819f, 0.0f, 0.965926f), Ogre::Vector3(1.0f));

	arenaPillarBL->Start();
	scene->AddGameObject(arenaPillarBL);

	///////////////////END PILLARS///////////////////
#pragma endregion

#pragma region Walls
	
	SharedGameObject leftWall = std::make_shared<GameObject>(scene, "Wall");
	MeshRenderComponent* wallMesh = new MeshRenderComponent();
	leftWall->AttachComponent(wallMesh);
	wallMesh->LoadModel("BasicPlane");
	wallMesh->SetMaterial("StadiumWall");
	Ogre::Radian ninetyDeg = Ogre::Radian(Ogre::Degree(90.0f));
	Ogre::Quaternion leftWallRot = Ogre::Quaternion(ninetyDeg, Ogre::Vector3::UNIT_Y);
	RigidBodyComponent* wallRigid = new RigidBodyComponent();
	leftWall->AttachComponent(wallRigid);
	wallRigid->CreateRigidBody(RigidBodyComponent::STATIC);
	wallRigid->AttachShape("ArenaWallShape1");
	wallRigid->CreateDebugDraw();
	leftWall->SetWorldTransform(Ogre::Vector3(0.0f, 0.0f, 20.0f),leftWallRot, Ogre::Vector3(10.0f, 10.0f, 7.5f));

	leftWall->Start();
	scene->AddGameObject(leftWall);

#pragma endregion
}