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::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;
}
void MyGame::CreateSphereToCameraPosition()
{
	SceneNode* s = new SceneNode(sphere);
	s->SetRotation(Matrix4::Translation(gameCamera->GetPosition()));
	//s->SetTranslation(Vector3());

	s->SetModelScale(Vector3(SPHERE_INITIAL_SIZE * sizeFactor, SPHERE_INITIAL_SIZE * sizeFactor, SPHERE_INITIAL_SIZE * sizeFactor));
	//s->SetModelScale(Vector3(1000.0f, 1000.0f , 1000.0f));

	s->SetBoundingRadius(SPHERE_INITIAL_SIZE * sizeFactor);
	s->SetColour(Vector4((((int)rand()) % 100) / 100.0f, (((int)rand()) % 100) / 100.0f, (((int)rand()) % 100) / 100.0f, 1.0f));

	GameEntity*g = new GameEntity(s, new SpherePhysicsNode());
	((SpherePhysicsNode&)(g->GetPhysicsNode())).SetRadius(SPHERE_INITIAL_SIZE*sizeFactor);

	g->GetPhysicsNode().SetPosition(gameCamera->GetPosition());

	cout << "sphere created on position " << gameCamera->GetPosition() << endl;

	g->GetPhysicsNode().SetInvMass(SPHERE_INITIAL_INVMASS / sizeFactor);
	Vector3 speedVec = gameCamera->GetViewVector();
	speedVec = speedVec * SPHERE_INITIAL_SPEED * (const float)speedFactor;
	g->GetPhysicsNode().SetLinearVelocity(speedVec);
	g->GetPhysicsNode().SetGravityFactor(EARTH_GRAVITY_FACTOR);
	g->GetPhysicsNode().ActivateNode();

	g->GetPhysicsNode().BuildInertiaMatrix();
	g->ConnectToSystems();
	allEntities.push_back(g);
}
Renderer::Renderer(Window &parent) : OGLRenderer(parent) {
	CubeRobot::CreateCube();
	projMatrix = Matrix4::Perspective(1.0f, 10000.0f, (float)width/(float)height, 45.0f);
	camera = new Camera();
	camera->SetPosition(Vector3(0, 100, 750.0f));

	currentShader = new Shader("../../Shaders/SceneVertex.glsl", "../../Shaders/SceneFragment.glsl");
	quad = Mesh::GenerateQuad();
	quad->SetTexture(SOIL_load_OGL_texture("../../Textures/stainedglass.tga", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, 0));

	if (!currentShader->LinkProgram() || !quad->GetTexture()){
		return;
	}
	
	root = new SceneNode();

	for (int i = 0; i < 5; ++i){
		SceneNode* s = new SceneNode();
		s->SetColour(Vector4(1.0f, 1.0f, 1.0f, 0.5f));
		s->SetTransform(Matrix4::Translation(Vector3(0,100.0f, -300.0f + 100.0f + 100 * i)));
		s->SetModelScale(Vector3(100.0f, 100.0f, 100.0f));
		s->SetBoundingRadius(100.0f);
		s->SetMesh(quad);
		root->AddChild(s);
	}

	root->AddChild(new CubeRobot());

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	init = true;
}
Exemple #5
0
void GSAvatarMod::CheckAvailable()
{
  SceneNode* node = GetGuiSceneGraph()->GetRootNode(SceneGraph::AMJU_OPAQUE);
  GuiButton* ok = (GuiButton*)GetElementByName(m_gui, "ok-button");
 
  if (m_current >= m_howManyCharsAvailable)
  {
    if (node)
    {
      node->SetColour(Colour(0.5f, 0.5f, 0.5f, 0.5f));
      ok->SetIsEnabled(false);
    }
  }
  else
  {
    if (node)
    {
      node->SetColour(Colour(1, 1, 1, 1));
      ok->SetIsEnabled(true);
    }
  }
}
/*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;
}
Exemple #7
0
/*
Makes a sphere.
*/
GameEntity* MyGame::BuildSphereEntity(float radius, Vector3 pos, Vector3 vel) {
	SceneNode* s = new SceneNode(sphere);

	s->SetModelScale(Vector3(radius,radius,radius));
	s->SetBoundingRadius(radius);
	s->SetColour(Vector4(0.2,0.2,0.5,1));
	PhysicsNode*p = new PhysicsNode();
	p->SetPosition(pos);
	p->SetLinearVelocity(vel);
	p->SetAngularVelocity(Vector3(0,0,0.01f));
	p->SetInverseInertia(InertialMatrixHelper::createSphereInvInertial(1.0f, radius));
	p->SetInverseMass(1.0f);
	p->SetCollisionVolume(new CollisionSphere(radius));
	GameEntity*g = new GameEntity(s, p);
	g->ConnectToSystems();
	return g;
}
void MyGame::BuildDodgingEntities(float size, Vector3& initialPosition)
{
	SceneNode* s = new SceneNode(sphere);

	s->SetColour(Vector4(1.0f, 1.0f, 1.0f, 1.0f));

	s->SetRotation(Matrix4::Translation(initialPosition));

	s->SetModelScale(Vector3(size, size, size));
	s->SetBoundingRadius(size);
	
	SpherePhysicsNode* g = new SpherePhysicsNode();
	g->SetRadius(size);
	g->SetPosition(initialPosition);
	g->SetGravityFactor(NON_GRAVITY);
	float massFactor = size / SPHERE_INITIAL_SIZE;
	g->SetInvMass(SPHERE_INITIAL_INVMASS / massFactor);
	g->ActivateNode();
	g->BuildInertiaMatrix();
	g->SetTarget(s);
	g->dumpingFactor = 0.9f;
	Renderer::GetRenderer().AddNode(s);
	PhysicsSystem::GetPhysicsSystem().SetDodgingEntity(g);
}
Exemple #9
0
void MyGame::BuildSprings() {
	
	float radius = 50.0f;
	int nrt = 7;
	int n= nrt*nrt;
	float space = 40.0f;
	float mass = 2.0f;
	float ks = 5.0f; //5.0
	float kd = 0.99f;

	cloth = new PhysicsCloth(7, 7);
	
	//CHANGE THIS EVERYTIME YOU CHANGE NRT
	SpringNode* springmesh[7][7];
	vector<GameEntity*> gv;
	vector<Spring*> s;
	for(int i = 0; i < n; i++) {
		SceneNode* rn = new SceneNode();

		rn->SetModelScale(Vector3(radius,radius,radius));
		rn->SetBoundingRadius(radius);
		rn->SetColour(Vector4(1.0f,1.0f,1.0f,1.0f));

		
		float temp = (1.0) / ((0.2f) * (2 * mass * radius * radius));
		SpringNode* sn = new SpringNode(Vector3(space * (i%nrt), 1000.0f,space*(i/nrt)));
		springmesh[i%nrt][i/nrt] = sn;
		sn->SetInvInertia(temp);
		sn->setInvMass(mass);
		sn->addCV(new CollisionSphere(Vector3(0,0,0),radius));
		sn->dynamic = true;
		sn->sleep = false;
		
		//FOR CONTAINER EFFECT 
		//if(i == 0 || i == nrt-1 || i == n -1 || i == n - nrt) sn->fixed = true;
		if(i == 0 || i == nrt-1 ) sn->fixed = true;

		GameEntity*g = new GameEntity(rn, sn);
		g->ConnectToSystems();
		gv.push_back(g);
		cloth->nodes.push_back(sn);
		
		//allEntities.push_back(g);
	}
	int c = 0;
	/*
	vector<GameEntity*>::iterator i2 = gv.begin();
	i2++;
	for(vector<GameEntity*>::iterator i = gv.begin(); i2!= gv.end(); i++, i2++) {
		c++;
		
		Spring* s = new Spring(
			(SpringNode*)&(*i)->GetPhysicsNode(),(*i)->GetPhysicsNode().GetPosition(),
			(SpringNode*)&(*i2)->GetPhysicsNode(),(*i)->GetPhysicsNode().GetPosition()
			);
		 //0.6f
		//s->m_length = 50.0f;

		//if(i==gv.begin()) ((SpringNode*)&(*i)->GetPhysicsNode())->fixed = true;
		//if(i==gv.end()-1) ((SpringNode*)&(*i)->GetPhysicsNode())->fixed = true;
		((SpringNode*)&(*i)->GetPhysicsNode())->AddSpring(s);
		if(i2!=gv.end())
		((SpringNode*)&(*i2)->GetPhysicsNode())->AddSpring(s);
	}
	*/
	for(int x = 0; x < nrt; x++) {
		for(int y = 0; y< nrt; y++) {
			Spring* s;
			
			if(y!=nrt-1){
				s = new Spring(
					springmesh[x][y],
					springmesh[x][y]->GetPosition(),
					springmesh[x][y+1],
					springmesh[x][y+1]->GetPosition());

					s->m_ks = ks;
					s->m_kd = kd;

					springmesh[x][y]->AddSpring(s);
					springmesh[x][y+1]->AddSpring(s);
					springs.push_back(s);
					PhysicsSystem::GetPhysicsSystem().AddSpring(s);
			}
			if(x!=nrt-1) {
				s = new Spring(
					springmesh[x][y],
					springmesh[x][y]->GetPosition(),
					springmesh[x+1][y],
					springmesh[x+1][y]->GetPosition());

				s->m_ks = ks;
				s->m_kd = kd;

				springmesh[x][y]->AddSpring(s);
				springmesh[x+1][y]->AddSpring(s);
				springs.push_back(s);
				PhysicsSystem::GetPhysicsSystem().AddSpring(s);
			}
			if(x!=nrt-1 && y!=nrt-1) {
				s = new Spring(
					springmesh[x][y],
					springmesh[x][y]->GetPosition(),
					springmesh[x+1][y+1],
					springmesh[x+1][y+1]->GetPosition());

				s->m_ks = ks;
				s->m_kd = kd;

				springmesh[x][y]->AddSpring(s);
				springmesh[x+1][y+1]->AddSpring(s);
				springs.push_back(s);
				PhysicsSystem::GetPhysicsSystem().AddSpring(s);
			}
		}
	}
	clothEntities = gv;
	
}