Пример #1
0
// ***************************************************************************
void			CMaterial::flushTextures (IDriver &driver, uint selectedTexture)
{
	// For each textures
	for (uint tex=0; tex<IDRV_MAT_MAXTEXTURES; tex++)
	{
		// Texture exist ?
		if (_Textures[tex])
		{
			// Select the good texture
			_Textures[tex]->selectTexture (selectedTexture);

			// Force setup texture
			driver.setupTexture (*_Textures[tex]);
		}
	}

	// If Lightmap material
	if(_ShaderType==LightMap)
	{
		// For each lightmap
		for (uint lmap=0; lmap<_LightMaps.size(); lmap++)
		{
			// Texture exist?
			if(_LightMaps[lmap].Texture)
			{
				// Force setup texture
				driver.setupTexture (*_LightMaps[lmap].Texture);
			}
		}
	}

}
Пример #2
0
int _tmain1(int argc, _TCHAR* argv[])
{
    //Client
    IDriver* pMyDriver = new BenzDriver();
    ISportCar* pMyCar = pMyDriver->SportCarDriver();
    pMyCar->run();

    getchar();
	return 0;
}
Пример #3
0
void WaterManager::Render( IDriver& driver, TerrainManager* world )
{
	if( m_isRender )
	{
		RenderTarget* now = driver.PopRenderTarget( );
		driver.PushRenderTarget( m_Refraction );
		driver.Clear( IDriver::COLOR_BUFFER | IDriver::DEPTH_BUFFER | IDriver::STENCIL_BUFFER );
		world->Render( driver );
		driver.PopRenderTarget( );
		driver.PushRenderTarget( now );
	}
}
Пример #4
0
//*******************************************************************************
void CWaterEnvMap::update(TGlobalAnimationTime time, IDriver &driver)
{
	if (_LastRenderTime == time) return;
	_LastRenderTime = time;
	// First five updates are used to render the cubemap faces (bottom face is not rendered)
	// Sixth update project the cubemap into a 2D texture
	uint numTexToRender;
	if (_UpdateTime > 0)
	{
		uint64 currRenderTick = (uint64) (time / (_UpdateTime / (NUM_FACES_TO_RENDER + 1)));
		numTexToRender = (uint) (currRenderTick - _LastRenderTick);
		_LastRenderTick = currRenderTick;
	}
	else
	{
		numTexToRender = NUM_FACES_TO_RENDER + 1;
	}
	if (!numTexToRender) return;
	if (_NumRenderedFaces == 0)
	{
		_StartRenderTime = time;
	}
	uint lastCubeFacesToRender = std::min((uint) NUM_FACES_TO_RENDER, _NumRenderedFaces + numTexToRender); // we don't render negative Z (only top hemisphere is used)
	for(uint k = _NumRenderedFaces; k < lastCubeFacesToRender; ++k)
	{
		driver.setRenderTarget(_EnvCubic, 0, 0, _EnvCubicSize, _EnvCubicSize, 0, (uint32) k);
		render((CTextureCube::TFace) k, _StartRenderTime);
	}
	_NumRenderedFaces = lastCubeFacesToRender;
	if (_NumRenderedFaces == NUM_FACES_TO_RENDER && (_NumRenderedFaces + numTexToRender) > NUM_FACES_TO_RENDER)
	{
		// render to 2D map
		driver.setRenderTarget(_Env2D, 0, 0, _Env2DSize, _Env2DSize);
		doInit();
		//
		driver.activeVertexProgram(NULL);
		driver.activeVertexBuffer(_FlattenVB);
		driver.activeIndexBuffer(_FlattenIB);
		driver.setFrustum(-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, false);
		driver.setupViewMatrix(CMatrix::Identity);
		CMatrix mat;
		//mat.scale(0.8f);
		driver.setupModelMatrix(mat);
		_MaterialPassThru.setTexture(0, _EnvCubic);
		_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, _Alpha));
		driver.renderTriangles(_MaterialPassThru, 0, FVB_NUM_TRIS);
		_NumRenderedFaces = 0; // start to render again
	}
	driver.setRenderTarget(NULL);
}
Пример #5
0
//*******************************************************************************
void CWaterEnvMap::renderTestMesh(IDriver &driver)
{
	doInit();
	CMaterial testMat;
	testMat.setLighting(false);
	testMat.texEnvOpRGB(0, CMaterial::Modulate);
	testMat.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
	testMat.texEnvArg0RGB(1, CMaterial::Diffuse, CMaterial::SrcColor);
	testMat.texEnvOpAlpha(0, CMaterial::Replace);
	testMat.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
	testMat.texConstantColor(0, CRGBA(255, 255, 255, 255));
	testMat.setDoubleSided(true);
	testMat.setZWrite(false);
	testMat.setZFunc(CMaterial::always);
	// tmp : test cubemap
	driver.activeVertexProgram(&testMeshVP);
	driver.activeVertexBuffer(_TestVB);
	driver.activeIndexBuffer(_TestIB);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity); // tmp
	_MaterialPassThruZTest.setTexture(0, _EnvCubic);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
	driver.setConstant(4, 2.f, 1.f, 0.f, 0.f);
	//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
	driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
	driver.activeVertexProgram(NULL);
}
Пример #6
0
//-------------------------------------------------------------------------------------------------------
void WaterManager::OnBeginUpdate( IDriver& driver )
{
	m_isRender = false;
	Frustumf frustum = driver.GetCamera().GetFrustum();
	for ( WaterMeshes::iterator it = m_WaterDatas.begin();
		it != m_WaterDatas.end();
		it ++ )
	{
		if( frustum.Intersect( (*it)->BindBox() ) )
		{
			m_isRender = true;
			if( m_LastTileIndex != (*it)->GetIndex() )
			{
				m_LastTileIndex = (*it)->GetIndex();
				m_MiddleHeight = (*it)->GetWaterParameter().get_float( p_fWaterBaseHeight );
				m_pWater->WaterSurface( (*it)->GetMaterial(), (*it)->GetWaterParameter() );
			}
			break;
		}
	}
	if( m_isRender )
	{
		m_pWater->OnBeginUpdate( driver );
	}
}
Пример #7
0
void WaterManager::Render( IDriver& driver )
{
	if( m_isRender )
	{
		driver.GetPipeline().MakeCopyScreen();
		m_pWater->Render( driver );
	}
}
Пример #8
0
//++ ------------------------------------------------------------------------------------
// Details:	Unregister all the Driver registered with *this manager. The manager also
//			deletes
// Type:	Method.
// Args:	None.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMIDriverMgr::UnregisterDriverAll( void )
{
	MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin();
	while( it != m_mapDriverIdToDriver.end() )
	{
		IDriver * pDriver = (*it).second;
		pDriver->DoShutdown();
		
		// Next
		++it;
	}

	m_mapDriverIdToDriver.clear();
	m_pDriverCurrent = NULL;

	return MIstatus::success;
}
Пример #9
0
//++ ------------------------------------------------------------------------------------
// Details:	Register a driver with *this Driver Manager. Call SetUseThisDriverToDoWork()
//			inform the manager which driver is the one to the work. The manager calls
//			the driver's init function which must be successful in order to complete the
//			registration.
// Type:	Method.
// Args:	vrDriver	- (R) The driver to register.
//			vrDriverID	- (R) The driver's ID to lookup by.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMIDriverMgr::RegisterDriver( const IDriver & vrDriver, const CMIUtilString & vrDriverID )
{
	if( HaveDriverAlready( vrDriver ) )
		return MIstatus::success;

	IDriver * pDriver = const_cast< IDriver * >( &vrDriver );
	if( !pDriver->SetId( vrDriverID ) )
		return MIstatus::failure;
	if( !pDriver->DoInitialize() )
	{
		SetErrorDescriptionn( MIRSRC( IDS_DRIVERMGR_DRIVER_ERR_INIT ), pDriver->GetName().c_str(), vrDriverID.c_str(), pDriver->GetError().c_str() );
		return MIstatus::failure;
	}

	MapPairDriverIdToDriver_t pr( vrDriverID, pDriver );
	m_mapDriverIdToDriver.insert( pr );

	return MIstatus::success;
}
Пример #10
0
//++ ------------------------------------------------------------------------------------
// Details:	Search the registered drivers and return the first driver which says it is
//			not GDB/MI compatible i.e. the LLDB Driver class.
// Type:	Method.
// Args:	None. 
// Return:	IDriver * - Ptr to driver, NULL = no driver found.
// Throws:	None.
//--
CMIDriverMgr::IDriver * CMIDriverMgr::GetFirstNonMIDriver( void ) const
{
	IDriver * pDriver = nullptr;
	MapDriverIdToDriver_t::const_iterator it = m_mapDriverIdToDriver.begin();
	while( it != m_mapDriverIdToDriver.end() )
	{
		const CMIUtilString & rDrvId = (*it).first; MIunused( rDrvId );
		IDriver * pDvr = (*it).second;
		if( !pDvr->GetDriverIsGDBMICompatibleDriver() )
		{
			pDriver = pDvr;
			break;
		}

		// Next
		++it;
	}

	return pDriver;
}
Пример #11
0
//***************************************************************************************************************
void				CFlareShape::flushTextures (IDriver &driver, uint selectedTexture)
{
	// Flush each texture
	for (uint tex=0; tex<MaxFlareNum; tex++)
	{
		if (_Tex[tex] != NULL)
		{
			// Select the good texture
			_Tex[tex]->selectTexture (selectedTexture);

			// Flush texture
			driver.setupTexture (*_Tex[tex]);
		}
	}
}
Пример #12
0
// ***************************************************************************
bool CMaterial::isSupportedByDriver(IDriver &drv, bool forceBaseCaps) const
{
	uint numTexStages = drv.getNbTextureStages();
	// special case for radeon : though 3 stages are supported, do as if there were only 2, because of the texEnvColor feature
	// not managed in Direct3D : emulation is provided, but for no more than 2 constants (and if diffuse is not used)
	if (numTexStages == 3) numTexStages = 2;
	if (forceBaseCaps) numTexStages = std::min(numTexStages, (uint) 2);
	switch(getShader())
	{
		case Normal:
		{
			if (getNumUsedTextureStages() > numTexStages) return false;
			// see if each tex env is supported
			for(uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
			{
				if (getTexture(k))
				{
					switch(getTexEnvOpRGB(k))
					{
						case InterpolateConstant: if (!drv.supportBlendConstantColor()) return false;
						case EMBM:				  if (forceBaseCaps || !drv.supportEMBM() || !drv.isEMBMSupportedAtStage(k)) return false;
						case Mad:				  if (!drv.supportMADOperator()) return false;
						default: break;
					}
					switch(getTexEnvOpAlpha(k))
					{
						case InterpolateConstant: if (!drv.supportBlendConstantColor()) return false;
						case EMBM:				  if (forceBaseCaps || !drv.supportEMBM() || !drv.isEMBMSupportedAtStage(k)) return false;
						case Mad:				  if (!drv.supportMADOperator()) return false;
						default: break;
					}
				}
			}
			return true;
		}
		break;
		case Bump:					return false; // not impl.
		case UserColor:				return true;
		case LightMap:				return true;
		case Specular:				return true;
		case Caustics:				return false;
		case PerPixelLighting:		 return drv.supportPerPixelLighting(true);
		case PerPixelLightingNoSpec: return drv.supportPerPixelLighting(false);
		case Cloud:					return true;
		case Water:					return true;
		default:
			nlassert(0); // unknown shader, must complete
	}
	return false;
}
Пример #13
0
//*******************************************************************************
void CWaterEnvMap::init(uint cubeMapSize, uint projection2DSize, TGlobalAnimationTime updateTime, IDriver &driver)
{
	// Allocate cube map
	// a cubic texture with no sharing allowed
	class CTextureCubeUnshared : public CTextureCube
	{
	public:
		virtual bool supportSharing() const {return false;}
		virtual uint32 getWidth(uint32 numMipMap = 0) const
		{
			nlassert(numMipMap == 0);
			return Size;
		}
		virtual uint32 getHeight(uint32 numMipMap = 0) const
		{
			nlassert(numMipMap == 0);
			return Size;
		}
		uint32 Size;
	};
	// a 2D testure
	class CTexture2DUnshared : public CTextureBlank
	{
	public:
		virtual bool supportSharing() const {return false;}
		virtual uint32 getWidth(uint32 numMipMap = 0) const
		{
			nlassert(numMipMap == 0);
			return Size;
		}
		virtual uint32 getHeight(uint32 numMipMap = 0) const
		{
			nlassert(numMipMap == 0);
			return Size;
		}
		uint32 Size;
	};
	nlassert(cubeMapSize > 0);
	nlassert(NLMISC::isPowerOf2(cubeMapSize));
	nlassert(projection2DSize > 0);
	nlassert(NLMISC::isPowerOf2(projection2DSize));
	CTextureCubeUnshared *envCubic = new CTextureCubeUnshared;
	_EnvCubic = envCubic;
	_EnvCubic->setRenderTarget(true); // we will render to the texture
	_EnvCubic->setWrapS(ITexture::Clamp);
	_EnvCubic->setWrapT(ITexture::Clamp);
	_EnvCubic->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
	CTexture2DUnshared *tb = new CTexture2DUnshared;
	tb->resize(cubeMapSize, cubeMapSize); // Unfortunately,  must allocate memory in order for the driver to figure out the size
	                                      // that it needs to allocate for the texture, though its datas are never used (it is a render target)
	tb->Size = cubeMapSize;
	tb->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
	for(uint k = 0; k < 6; ++k)
	{
		_EnvCubic->setTexture((CTextureCube::TFace) k, tb);
		_EnvCubic->getTexture((CTextureCube::TFace) k)->setRenderTarget(true);
	}
	envCubic->Size = cubeMapSize;
	// setup the texture to force the driver to allocate vram for it
	driver.setupTexture(*_EnvCubic);
	tb->reset();
	// Allocate projection 2D map
	CTexture2DUnshared *env2D = new CTexture2DUnshared;
	_Env2D = env2D;
	_Env2D->resize(projection2DSize, projection2DSize);
	env2D->Size = projection2DSize;
	_Env2D->setWrapS(ITexture::Clamp);
	_Env2D->setWrapT(ITexture::Clamp);
	_Env2D->setRenderTarget(true); // we will render to the texture
	_Env2D->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
	driver.setupTexture(*_Env2D); // allocate vram
	_Env2D->reset();
	_UpdateTime = updateTime;
	_LastRenderTime = -1;
	invalidate();
	_NumRenderedFaces = 0;
	_EnvCubicSize = cubeMapSize;
	_Env2DSize = projection2DSize;
}
Пример #14
0
// TMP TMP
void tempDumpColPolys()
{
	CPackedWorld *pw = R2::getEditor().getIslandCollision().getPackedIsland();
	if (pw)
	{
		static CMaterial material;
		static CMaterial wiredMaterial;
		static CMaterial texturedMaterial;
		static CVertexBuffer vb;
		static bool initDone = false;
		if (!initDone)
		{
			vb.setVertexFormat(CVertexBuffer::PositionFlag);
			vb.setPreferredMemory(CVertexBuffer::AGPVolatile, false);
			material.initUnlit();
			material.setDoubleSided(true);
			material.setZFunc(CMaterial::lessequal);
			wiredMaterial.initUnlit();
			wiredMaterial.setDoubleSided(true);
			wiredMaterial.setZFunc(CMaterial::lessequal);
			wiredMaterial.setColor(CRGBA(255, 255, 255, 250));
			wiredMaterial.texEnvOpAlpha(0, CMaterial::Replace);
			wiredMaterial.texEnvArg0Alpha(0, CMaterial::Diffuse, CMaterial::SrcAlpha);
			wiredMaterial.setBlend(true);
			wiredMaterial.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
			texturedMaterial.initUnlit();
			texturedMaterial.setDoubleSided(true);
			texturedMaterial.setZFunc(CMaterial::lessequal);
			initDone = true;
		}
		// just add a projected texture
		R2::getEditor().getIslandCollision().loadEntryPoints();
		R2::CScenarioEntryPoints &sep = R2::CScenarioEntryPoints::getInstance();
		CVectorD playerPos = UserEntity->pos();
		R2::CScenarioEntryPoints::CCompleteIsland *island = sep.getCompleteIslandFromCoords(CVector2f((float) playerPos.x, (float) playerPos.y));
		static CSString currIsland;
		if (island && island->Island != currIsland)
		{
			currIsland = island->Island;
			CTextureFile *newTex = new CTextureFile(currIsland + "_sp.tga");
			newTex->setWrapS(ITexture::Clamp);
			newTex->setWrapT(ITexture::Clamp);
			texturedMaterial.setTexture(0, newTex);
			texturedMaterial.texEnvOpRGB(0, CMaterial::Replace);
			texturedMaterial.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
			texturedMaterial.setTexCoordGen(0, true);
			texturedMaterial.setTexCoordGenMode(0, CMaterial::TexCoordGenObjectSpace);
			CMatrix mat;
			CVector scale((float) (island->XMax -  island->XMin),
						  (float) (island->YMax -  island->YMin), 0.f);
			scale.x = 1.f / favoid0(scale.x);
			scale.y = 1.f / favoid0(scale.y);
			scale.z = 0.f;
			mat.setScale(scale);
			mat.setPos(CVector(- island->XMin * scale.x, - island->YMin * scale.y, 0.f));
			//
			CMatrix uvScaleMat;
			//
			uint texWidth = (uint) (island->XMax -  island->XMin);
			uint texHeight = (uint) (island->YMax -  island->YMin);
			float UScale = (float) texWidth / 	raiseToNextPowerOf2(texWidth);
			float VScale = (float) texHeight / raiseToNextPowerOf2(texHeight);
			//
			uvScaleMat.setScale(CVector(UScale, - VScale, 0.f));
			uvScaleMat.setPos(CVector(0.f, VScale, 0.f));
			//
			texturedMaterial.enableUserTexMat(0, true);
			texturedMaterial.setUserTexMat(0, uvScaleMat * mat);
		}
		const CFrustum &frust = MainCam.getFrustum();

		//
		IDriver *driver = ((CDriverUser  *) Driver)->getDriver();

		driver->enableFog(true);
		const CRGBA clearColor = CRGBA(0, 0, 127, 0);
		driver->setupFog(frust.Far * 0.8f, frust.Far, clearColor);
		CViewport vp;
		vp.init(0.f, 0.f, 1.f, 1.f);
		driver->setupViewport(vp);
		CScissor scissor;
		viewportToScissor(vp, scissor);
		driver->setupScissor(scissor);
		//
		driver->setFrustum(frust.Left, frust.Right, frust.Bottom, frust.Top, frust.Near, frust.Far, frust.Perspective);
		driver->setupViewMatrix(MainCam.getMatrix().inverted());
		driver->setupModelMatrix(CMatrix::Identity);
		//
		//
		const CVector localFrustCorners[8] =
		{
			CVector(frust.Left, frust.Near, frust.Top),
			CVector(frust.Right, frust.Near, frust.Top),
			CVector(frust.Right, frust.Near, frust.Bottom),
			CVector(frust.Left, frust.Near, frust.Bottom),
			CVector(frust.Left  * frust.Far / frust.Near, frust.Far, frust.Top * frust.Far / frust.Near),
			CVector(frust.Right * frust.Far / frust.Near, frust.Far, frust.Top * frust.Far / frust.Near),
			CVector(frust.Right * frust.Far / frust.Near, frust.Far, frust.Bottom * frust.Far / frust.Near),
			CVector(frust.Left  * frust.Far / frust.Near, frust.Far, frust.Bottom * frust.Far / frust.Near)
		};
		// roughly compute covered zones
		//
		/*
		sint frustZoneMinX = INT_MAX;
		sint frustZoneMaxX = INT_MIN;
		sint frustZoneMinY = INT_MAX;
		sint frustZoneMaxY = INT_MIN;
		for(uint k = 0; k < sizeofarray(localFrustCorners); ++k)
		{
			CVector corner = camMat * localFrustCorners[k];
			sint zoneX = (sint) (corner.x / 160.f) - zoneMinX;
			sint zoneY = (sint) floorf(corner.y / 160.f) - zoneMinY;
			frustZoneMinX = std::min(frustZoneMinX, zoneX);
			frustZoneMinY = std::min(frustZoneMinY, zoneY);
			frustZoneMaxX = std::max(frustZoneMaxX, zoneX);
			frustZoneMaxY = std::max(frustZoneMaxY, zoneY);
		}
		*/

		const uint TRI_BATCH_SIZE = 10000; // batch size for rendering
		static std::vector<TPackedZoneBaseSPtr> zones;
		zones.clear();
		pw->getZones(zones);
		for(uint k = 0; k < zones.size(); ++k)
		{
			zones[k]->render(vb, *driver, texturedMaterial, wiredMaterial, MainCam.getMatrix(), TRI_BATCH_SIZE, localFrustCorners);
		}
	}
}
Пример #15
0
//-------------------------------------------------------------------------------------------------------
void BloomPS::Process(IDriver& driver, const RenderTarget* const org, const RenderTarget* const scene, RenderTarget* const out, bool& isSwitch)
{
	float Range = 2; //控制模糊度

	//降采样
	//driver.PushRenderTarget(m_pDownSimple_1);
	//driver.Clear( IDriver::COLOR_BUFFER );
	//QuadShader& qs = driver.GetShaderManage().GetShader<QuadShader>(ShaderManage::QuadShader);
	//driver.Draw( *m_pRendBuffer, qs, scene->GetColorBuffer() );
	//driver.PopRenderTarget();

	//流明化
	driver.PushRenderTarget(m_pDownSimple_1);
	driver.Clear( IDriver::COLOR_BUFFER );
	Luminance& le = driver.GetShaderManage().GetShader<Luminance>(ShaderManage::Luminance);
	driver.Draw( *m_pRendBuffer, le, scene->GetColorBuffer() );
	driver.PopRenderTarget();

	//x方向模糊
	driver.PushRenderTarget(m_pDownSimple_2);
	driver.Clear( IDriver::COLOR_BUFFER );
	Gaussian& gauss = driver.GetShaderManage().GetShader<Gaussian>(ShaderManage::Gaussian);
	gauss.SetParamStep( vector2f( Range / m_pDownSimple_1->GetSize().m_x, 0.0f ) );
	driver.Draw( *m_pRendBuffer, gauss, m_pDownSimple_1->GetColorBuffer() );
	driver.PopRenderTarget();

	//y方向模糊
	driver.PushRenderTarget(m_pDownSimple_1);
	driver.Clear( IDriver::COLOR_BUFFER );
	gauss.SetParamStep( vector2f( 0.0f, Range / m_pDownSimple_2->GetSize().m_y ) );
	driver.Draw( *m_pRendBuffer, gauss, m_pDownSimple_2->GetColorBuffer() );
	driver.PopRenderTarget();

	driver.PushRenderTarget( out );//如果画在了输出上面,则需要更换输出,下一个pe就用另外一张rt
	isSwitch = true;
	driver.Clear( IDriver::COLOR_BUFFER );
	//if( 0 )
	{
		driver.EnableAlphaBlend(IDriver::BL_SRC_ALPHA, IDriver::BL_ONE_MINUS_SRC_ALPHA, IDriver::BL_SRC_ALPHA, IDriver::BL_ONE_MINUS_SRC_ALPHA );
		Combine& ce = driver.GetShaderManage().GetShader<Combine>(ShaderManage::Combine);
		ce.SetParamOrginial( scene->GetColorBuffer() );
		ce.SetParamSecen( m_pDownSimple_1->GetColorBuffer() );
		ce.SetParamOrginialWeight(1.0f);
		ce.SetParamSecenWeight(0.0f);//was 0.75
		driver.Draw( *m_pRendBuffer, ce, NULL );
	}
	//else
	//{
	//	QuadShader& qs = driver.GetShaderManage().GetShader<QuadShader>(ShaderManage::QuadShader);
	//	driver.Draw( *m_pRendBuffer, qs, m_pDownSimple_1->GetColorBuffer() );
	//	//driver.Draw( *m_pRendBuffer, ui, org->GetDepthBuffer() );
	//}
	driver.PopRenderTarget( );
}
Пример #16
0
void CExportNel::buildScene (NL3D::CScene &scene, NL3D::CShapeBank &shapeBank, IDriver &driver, TimeValue tvTime, 
							 NL3D::CLandscape *landscape, IProgress *progress, bool buildHidden, 
							 bool onlySelected, bool buildLods)
{
	// Register classes
	// done in dllentry registerSerial3d ();

	CScene::registerBasics ();

	// Get node count
	int nNumNode=_Ip->GetRootNode ()->NumberOfChildren ();
	int nNbMesh=0;

	// *******************
	// * Then, build Mesh shapes
	// *******************

	// Prepare ig export.
	std::vector<INode*>						igVectNode;
	std::map<std::string, NL3D::IShape *>	igShapeMap;

	// SunDirection.
	NLMISC::CVector							igSunDirection(0, 1, -1);

	// SunColor.
	NLMISC::CRGBA							igSunColor(255, 255, 255);
	SLightBuild								sgLightBuild;

	// Build Mesh Shapes.
	_Options.FeedBack = progress;
	nNbMesh = 0;

	// View all selected objects
	int nNode;
	for (nNode=0; nNode<nNumNode; nNode++)
	{
		// Get the node
		INode* pNode=_Ip->GetRootNode ()->GetChildNode (nNode);
		if ( (!pNode->IsHidden () || buildHidden) && (pNode->Selected () || !onlySelected) )
		{
			string sTmp = "Object Name: ";
			sTmp += pNode->GetName();
			if (progress)
				progress->setLine (0, sTmp);
			sTmp = "";
			for (uint32 i = 1; i < 10; ++i) 
			{
				if (progress)
					progress->setLine (i, sTmp);
			}
			sTmp = "Last Error";
			if (progress)
			{
				progress->setLine (10, sTmp);
				progress->update();
			}
			
			// It is a zone ?
			if (RPO::isZone (*pNode, tvTime) && landscape)
			{
				// Get a Object pointer
				ObjectState os=pNode->EvalWorldState(_Ip->GetTime()); 

				// Ok ?
				if (os.obj)
				{
					// Convert in 3ds NeL patch mesh
					RPO *tri = (RPO *) os.obj->ConvertToType(_Ip->GetTime(), RYKOLPATCHOBJ_CLASS_ID);
					if (tri)
					{
						CZone zone;
						CZoneSymmetrisation	sym;
						static int zoneId = 0;
						if (tri->rpatch->exportZone (pNode, &tri->patch, zone, sym, zoneId++, 160, 1, false))
							landscape->addZone (zone);
					}
				}
			}
			// Try to export a mesh
			else if (CExportNel::isMesh (*pNode, tvTime))
			{
				// Build skined ?
				bool skined=false;
				++nNbMesh;
				
				// Skinning ?
				if (CExportNel::isSkin (*pNode))
				{
					// todo: skinning export
				}
				
				// Build skined ?
				if (!skined)
				{
					// Is it an accelerator ?
					if ((CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_ACCEL, 32)&3) == 0)
					{
						// Export the shape
						IShape *pShape = NULL;
						pShape=buildShape (*pNode, tvTime, NULL, buildLods);

						// Export successful ?
						if (pShape)
						{
							// get the nelObjectName, as used in building of the instanceGroup.
							std::string	nelObjectName= CExportNel::getNelObjectName(*pNode);

							// ugly way to verify the shape is really added to the sahepBank: use a refPtr :)
							NLMISC::CRefPtr<IShape>		prefShape= pShape;


							std::string nelObjectNameNoExt;
							// Add to the view, but don't create the instance (created in ig).						
							if (!(nelObjectName.find(".shape") != std::string::npos || nelObjectName.find(".ps") != std::string::npos))
							{
								nelObjectNameNoExt = nelObjectName;
								nelObjectName += ".shape";							
							}
							else
							{
								std::string::size_type pos = nelObjectName.find(".");
								nlassert(pos != std::string::npos);
								nelObjectNameNoExt = std::string(nelObjectName, 0, pos);
							}
							
							// Add to the view, but don't create the instance (created in ig).
							// Since IG use strlwr version of the name, must strlwr it here.
							std::string	nelObjectNameLwr = nelObjectName;
							strlwr(nelObjectNameLwr);
							shapeBank.add (nelObjectNameLwr.c_str(), CSmartPtr<IShape> (pShape));
							scene.createInstance (nelObjectNameLwr.c_str());

							// If the shape is not destroyed in addMesh() (with smarPtr), then add it to the shape map.
							if(prefShape)
							{
								igShapeMap.insert( std::make_pair(nelObjectNameNoExt, pShape) );
							}
							
							// Add to list of node for IgExport.
							igVectNode.push_back(pNode);
						}
					}
				}
			}
		}
	}

	// if ExportLighting, Export all lights in scene (not only selected ones).
	if(_Options.bExportLighting)
	{
		// List all nodes in scene.
		vector<INode*>	nodeList;
		getObjectNodes(nodeList, tvTime);
		
		// For all of them.
		for(uint i=0;i<nodeList.size();i++)
		{
			INode	*pNode= nodeList[i];

			if( sgLightBuild.canConvertFromMaxLight(pNode, tvTime) )
			{
				// Convert it.
				sgLightBuild.convertFromMaxLight(pNode, tvTime);

				// PointLight/SpotLight/AmbientLight ??
				if(sgLightBuild.Type != SLightBuild::LightDir)
				{
					// Add to list of node for IgExport.
					igVectNode.push_back(pNode);
				}
				// "SunLight" ??
				else if( sgLightBuild.Type == SLightBuild::LightDir )
				{
					// if this light is checked to export as Sun Light
					int		nExportSun= CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_EXPORT_AS_SUN_LIGHT, BST_UNCHECKED);
					if(nExportSun== BST_CHECKED)
					{
						// Add to list of node for IgExport (enabling SunLight in the ig)
						igVectNode.push_back(pNode);

						// Replace sun Direciton.
						igSunDirection= sgLightBuild.Direction;
						// Replace sun Color.
						igSunColor= sgLightBuild.Diffuse;
					}
				}
			}
		}
	}

	_Options.FeedBack = NULL;


	// *******************
	// * Export instance Group.
	// *******************

	// Info for lighting: retrieverBank and globalRetriever.
	CIgLighterLib::CSurfaceLightingInfo		slInfo;
	slInfo.RetrieverBank= NULL;
	slInfo.GlobalRetriever= NULL;

	// Result instance group
	vector<INode*> resultInstanceNode;

	// Build the ig (with pointLights)
	NL3D::CInstanceGroup	*ig= buildInstanceGroup(igVectNode, resultInstanceNode, tvTime);
	if(ig)
	{
		// If ExportLighting
		if( _Options.bExportLighting )
		{
			// Light the ig.
			NL3D::CInstanceGroup	*igOut= new NL3D::CInstanceGroup;
			// Init the lighter.
			CMaxInstanceLighter		maxInstanceLighter;
			maxInstanceLighter.initMaxLighter(*_Ip);

			// Setup LightDesc Ig.
			CInstanceLighter::CLightDesc	lightDesc;
			// Copy map to get info on shapes.
			lightDesc.UserShapeMap= igShapeMap;
			// Setup Shadow and overSampling.
			lightDesc.Shadow= _Options.bShadow;
			lightDesc.OverSampling= NLMISC::raiseToNextPowerOf2(_Options.nOverSampling);
			clamp(lightDesc.OverSampling, 0U, 32U);
			if(lightDesc.OverSampling==1)
				lightDesc.OverSampling= 0;
			// Setup LightDirection.
			lightDesc.LightDirection= igSunDirection.normed();
			// For interiors ig, disable Sun contrib according to ig.
			lightDesc.DisableSunContribution= !ig->getRealTimeSunContribution();


			// If View SurfaceLighting enabled
			if(_Options.bTestSurfaceLighting)
			{
				// Setup a CSurfaceLightingInfo
				slInfo.CellSurfaceLightSize= _Options.SurfaceLightingCellSize;
				NLMISC::clamp(slInfo.CellSurfaceLightSize, 0.001f, 1000000.f);
				slInfo.CellRaytraceDeltaZ= _Options.SurfaceLightingDeltaZ;
				slInfo.ColIdentifierPrefix= "col_";
				slInfo.ColIdentifierSuffix= "_";
			}


			// Light Ig.
			CIgLighterLib::lightIg(maxInstanceLighter, *ig, *igOut, lightDesc, slInfo, "");

			// Close the lighter.
			maxInstanceLighter.closeMaxLighter();

			// Swap pointer and release unlighted one.
			swap(ig, igOut);
			delete igOut;
		}
	
		// Add all models to the scene		
		ig->addToScene(scene, &driver);

		// Unfreeze all objects from HRC.
		ig->unfreezeHRC();
	}

	// *******************
	// * Launch
	// *******************

	// ExportLighting?
	if ( _Options.bExportLighting )
	{
		// Take the ambient of the scene as the ambient of the sun.
		CRGBA	sunAmb= getAmbientColor (tvTime);

		// Disable Global ambient light
		driver.setAmbientColor (CRGBA::Black);
		scene.setAmbientGlobal(CRGBA::Black);

		// setup lighting and sun, if any light added. Else use std OpenGL front lighting
		scene.enableLightingSystem(true);

		// Setup sun.
		scene.setSunAmbient(sunAmb);
		scene.setSunDiffuse(igSunColor);
		scene.setSunSpecular(igSunColor);
		scene.setSunDirection(igSunDirection);
	}
	else
	{
		/*
		// Setup ambient light
		driver.setAmbientColor (getAmbientColor (tvTime));
		scene.setAmbientGlobal (getAmbientColor (tvTime));

		// Build light vector
		std::vector<CLight> vectLight;
		getLights (vectLight, tvTime);

		// Light in the scene ?
		if (!vectLight.empty())
		{
			// Use old Driver Light mgt.
			scene.enableLightingSystem(false);
			scene.setSunAmbient(CRGBA::Black);
			scene.setSunDiffuse(igSunColor);
			scene.setSunSpecular(igSunColor);
			scene.setSunDirection(igSunDirection);

			// Insert each lights
			for (uint light=0; light<vectLight.size(); light++)
			{
				driver.enableLight (light);
				driver.setLight (light, vectLight[light]);
			}
		}
		*/
	}

	_Options.FeedBack = NULL;
}
Пример #17
0
void CFXAA::applyEffect()
{
	if (!m_PP)
		return;

	CDriverUser *dru = static_cast<CDriverUser *>(m_Driver);
	IDriver *drv = dru->getDriver();

	// backup
	bool fogEnabled = m_Driver->fogEnabled();
	m_Driver->enableFog(false);

	NL3D::ITexture *renderTarget = drv->getRenderTarget();
	nlassert(renderTarget);
	nlassert(renderTarget->isBloomTexture());

	uint width = renderTarget->getWidth();
	uint height = renderTarget->getHeight();
	bool mode2D = static_cast<CTextureBloom *>(renderTarget)->isMode2D();
	nlassert(renderTarget->getUploadFormat() == ITexture::Auto);

	float fwidth = (float)width;
	float fheight = (float)height;
	float pwidth = 1.0f / fwidth;
	float pheight = 1.0f / fheight;
	float hpwidth = pwidth * 0.5f;
	float hpheight = pheight * 0.5f;
	float n = 0.5f;

	//if (width != m_Width || height != m_Height)
	/*{
		// Build VB
		m_Width = width;
		m_Height = height;
		CVertexBufferReadWrite vba;
		m_VB.lock(vba);
		vba.setValueFloat3Ex(CVertexBuffer::Position, 0, 0.f, 0.f, 0.5f); // BL
		vba.setValueFloat3Ex(CVertexBuffer::Position, 1, 1.f, 0.f, 0.5f); // BR
		vba.setValueFloat3Ex(CVertexBuffer::Position, 2, 1.f, 1.f, 0.5f); // TR
		vba.setValueFloat3Ex(CVertexBuffer::Position, 3, 0.f, 1.f, 0.5f); // TL
		vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 0, 0.f, 0.f);
		vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 1, 1.f, 0.f);
		vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 2, 1.f, 1.f);
		vba.setValueFloat2Ex(CVertexBuffer::TexCoord0, 3, 0.f, 1.f);
		vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 0, 0.f - hpwidth, 0.f - hpheight, 0.f + hpwidth, 0.f + hpheight);
		vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 1, 1.f - hpwidth, 0.f - hpheight, 1.f + hpwidth, 0.f + hpheight);
		vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 2, 1.f - hpwidth, 1.f - hpheight, 1.f + hpwidth, 1.f + hpheight);
		vba.setValueFloat4Ex(CVertexBuffer::TexCoord1, 3, 0.f - hpwidth, 1.f - hpheight, 0.f + hpwidth, 1.f + hpheight);
	}*/

	// create render target
	CTextureUser *otherRenderTarget = m_Driver->getRenderTargetManager().getRenderTarget(width, height, mode2D);

	// swap render target
	CTextureUser texNull;
	dru->setRenderTarget(texNull);
	drv->swapTextureHandle(*renderTarget, *otherRenderTarget->getITexture());
	drv->setRenderTarget(renderTarget);
	m_Driver->setMatrixMode2D11();

	// debug
	// m_Driver->clearBuffers(CRGBA(128, 128, 128, 128));

	// activate program
	bool vpok = drv->activeVertexProgram(m_VP);
	nlassert(vpok);
	bool ppok = drv->activePixelProgram(m_PP);
	nlassert(ppok);
	/*drv->setUniform4f(IDriver::PixelProgram, 0, -n / fwidth, -n / fheight, n / fwidth, n / fheight); // fxaaConsoleRcpFrameOpt
	drv->setUniform4f(IDriver::PixelProgram, 1, -2.0f / fwidth, -2.0f / fheight, 2.0f / fwidth, 2.0f / fheight); // fxaaConsoleRcpFrameOpt2*/
	drv->setUniform2f(IDriver::PixelProgram, 0, 1.0f / fwidth, 1.0f / fheight); // fxaaQualityRcpFrame
	drv->setUniform1f(IDriver::PixelProgram, 1, 0.75f); // fxaaQualitySubpix
	drv->setUniform1f(IDriver::PixelProgram, 2, 0.166f); // fxaaQualityEdgeThreshold
	drv->setUniform1f(IDriver::PixelProgram, 3, 0.0833f); // fxaaQualityEdgeThresholdMin
	drv->setUniformMatrix(IDriver::VertexProgram, 0, IDriver::ModelViewProjection, IDriver::Identity);
	// drv->setUniform4f(IDriver::VertexProgram, 9, -hpwidth, -hpheight, hpwidth, hpheight);

	// render effect
	m_Mat.getObjectPtr()->setTexture(0, otherRenderTarget->getITexture());
	/*drv->activeVertexBuffer(m_VB);
	drv->renderRawQuads(*m_Mat.getObjectPtr(), 0, 1);*/
	m_Driver->drawQuad(m_QuadUV, m_Mat);
	m_Mat.getObjectPtr()->setTexture(0, NULL);

	// deactivate program
	drv->activeVertexProgram(NULL);
	drv->activePixelProgram(NULL);

	// restore
	m_Driver->enableFog(fogEnabled);

	// recycle render target
	m_Driver->getRenderTargetManager().recycleRenderTarget(otherRenderTarget);
}
Пример #18
0
///===========================================================================
void CParticleSystemShape::flushTextures(IDriver &driver, uint selectedTexture)
{
	// if textures are already flushed, no-op
	if (!_CachedTex.empty()) return;
	if (_SharedSystem)
	{
		_SharedSystem->enumTexs(_CachedTex, driver);
	}
	else
	{
		s_PSSMutex.enter();

		// must create an instance just to flush the textures
		CParticleSystem *myInstance = NULL;

		#ifdef PS_FAST_ALLOC
			nlassert(PSBlockAllocator == NULL);
			NLMISC::CContiguousBlockAllocator blockAllocator;
			PSBlockAllocator = &blockAllocator;
			blockAllocator.init(300000); // we release memory just after, and we don't want to fragment the memory, so provide large enough mem
		#endif
		// serialize from the memory stream
		if (!_ParticleSystemProto.isReading()) // we must be sure that we are reading the stream
		{
			_ParticleSystemProto.invert();
		}
		_ParticleSystemProto.resetPtrTable();
		_ParticleSystemProto.seek(0, NLMISC::IStream::begin);
		_ParticleSystemProto.serialPtr(myInstance); // instanciate the system
		#ifdef PS_FAST_ALLOC
			_NumBytesWanted = blockAllocator.getNumAllocatedBytes(); // next allocation will be fast because we know how much memory to allocate
		#endif
		myInstance->enumTexs(_CachedTex, driver);
		// tmp
		/*
		#ifdef NL_DEBUG
			for(uint k = 0; k < myInstance->getNbProcess(); ++k)
			{
				CPSLocated *loc = (CPSLocated *) myInstance->getProcess(k);
				for(uint l = 0; l < loc->getNbBoundObjects(); ++l)
				{
					if (dynamic_cast<CPSCentralGravity *>(loc->getBoundObject(l)))
					{
						nlwarning("PS %s uses central gravity", myInstance->getName().c_str());
						break;
					}
				}
			}
		#endif */
		// sort the process inside the fx
		myInstance->getSortingByEmitterPrecedence(_ProcessOrder);
		delete myInstance;
		#ifdef PS_FAST_ALLOC
			PSBlockAllocator = NULL;
		#endif
		s_PSSMutex.leave();
	}
	for(uint k = 0; k < _CachedTex.size(); ++k)
	{
		//nlinfo(_CachedTex[k]->getShareName().c_str());
		if (_CachedTex[k])
		{
			_CachedTex[k]->setTextureCategory(CPSTextureCategory::get());
			driver.setupTexture(*_CachedTex[k]);
		}
	}
}
Пример #19
0
int main()
{
  FILE *ofile = fopen("/tmp/KeyboardDriverProxyTests.out", "w");

  if (!ofile) {
    Service::Panic((char *)NAME, (char *)strerror(errno), errno);
    return errno;
  }

  IDriver *proxy = new DriverProxy();

  int ret = proxy->Open("MockKeyboardDriver", 123);
  fprintf(ofile, "Open returned: %d\n", ret);

  ret = proxy->Close();
  fprintf(ofile, "Close returned: %d\n", ret);

  unsigned char buffer[BUFFER_SIZE];
  ret = proxy->Read(0, BUFFER_SIZE, buffer);
  fprintf(ofile, "Read returned: %d\n", ret);
  fprintf(ofile, "Read data: ");
  for (unsigned i = 0; i < BUFFER_SIZE; ++i) {
    fprintf(ofile, "0x%X ", buffer[i]);
  }
  fprintf(ofile, "\n");

  ret = proxy->IOControl(KEYBOARD_IOCTL_CLEAR_DATA, NULL);
  fprintf(ofile, "IOControl returned: %d\n", ret);

  ret = proxy->Gather(0, 0, NULL);
  fprintf(ofile, "Gather returned: %d\n", ret);

  ret = proxy->Scatter(0, 0, NULL);
  fprintf(ofile, "Scatter returned: %d\n", ret);

  ret = proxy->Cancel();
  fprintf(ofile, "Cancel returned: %d\n", ret);

  buffer[0] = static_cast<unsigned char>(0);

  // Wait for service to be terminated.
  while (1) {
    // Here we will continue to ask driver to flip keyboard activity for us.
    ret = proxy->Write(0, 1, buffer);
    fprintf(ofile, "Write returned: %d\n", ret);
    buffer[0] = !buffer[0];
    if (fflush(ofile) < 0) {
      Service::Panic((char *)NAME, (char *)strerror(errno), errno);
      return errno;
    }
    sleep(900);
  }

  if (fclose(ofile) < 0) {
    Service::Panic((char *)NAME, (char *)strerror(errno), errno);
    return errno;
  }

  delete proxy;

  return 0;
}
Пример #20
0
int main ()
{
  printf ("Results of render_targets1_test:\n");
  
  try
  {
    ViewPtr view [4];
    
    {    
      Test           test (L"OpenGL device test first window (render_targets1)");
      syslib::Window window (syslib::WindowStyle_Overlapped, 400, 200);
      
      window.SetTitle (L"OpenGL device test second window (render_targets1)");
      
      SwapChainDesc swap_chain_desc;
      
      test.swap_chain->GetDesc (swap_chain_desc);
      
      swap_chain_desc.window_handle = window.Handle ();
      
      IAdapter* adapter = test.swap_chain->GetAdapter ();
      IDriver*  driver  = DriverManager::FindDriver ("DX11");
      
      if (!driver || !adapter)
      {
        printf ("Wrong DX11 driver configuration\n");
        return 0;
      }      

      SwapChainPtr swap_chain (driver->CreateSwapChain (test.device.get (), swap_chain_desc), false);
      
      TexturePtr texture [4] = {
        TexturePtr (test.device->CreateRenderTargetTexture (test.swap_chain.get (), 0), false),
        TexturePtr (test.device->CreateDepthStencilTexture (test.swap_chain.get ()), false),
        TexturePtr (test.device->CreateRenderTargetTexture (swap_chain.get (), 0), false),
        TexturePtr (test.device->CreateDepthStencilTexture (swap_chain.get ()), false)
      };    
      
      ViewDesc view_desc;

      memset (&view_desc, 0, sizeof (view_desc));

      view_desc.layer     = 0;
      view_desc.mip_level = 0;

      for (int i=0; i<4; i++)
        view [i] = ViewPtr (test.device->CreateView (texture [i].get (), view_desc), false);

      test.device->GetImmediateContext ()->OSSetRenderTargetView (0, view [Window1_RenderTarget].get ());
      test.device->GetImmediateContext ()->OSSetDepthStencilView (view [Window2_DepthStencil].get ());

      Color4f clear_color;
      
      clear_color.red   = 0;
      clear_color.green = 0.7f;
      clear_color.blue  = 0.7f;
      clear_color.alpha = 0;

      size_t rt_index = 0;

      test.device->GetImmediateContext ()->ClearViews (ClearFlag_All, 1, &rt_index, &clear_color, 0.5f, 12);
      test.device->GetImmediateContext ()->Draw (PrimitiveType_PointList, 0, 0);

      test.swap_chain->Present ();      
      swap_chain->Present ();
    }
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }
  
  return 0;
}
Пример #21
0
// ***************************************************************************
void	CScene::endPartRender(bool keepTrav)
{
	nlassert(_IsRendering);
	_IsRendering = false;

	if (!keepTrav)
	{
		// Delete model deleted during the rendering
		uint i;
		for (i=0; i<_ToDelete.size(); i++)
			deleteModel (_ToDelete[i]);
		_ToDelete.clear ();

		// Special for SkeletonSpawnScript animation. create models spawned now
		flushSSSModelRequests();

		// Particle system handling (remove the resources of those which are too far, as their clusters may not have been parsed).
		// Note that only a few of them are tested at each call
		_ParticleSystemManager.refreshModels(ClipTrav.WorldFrustumPyramid, ClipTrav.CamPos);

		// Waiting Instance handling
		double deltaT = _DeltaSystemTimeBetweenRender;
		clamp (deltaT, 0.01, 0.1);
		updateWaitingInstances(deltaT);
	}

	// Reset profiling
	_NextRenderProfile= false;

	IDriver *drv = getDriver();
	drv->activeVertexProgram(NULL);
	drv->activePixelProgram(NULL);
	drv->activeGeometryProgram(NULL);

	// Ensure nothing animates on subsequent renders
	_EllapsedTime = 0.f;

	/*
	uint64 total = PSStatsRegisterPSModelObserver +
				  PSStatsRemovePSModelObserver +
				  PSStatsUpdateOpacityInfos +
				  PSStatsUpdateLightingInfos +
				  PSStatsGetAABBox +
				  PSStatsReallocRsc +
				  PSStatsReleasePSPointer +
				  PSStatsRefreshRscDeletion +
				  PSStatsReleaseRsc +
				  PSStatsReleaseRscAndInvalidate +
				  PSStatsGetNumTriangles +
				  PSStatsCheckAgainstPyramid +
				  PSStatsTraverseAnimDetail +
				  PSStatsDoAnimate +
				  PSStatsTraverseRender +
				  PSStatsTraverseClip +
				  PSStatsCheckDestroyCondition +
				  PSStatsForceInstanciate +
				  PSStatsDoAnimatePart1 +
				  PSStatsDoAnimatePart2 +
				  PSStatsDoAnimatePart3 +
				  PSStatsTraverseAnimDetailPart1 +
				  PSStatsTraverseAnimDetailPart2 +
				  PSStatsTraverseAnimDetailPart3 +
				  PSStatsTraverseAnimDetailPart4 +
				  PSAnim1 +
				  PSAnim2+
				  PSAnim3+
				  PSAnim4+
				  PSAnim5+
				  PSAnim6+
				  PSAnim7+
				  PSAnim8+
				  PSAnim9+
				  PSAnim10+
				  PSAnim11;


	 if (((double) total / (double) NLMISC::CSystemInfo::getProcessorFrequency()) > 0.01)
	 {
		  nlinfo("***** PS STATS ****");
		  #define PS_STATS(var) \
		  nlinfo("time for " #var " = %.2f", (float) (1000 * ((double) var / (double) CSystemInfo::getProcessorFrequency())));

		  PS_STATS(PSStatsRegisterPSModelObserver)
		  PS_STATS(PSStatsRemovePSModelObserver)
		  PS_STATS(PSStatsUpdateOpacityInfos)
		  PS_STATS(PSStatsUpdateLightingInfos)
		  PS_STATS(PSStatsGetAABBox)
		  PS_STATS(PSStatsReallocRsc)
		  PS_STATS(PSStatsReleasePSPointer)
		  PS_STATS(PSStatsRefreshRscDeletion)
		  PS_STATS(PSStatsReleaseRsc)
		  PS_STATS(PSStatsReleaseRscAndInvalidate)
		  PS_STATS(PSStatsGetNumTriangles)
		  PS_STATS(PSStatsCheckAgainstPyramid)
		  PS_STATS(PSStatsTraverseAnimDetail)
		  PS_STATS(PSStatsDoAnimate)
		  PS_STATS(PSStatsTraverseRender)
		  PS_STATS(PSStatsTraverseClip)
		  PS_STATS(PSStatsClipSystemInstanciated);
		  PS_STATS(PSStatsClipSystemNotInstanciated);
		  PS_STATS(PSStatsClipSystemCheckAgainstPyramid);
		  PS_STATS(PSStatsInsertInVisibleList);
		  PS_STATS(PSStatsCheckDestroyCondition)
		  PS_STATS(PSStatsForceInstanciate)
		  PS_STATS(PSStatsDoAnimatePart1)
		  PS_STATS(PSStatsDoAnimatePart2)
		  PS_STATS(PSStatsDoAnimatePart3)
		  PS_STATS(PSStatsTraverseAnimDetailPart1)
		  PS_STATS(PSStatsTraverseAnimDetailPart2)
		  PS_STATS(PSStatsTraverseAnimDetailPart3)
		  PS_STATS(PSStatsTraverseAnimDetailPart4)
		  PS_STATS(PSAnim1)
		  PS_STATS(PSAnim2)
		  PS_STATS(PSAnim3)
		  PS_STATS(PSAnim4)
		  PS_STATS(PSAnim5)
		  PS_STATS(PSAnim6)
		  PS_STATS(PSAnim7)
		  PS_STATS(PSAnim8)
		  PS_STATS(PSAnim9)
		  PS_STATS(PSAnim10)
		  PS_STATS(PSAnim11)
		  PS_STATS(PSStatsZonePlane)
		  PS_STATS(PSStatsZoneSphere)
		  PS_STATS(PSStatsZoneDisc)
		  PS_STATS(PSStatsZoneRectangle)
		  PS_STATS(PSStatsZoneCylinder)
		  PS_STATS(PSMotion1)
		  PS_STATS(PSMotion2)
		  PS_STATS(PSMotion3)
		  PS_STATS(PSMotion4)
		  PS_STATS(PSStatCollision)
		  PS_STATS(PSStatEmit)
		  PS_STATS(PSStatRender)


		nlinfo("num do animate = %d", (int) PSStatsNumDoAnimateCalls);

		nlinfo("Max et = %.2f", PSMaxET);
		nlinfo("Max ps nb pass = %d", (int) PSMaxNBPass);

		PS_STATS(total)

	 }

	 PSStatsRegisterPSModelObserver = 0;
	 PSStatsRemovePSModelObserver = 0;
	 PSStatsUpdateOpacityInfos = 0;
	 PSStatsUpdateLightingInfos = 0;
	 PSStatsGetAABBox = 0;
	 PSStatsReallocRsc = 0;
	 PSStatsReleasePSPointer = 0;
	 PSStatsRefreshRscDeletion = 0;
	 PSStatsReleaseRsc = 0;
	 PSStatsReleaseRscAndInvalidate = 0;
	 PSStatsGetNumTriangles = 0;
	 PSStatsCheckAgainstPyramid = 0;
	 PSStatsTraverseAnimDetail = 0;
	 PSStatsDoAnimate = 0;
	 PSStatsTraverseRender = 0;
	 PSStatsTraverseClip = 0;
	 PSStatsCheckDestroyCondition = 0;
	 PSStatsForceInstanciate = 0;
	 PSStatsClipSystemInstanciated = 0;
	 PSStatsClipSystemNotInstanciated = 0;
	 PSStatsClipSystemCheckAgainstPyramid = 0;
	 PSStatsInsertInVisibleList = 0;
	 PSStatsDoAnimatePart1 = 0;
	 PSStatsDoAnimatePart2 = 0;
	 PSStatsDoAnimatePart3 = 0;
	 PSStatsTraverseAnimDetailPart1 = 0;
	 PSStatsTraverseAnimDetailPart2 = 0;
	 PSStatsTraverseAnimDetailPart3 = 0;
	 PSStatsTraverseAnimDetailPart4 = 0;
	 PSStatsNumDoAnimateCalls = 0;
	 PSAnim1 = 0;
	 PSAnim2 = 0;
	 PSAnim3 = 0;
	 PSAnim4 = 0;
	 PSAnim5 = 0;
	 PSAnim6 = 0;
	 PSAnim7 = 0;
	 PSAnim8 = 0;
	 PSAnim9 = 0;
	 PSAnim10 = 0;
	 PSAnim11 = 0;
	 PSMaxET = 0.f;
	 PSMaxNBPass = 0;
	 PSStatsZonePlane = 0;
	 PSStatsZoneSphere = 0;
	 PSStatsZoneDisc = 0;
	 PSStatsZoneRectangle = 0;
	 PSStatsZoneCylinder = 0;
	 PSMotion1 = 0;
	 PSMotion2 = 0;
	 PSMotion3 = 0;
	 PSMotion4 = 0;
	 PSStatCollision = 0;
	 PSStatEmit = 0;
	 PSStatRender = 0;
	 */
}