Ejemplo n.º 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);
}
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 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] == "\"fire\"" || 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] == "\"fire\"")
                desc->SetFireDescriptor();
            else if (token[2] == "\"fountain\"")
                desc->SetFountainDescriptor();
            
            mParticleSystem = new ParticleSystem(emitter, desc);
            World::GetInstance()->AddParticleSystem(mParticleSystem);
        }
		else
			return false;
	}

	return true;
}
Ejemplo n.º 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;
}