Beispiel #1
0
void World::UpdateParticle(float dt)
{
	//Animation *a = FindAnimation("splineAnime");
//vec3 p = a->GetCurrentPosition(dt);
//Collision *c = new Collision();
//bool isC = c->emitParticle(p);
if (dt==0){

Billboard *b = new Billboard();
b->size  = glm::vec2(2.0, 2.0);
b->position = glm::vec3(0.0, 3.0, 0.0);
b->color = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);

Billboard *b2 = new Billboard();
b2->size  = glm::vec2(2.0, 2.0);
b2->position = glm::vec3(0.0, 3.0, 1.0);
b2->color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);

mpBillboardList->AddBillboard(b);
mpBillboardList->AddBillboard(b2);


ParticleDescriptor* fountainDescriptor = new ParticleDescriptor();
fountainDescriptor->SetFireDescriptor();

ParticleDescriptor* fireDescriptor = new ParticleDescriptor();
fireDescriptor->SetFireDescriptor();

ParticleEmitter* emitter = new ParticleEmitter(vec3(0.0f, 0.0f, 0.0f));

ParticleSystem* ps = new ParticleSystem(emitter, fountainDescriptor);
AddParticleSystem(ps);
}
}
FireModel::FireModel() :Model()
{

    ParticleDescriptor* desc = new ParticleDescriptor();
    desc->SetFireDescriptor();

    // @blenkz - need to pass a model (which this fire is) for parenting
    ParticleEmitter* emitter = new ParticleEmitter(mPosition, this);

    // @blenkz - the model class has a variable for particle systems.
    // Its destructor will remove the system from the world and then delete it.
    mParticleSystem = new ParticleSystem(emitter, desc);
    World::GetInstance()->AddParticleSystem(mParticleSystem);
}
Beispiel #3
0
bool Model::ParseLine(const std::vector<ci_string> &token){
  if (token.empty() == false){
    if (token[0].empty() == false && token[0][0] == '#')
      return true;
    else if (token[0] == "name"){
      assert(token.size() > 2);
      assert(token[1] == "=");
      
      mName = token[2];
    }
    else if (token[0] == "position"){
      assert(token.size() > 4);
      assert(token[1] == "=");
      
      mPosition.x = static_cast<float>(atof(token[2].c_str()));
      mPosition.y = static_cast<float>(atof(token[3].c_str()));
      mPosition.z = static_cast<float>(atof(token[4].c_str()));
    }
    else if (token[0] == "rotation"){
      assert(token.size() > 4);
      assert(token[1] == "=");
      
      mRotationAxis.x = static_cast<float>(atof(token[2].c_str()));
      mRotationAxis.y = static_cast<float>(atof(token[3].c_str()));
      mRotationAxis.z = static_cast<float>(atof(token[4].c_str()));
      mRotationAngleInDegrees = static_cast<float>(atof(token[5].c_str()));
      
      glm::normalize(mRotationAxis);
    }
    else if (token[0] == "scaling"){
      assert(token.size() > 4);
      assert(token[1] == "=");
      
      mScaling.x = static_cast<float>(atof(token[2].c_str()));
      mScaling.y = static_cast<float>(atof(token[3].c_str()));
      mScaling.z = static_cast<float>(atof(token[4].c_str()));
    }
    else if (token[0] == "animation"){
      assert(token.size() > 2);
      assert(token[1] == "=");
      
      ci_string animName = token[2];
      
      mAnimation = World::GetInstance()->FindAnimation(animName);
    }
    else if (token[0] == "particlesystem"){
      assert(token.size() > 2);
      assert(token[1] == "=");
      assert(token[2] == "\"snow\"" || token[2] == "\"fountain\""); // only to hardcoded particle systems
      
      
      ParticleEmitter* emitter = new ParticleEmitter(vec3(0.0f, 0.0f, 0.0f), this);
      ParticleDescriptor* desc = new ParticleDescriptor();
      
      if (token[2] == "\"snow\"")
        desc->SetSnowDescriptor();
      else if (token[2] == "\"fountain\"")
        desc->SetFountainDescriptor();
      
      mParticleSystem = new ParticleSystem(emitter, desc);
      World::GetInstance()->AddParticleSystem(mParticleSystem);
    }
    else
      return false;
  }
  
  return true;
}
Beispiel #4
0
bool Model::ParseLine(const std::vector<ci_string> &token)
{
		if (token.empty() == false)
	{
		if (token[0].empty() == false && token[0][0] == '#')
		{
			return true;
		}
		else if (token[0] == "name")
		{
			assert(token.size() > 2);
			assert(token[1] == "=");

			mName = token[2];	
		}
		else if (token[0] == "physics"){
			assert(token.size() > 2);
			assert(token[1] == "=");

			auto physics_type = token[2];

			if (physics_type == "none"){
				mPhysicsType = None;
			}
			else if (physics_type == "dynamic"){
				mPhysicsType = Dynamic;
			}
			else if (physics_type == "static"){
				mPhysicsType = Static;
			}
			else if (physics_type == "kinematic"){
				mPhysicsType = Kinematic;
			}
			else{
				assert(!"physics type invalid!");
			}

		}
		else if (token[0] == "position")
		{
			assert(token.size() > 4);
			assert(token[1] == "=");

			mPosition.x = static_cast<float>(atof(token[2].c_str()));
			mPosition.y = static_cast<float>(atof(token[3].c_str()));
			mPosition.z = static_cast<float>(atof(token[4].c_str()));
		}
		else if (token[0] == "rotation")
		{
			assert(token.size() > 4);
			assert(token[1] == "=");

			mRotationAxis.x = static_cast<float>(atof(token[2].c_str()));
			mRotationAxis.y = static_cast<float>(atof(token[3].c_str()));
			mRotationAxis.z = static_cast<float>(atof(token[4].c_str()));
			mRotationAngleInDegrees = static_cast<float>(atof(token[5].c_str()));

			glm::normalize(mRotationAxis);
		}
		else if (token[0] == "scaling")
		{
			assert(token.size() > 4);
			assert(token[1] == "=");

			mScaling.x = static_cast<float>(atof(token[2].c_str()));
			mScaling.y = static_cast<float>(atof(token[3].c_str()));
			mScaling.z = static_cast<float>(atof(token[4].c_str()));
		}
		else if (token[0] == "animation")
		{
			assert(token.size() > 2);
			assert(token[1] == "=");

			ci_string animName = token[2];
            
            mAnimation = World::GetInstance()->FindAnimation(animName);
		}
        else if (token[0] == "particlesystem")
        {
			assert(token.size() > 2);
			assert(token[1] == "=");
			assert(token[2] == "\"fire\"" || token[2] == "\"fountain\""); // only to hardcoded particle systems


			ParticleEmitter* emitter;
			ParticleDescriptor* desc;

			if (token[2] == "\"fire\"")
			{
				emitter = new ParticleEmitter(vec3(-15.5f, 0.75f, 0.0f), this); //move fire
				desc = new ParticleDescriptor();
				desc->SetFireDescriptor();
			}
			else if (token[2] == "\"fountain\"")
			{
				emitter = new ParticleEmitter(vec3(-15.5f, 8.0f, 0.0f), this);//move smoke
				desc = new ParticleDescriptor();
				desc->SetFountainDescriptor();
			}

			mParticleSystem = new ParticleSystem(emitter, desc);
			World::GetInstance()->AddParticleSystem(mParticleSystem);
        }
		else
		{
			return false;
		}
	}

	return true;
}
Beispiel #5
0
World::World()
{
	instance = this;


	this->spaceship = new Spaceship();
	this->spaceship->SetScaling(vec3(1.0f, 1.0f, 1.0f));
	mModel.push_back(this->spaceship);

	//setup enemy spaceship 1
	this->enemySpaceship1 = new Spaceship();
	this->enemySpaceship1->SetPosition(vec3(7.0f, 7.0f, 7.0f));
	this->enemySpaceship1->SetVelocity(vec3(-3.0f, 0.0f, 0.0f));
	this->enemySpaceship1->SetMaxCapacity(10);
	mModel.push_back(this->enemySpaceship1);

	//setup sphere model 1
#if defined(PLATFORM_OSX)
	this->sphere1 = new SphereModel(TextureLoader::LoadTexture("Textures\\asteroidTexture.jpg"));
#else
	this->sphere1 = new SphereModel(TextureLoader::LoadTexture("..\\Assets\\Textures\\asteroidTexture.jpg"));
#endif
	this->sphere1->SetPosition(vec3(5.0f, 5.0f, -20.0f));
	this->sphere1->SetVelocity(vec3(1.0f, 0.0f, 0.0f));

	this->emitter = new ParticleEmitter(vec3(0.0f, 0.0f, 0.0f), this->sphere1);
	this->desc = new ParticleDescriptor();

	desc->SetFireDescriptor();

	this->particleSystem = new ParticleSystem(emitter, desc);
	AddParticleSystem(this->particleSystem);

	mModel.push_back(this->sphere1);

	//setup sphere model 2
#if defined(PLATFORM_OSX)
	this->sphere2 = new SphereModel(TextureLoader::LoadTexture("Textures\\asteroidTexture.jpg"));
#else
	this->sphere2 = new SphereModel(TextureLoader::LoadTexture("..\\Assets\\Textures\\asteroidTexture.jpg"));
#endif
	this->sphere2->SetPosition(vec3(5.0f, 5.0f, -20.0f));
	this->sphere2->SetVelocity(vec3(0.0f, 0.0f, 1.0f));

	this->emitter = new ParticleEmitter(vec3(0.0f, 0.0f, 0.0f), this->sphere2);
	this->desc = new ParticleDescriptor();

	desc->SetFireDescriptor();

	this->particleSystem = new ParticleSystem(emitter, desc);
	AddParticleSystem(this->particleSystem);

	mModel.push_back(this->sphere2);



#if defined(PLATFORM_OSX)
	this->skybox = new Skybox(vec3(100.0f, 100.0f, 100.0f), "Textures\\skyboxPositiveX.png", "Textures\\skyboxNegativeX.png", "Textures\\skyboxPositiveY.png", "Textures\\skyboxNegativeY.png", "Textures\\skyboxPositiveZ.png", "Textures\\skyboxNegativeZ.png");
#else
	this->skybox = new Skybox(vec3(100.0f, 100.0f, 100.0f), "..\\Assets\\Textures\\skyboxPositiveX.png", "..\\Assets\\Textures\\skyboxNegativeX.png", "..\\Assets\\Textures\\skyboxPositiveY.png", "..\\Assets\\Textures\\skyboxNegativeY.png", "..\\Assets\\Textures\\skyboxPositiveZ.png", "..\\Assets\\Textures\\skyboxNegativeZ.png");
#endif

	// Setup Camera
	mCamera.push_back(new ThirdPersonCamera(vec3(3.0f, 1.0f, 5.0f), this->spaceship, 5.0f));

	thirdCam = new ThirdPersonCamera(vec3(3.0f, 1.0f, 5.0f), spaceship);
	thirdCam->SetCinematic(true);
	thirdCam->SetCinematicRadius(6.0f);
	mCamera.push_back(thirdCam);

	mCamera.push_back(new FirstPersonCamera(vec3(3.0f, 1.0f, 5.0f)));
	mCamera.push_back(new StaticCamera(vec3(3.0f, 30.0f, 5.0f), vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f)));
	mCamera.push_back(new StaticCamera(vec3(0.5f, 0.5f, 5.0f), vec3(0.0f, 0.5f, 0.0f), vec3(0.0f, 1.0f, 0.0f)));
	mCamera.push_back(new StaticCamera(vec3(0.0f, 50.0f, 0.0f), vec3(0.0f, 0.5f, 0.0f), vec3(0.0f, 1.0f, 0.0f)));
	mCurrentCamera = 0;

#if defined(PLATFORM_OSX)
	int billboardTextureID = TextureLoader::LoadTexture("Textures/Particle.png");
#else
	int billboardTextureID = TextureLoader::LoadTexture("../Assets/Textures/Particle.png");
#endif
	assert(billboardTextureID != 0);

	mpBillboardList = new BillboardList(2048, billboardTextureID);

	ParticleDescriptor* asteroidDescriptor = new ParticleDescriptor();
	asteroidDescriptor->SetAsteroidDescriptor();

	ParticleEmitter* emitter = new ParticleEmitter(vec3(0.0f, 0.0f, 0.0f));

	mAsteroidSystem = new AsteroidSystem(emitter, asteroidDescriptor);
	mSolarSystem = new SolarSystem();
}