Exemple #1
0
void CreateThrusterFlames (CObject *objP)
{
	static int nThrusters = -1;

	CFixVector	pos, dir = objP->info.position.mOrient.FVec ();
	int			d, j;
	tParticleEmitter		*emitterP;

VmVecNegate (&dir);
if (nThrusters < 0) {
	nThrusters =
		particleManager.Create (&objP->info.position.vPos, &dir, objP->info.nSegment, 2, -2000, 20000,
										gameOpts->render.particles.bSyncSizes ? -1 : gameOpts->render.particles.nSize [1],
										2, -2000, PLR_PART_SPEED * 50, LIGHT_PARTICLES, objP->Index (), NULL, 1, -1);
	particleManager.SetObjectSystem (objP->Index ()) = nThrusters;
	}
else
	particleManager.SetDir (nThrusters, &dir);
d = 8 * objP->info.xSize / 40;
for (j = 0; j < 2; j++)
	if (emitterP = GetParticleEmitter (nThrusters, j)) {
		VmVecScaleAdd (&pos, &objP->info.position.vPos, &objP->info.position.mOrient.FVec (), -objP->info.xSize);
		VmVecScaleInc (&pos, &objP->info.position.mOrient.RVec (), j ? d : -d);
		VmVecScaleInc (&pos, &objP->info.position.mOrient.UVec (),  -objP->info.xSize / 25);
		SetParticleEmitterPos (emitterP, &pos, NULL, objP->info.nSegment);
		}
}
// ============================================================================
//	Show the effect at a position (this will spawn the particle emitter if 
//	needed).
//
//	In:		The world-space position of the effect.
//
void CPlayerMindGameBeamEffectSimpleEffect::SetPosition(const Vec3& pos)
{
	IParticleEmitter* emitter = GetParticleEmitter(pos);
	if (emitter == NULL)
	{
		return;
	}

	Matrix34 matrix = Matrix34::CreateTranslationMat(pos);
	emitter->SetMatrix(matrix);
}
Exemple #3
0
void CEntityObject::ReleaseObjects()
{
	if (pStatObj)
	{
		pStatObj->Release();
		pStatObj = NULL;
	}
	else if (pCharacter)
	{
		if (ISkeletonAnim* pSkeletonAnim = pCharacter->GetISkeletonAnim())
			pSkeletonAnim->SetEventCallback(0, 0);

		if (ISkeletonPose* pSkeletonPose = pCharacter->GetISkeletonPose())
			pSkeletonPose->DestroyCharacterPhysics(0);

		pCharacter->Release();
		pCharacter = NULL;
	}
	else if (pLight)
	{
		pLight->ReleaseNode();
		pLight = NULL;
	}
	else if (IParticleEmitter* pEmitter = GetParticleEmitter())
	{
		pEmitter->Activate(false);
		pEmitter->SetEntity(NULL, 0);
		pEmitter->Release();
		pChildRenderNode = 0;
	}
	else if (pChildRenderNode)
	{
		pChildRenderNode->ReleaseNode();
		pChildRenderNode = 0;
	}
	if (pFoliage)
	{
		pFoliage->Release();
		pFoliage = 0;
	}

	//if(m_pRNData)
	//	gEnv->p3DEngine->FreeRNTmpData(&m_pRNData);
	//assert(!m_pRNData);
}
Exemple #4
0
void EngineActions::DuplicateEntity( ECS::Entity* p_entity )
{
	//Create new entity
	ECS::Entity* newEntity = CreateEntity();
	//Set position, scale and rotation of new entity to same as old entity + a little offset in X (to avoid clipping and confusion)
	SetPosition(newEntity, GetPosition(p_entity) + glm::vec3(10, 0, 0));
	SetOrientation(newEntity, GetOrientation(p_entity));
	SetScale(newEntity, GetScale(p_entity));

	//Get all components
	RootForce::Renderable*		renderable		= m_world->GetEntityManager()->GetComponent<RootForce::Renderable>(p_entity);
	RootForce::Physics*			physics			= m_world->GetEntityManager()->GetComponent<RootForce::Physics>(p_entity);
	RootForce::Collision*		collision		= m_world->GetEntityManager()->GetComponent<RootForce::Collision>(p_entity);
	RootForce::Script*			script			= m_world->GetEntityManager()->GetComponent<RootForce::Script>(p_entity);
	RootForce::WaterCollider*	watercollider	= m_world->GetEntityManager()->GetComponent<RootForce::WaterCollider>(p_entity);
	RootForce::ParticleEmitter* particleEmitter = m_world->GetEntityManager()->GetComponent<RootForce::ParticleEmitter>(p_entity);

	//Check if there's a renderable and copy data
	if(renderable != nullptr)
	{
		AddRenderable(newEntity);
		SetRenderableModelName(newEntity, GetRenderableModelName(p_entity));
		SetRenderableMaterialName(newEntity, GetRenderableMaterialName(p_entity));
	}

	//Check if there's a renderable and copy data
	if(collision != nullptr)
	{
		if(physics != nullptr)
		{
			AddPhysics(newEntity, true);
			SetMass(newEntity, GetMass(p_entity));
		}
		else
			AddPhysics(newEntity, false);

		SetPhysicsType(newEntity, GetPhysicsType(p_entity));
		SetPhysicsShape(newEntity, GetPhysicsShape(p_entity));
		SetShapeHeight(newEntity, GetShapeHeight(p_entity));
		SetShapeRadius(newEntity, GetShapeRadius(p_entity));
		SetPhysicsMesh(newEntity, GetPhysicsMesh(p_entity));
		SetCollideWithStatic(newEntity, GetCollideWithStatic(p_entity));
		SetCollideWithWorld(newEntity, GetCollideWithWorld(p_entity));
		SetGravity(newEntity, GetGravity(p_entity));	
	}

	//Check if there's a script and copy data
	if(script != nullptr)
	{
		AddScript(newEntity);
		SetScript(newEntity, GetScript(p_entity));
	}

	//Check if there's a water collider and copy data
	if(watercollider != nullptr)
	{
		AddWaterCollider(newEntity);
		SetWaterColliderInterval(newEntity, GetWaterColliderInterval(p_entity));
		SetWaterColliderPower(newEntity, GetWaterColliderPower(p_entity));
		SetWaterColliderRadius(newEntity, GetWaterColliderRadius(p_entity));
	}

	if(particleEmitter != nullptr)
	{
		AddParticle(newEntity);
		SetParticleEmitter(newEntity, GetParticleEmitter(p_entity));
	}
}