GameEntity* MyGame::BackFire(Vector3 pos) { GameEntity* g = new MoveSphere(new Cube(), new MoveSpherePhy(Quaternion::AxisAngleToQuaterion(Vector3(0, 1, 0), 90.0f), pos + Vector3(0, 0, 150))); SceneNode* s = &g->GetRenderNode(); PhysicsNode* p = &g->GetPhysicsNode(); Vector3 CamDir = gameCamera->GetCamDir(); s->SetTransform(Matrix4::Translation(Vector3(1, 1, 1)) * Matrix4::Rotation( 90.0f, Vector3(1, 0, 0))); s->SetColour(Vector4(0, 0, 1, 1)); s->type = 1; // For debug boxes. If 1 = debug boxes ON. s->SetBoundingRadius(50); s->SetModelScale(Vector3(10,10,20)); p->SetDimension(s->GetModelScale()); p->SetInverseMass(12.0f); p->SetSphereRadius(50); p->AddForce(-CamDir * 9000); p->SetOrientation(Quaternion::EulerAnglesToQuaternion(gameCamera->GetPitch(), gameCamera->GetYaw(), 0.0)); p->isMissile = true; p->isBackFire = true; g->ConnectToSystems(); return g; }
GameEntity* MyGame::ShotProjectile(float msec){ GameEntity* g = new MoveSphere(new Cube(), new MoveSpherePhy(Quaternion::AxisAngleToQuaterion(Vector3(0, 1, 0), 0.0f),Vector3(100,0,0))); SceneNode* s = &g->GetRenderNode(); PhysicsNode* p = &g->GetPhysicsNode(); Vector3 CamDir = gameCamera->GetCamDir(); s->SetColour(Vector4(0, 0, 1, 1)); s->type = 1; s->SetBoundingRadius(50); s->SetTransform(Matrix4::Translation(Vector3(1, 1, 1)) * Matrix4::Rotation( 270.0f, Vector3(1, 0, 0))); s->SetModelScale(Vector3(10,10,20)); p->SetDimension(s->GetModelScale()); m_speed = m_speed * 1000; p->SetInverseMass(9.0f); p->SetSphereRadius(50); p->AddForce(CamDir * 7000); p->SetPosition(gameCamera->GetPosition()); p->SetOrientation(Quaternion::EulerAnglesToQuaternion(gameCamera->GetPitch(), gameCamera->GetYaw(), 0.0)); p->isMissile = true; g->ConnectToSystems(); return g; }
GameEntity* MyGame::DrawMyAnything() { SceneNode* s = new FirstProjectile(); s->SetModelScale(Vector3(50.0f, 50.0f, 50.0f)); s->SetBoundingRadius(50.0f); PhysicsNode *p = new PhysicsNode(Quaternion::AxisAngleToQuaterion(Vector3(1, 0, 0), 90.0f), Vector3(1,1,1)); GameEntity* g = new GameEntity(s, p); g->ConnectToSystems(); return g; }
/*ANOTHER Quad - In Z - Axis.*/ GameEntity* MyGame::BuildQuadEntity2(float size) { SceneNode* s = new SceneNode(quad); s->SetModelScale(Vector3(size,size,size)); s->SetColour(Vector4(0, 1, 0, 1)); s->SetBoundingRadius(size); PhysicsNode* p = new PhysicsNode(Quaternion::AxisAngleToQuaterion(Vector3(1,0,0), 180.0f), Vector3(1,1,-500)); GameEntity* g = new GameEntity(s, p); p->isPlane = true; g->ConnectToSystems(); return g; }
GameEntity* MyGame::BuildClothEntity() { GameEntity* g = new GameEntity(new SceneNode(RenderCloth), new PhysicsNode()); g->ConnectToSystems(); g->GetRenderNode().useNormal = 0; g->GetRenderNode().SetBoundingRadius(5000.0f); if(g->GetRenderNode().GetMesh()->GetTexture()){ glBindTexture(GL_TEXTURE_2D, g->GetRenderNode().GetMesh()->GetTexture()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glBindTexture(GL_TEXTURE_2D, 0); } g->GetPhysicsNode().addCV(new CollisionSphere(Vector3(0,0,0),0.0f)); g->GetPhysicsNode().gravity = false; return g; }
void TerrainClass::BuildFloorEntity() { for (int i = 0; i < ChunckManager::NUM_VOXEL_CHUNCKS; i++) { SceneNode* sNode = new SceneNode(); sNode->SetMesh(terrain->getMeshAt(i)); sNode->SetModelScale(Vector3(SCALE_TERRAIN, SCALE_TERRAIN, SCALE_TERRAIN)); PhysicsNode* pNode = new PhysicsNode(); pNode->SetPosition(START_TERRAIN_POSITION); pNode->SetLinearVelocity(Vector3(0, 0, linearVelocityZ)); pNode->setLD(false); pNode->setSkyBox(true); terrainPhysicsNodes.push_back(pNode); countTerrainEntities++; GameEntity* geFirst = new GameEntity(sNode, pNode); geFirst->ConnectToSystems(); terrainEntities.push_back(geFirst); //add the id of the chunck just created //terrainChuncksId.push_back(geFirst->getId()); //reset the chunck id to be the same as the entity added; for consistency purposes //terrain->getChunckAt(i)->setId(i); } }