예제 #1
0
///===========================================================================
void CParticleSystemShape::buildFromPS(const CParticleSystem &ps)
{
	// must be sure that we are writting in the stream
	if (_ParticleSystemProto.isReading())
	{
		_ParticleSystemProto.invert();
	}

	// to have const correctness in the prototype, we must do this...
	CParticleSystem *myPs = const_cast<CParticleSystem *>(&ps);
	nlassert(myPs);
	// build the prototype
	_ParticleSystemProto.serialPtr(myPs);

	// mirror some system values
	_MaxViewDist = myPs->getMaxViewDist();
	_DestroyWhenOutOfFrustum = myPs->doesDestroyWhenOutOfFrustum();
	_DestroyModelWhenOutOfRange = myPs->getDestroyModelWhenOutOfRange();
	if (!myPs->getAutoComputeBBox())
	{
		_UsePrecomputedBBox = true;
		myPs->computeBBox(_PrecomputedBBox);
	}
	else
	{
		_UsePrecomputedBBox = false;
	}
	_Sharing = myPs->isSharingEnabled();
}
예제 #2
0
///===========================================================================
void	CParticleSystemShape::render(IDriver *drv, CTransformShape *trans, bool passOpaque)
{
	H_AUTO ( NL3D_Particles_Render );
	nlassert(drv);
	CParticleSystemModel *psm = NLMISC::safe_cast<CParticleSystemModel *>(trans);
	if (psm->_Invalidated) return;
	CParticleSystem *ps = psm->getPS();
	/// has the system been triggered yet ?
	if (!ps) return;

	TAnimationTime delay = psm->getEllapsedTime();
	nlassert(ps->getScene());

	///////////////////////
	// render particles  //
	///////////////////////

	/// if sharing is enabled,  we should resetup the system matrix
	if (ps->isSharingEnabled())
	{
		ps->setSysMat(&(psm->getWorldMatrix()));
		ps->setUserMatrix(&(psm->getUserMatrix()));
	}

	// Setup the matrix.
	/// drv->setupModelMatrix(trans->getWorldMatrix());

	ps->setDriver(drv);
	// draw particle
	PARTICLES_CHECK_MEM;
	if (passOpaque)
	{
		PSLookAtRenderTime = 0;
		//NLMISC::TTicks start = NLMISC::CTime::getPerformanceTime();
		ps->step(CParticleSystem::SolidRender, delay, *this, *psm);
		/*NLMISC::TTicks end = NLMISC::CTime::getPerformanceTime();
		nlinfo("Solid render time time = %.2f", (float) (1000 * NLMISC::CTime::ticksToSecond(end - start)));
		nlinfo("LookAt Render time = %.2f", (float) (1000 * NLMISC::CTime::ticksToSecond(PSLookAtRenderTime)));	*/
	}
	else
	{
		//PSLookAtRenderTime = 0;
		//NLMISC::TTicks start = NLMISC::CTime::getPerformanceTime();
		ps->step(CParticleSystem::BlendRender, delay, *this, *psm);
		/*NLMISC::TTicks end = NLMISC::CTime::getPerformanceTime();
		nlinfo("Blend render time time = %.2f", (float) (1000 * NLMISC::CTime::ticksToSecond(end - start)));
		nlinfo("LookAt Render time = %.2f", (float) (1000 * NLMISC::CTime::ticksToSecond(PSLookAtRenderTime)));	*/
	}
	PARTICLES_CHECK_MEM;
	if (psm->isToolDisplayEnabled())
	{
		ps->step(CParticleSystem::ToolRender, delay, *this, *psm);
		PARTICLES_CHECK_MEM;
	}
}