Exemple #1
0
void CWaterTask::release()
{
	CSceneUser *su = dynamic_cast<CSceneUser *>(&C3DTask::getInstance().scene());
//	CSceneUser *su = dynamic_cast<CSceneUser *>(nelWaterScene);
	CScene		&scene = su->getScene ();

	if(WaterInstance)
	{
		scene.deleteInstance(WaterInstance);
		WaterInstance = 0;
		//delete WaterShape;
	}

	if(nelWaterScene)
	{
		C3DTask::getInstance().driver().deleteScene(nelWaterScene);
		nelWaterScene = 0;
	}

	
}
Exemple #2
0
// ***************************************************************************
UScene			*CDriverUser::createScene(bool bSmallScene)
{
	CSceneUser *pSU = new CSceneUser(this, bSmallScene);

	// set the shape bank
	pSU->getScene().setShapeBank( &_ShapeBank._ShapeBank );
	// set the MeshSkin Vertex Streams
	pSU->getScene().getRenderTrav().setMeshSkinManager(&_MeshSkinManager);
	pSU->getScene().getRenderTrav().setShadowMeshSkinManager(&_ShadowMeshSkinManager);
	// set the AsyncTextureManager
	pSU->getScene().setAsyncTextureManager(&_AsyncTextureManager);
	// set the lodManager
	pSU->getScene().setLodCharacterManager(&_LodCharacterManager);
	return _Scenes.insert(pSU);
}
Exemple #3
0
void CWaterTask::init()
{
	nelWaterScene = C3DTask::getInstance().driver().createScene(false);

	nelWaterScene->getCam().setPerspective(degToRad(CConfigFileTask::getInstance().configFile().getVar("Fov").asFloat()), 1.33f, 1.0f*GScale, 30000.0f*GScale);
	nelWaterScene->getCam().setTransformMode (UTransformable::DirectMatrix);

////
	if(CConfigFileTask::getInstance().configFile().getVar("DisplayWater").asInt() == 2)
	{
		string res;
		static std::string shapeName("water_quad.shape");
		CSceneUser *su = dynamic_cast<CSceneUser *>(&C3DTask::getInstance().scene());
//		CSceneUser *su = dynamic_cast<CSceneUser *>(nelWaterScene);
		CScene		&scene = su->getScene ();

		// load textures
		res = CResourceManager::getInstance().get(envMap0Name());
		ITexture *envMap1   = new CTextureFile(res);
		res = CResourceManager::getInstance().get(envMap1Name());
		ITexture *envMap2   = new CTextureFile(res);
		
		res = CResourceManager::getInstance().get(heightMap0Name());
		ITexture *heightMap  = new CTextureFile(res);
		res = CResourceManager::getInstance().get(heightMap1Name());
		ITexture *heightMap2 = new CTextureFile(res);

		res = CResourceManager::getInstance().get("colormap.tga");
		ITexture *colorMap = new CTextureFile(res);
		
		WaterShape = new CWaterShape;
		WaterShape->setEnvMap(0, envMap1);
		WaterShape->setEnvMap(1, envMap2);
		
		WaterShape->setHeightMap(0, heightMap);
		WaterShape->setHeightMap(1, heightMap2);

		//WaterShape->setColorMap(colorMap);

		WaterShape->setWaterPoolID(0);

		CWaterHeightMap &whm = GetWaterPoolManager().getPoolByID(0);
//		float res = whm.getUnitSize();
//		res /= 10.0f;
//		whm.setUnitSize(res);
		whm.enableWaves ();

		float res2 = whm.getPropagationTime ();

		CConfigFileTask::getInstance().configFile().setCallback("Map1Scale", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("Map1Scale"));
		CConfigFileTask::getInstance().configFile().setCallback("Map2Scale", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("Map2Scale"));
		CConfigFileTask::getInstance().configFile().setCallback("Map1Speed", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("Map1Speed"));
		CConfigFileTask::getInstance().configFile().setCallback("Map2Speed", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("Map2Speed"));
		CConfigFileTask::getInstance().configFile().setCallback("WaveHeightFactor", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("WaveHeightFactor"));
		CConfigFileTask::getInstance().configFile().setCallback("WavesParams", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("WavesParams"));
		CConfigFileTask::getInstance().configFile().setCallback("WavesPropagation", cbVar);
		cbVar (CConfigFileTask::getInstance().configFile().getVar("WavesPropagation"));

//		WaterShape->setHeightMapScale(0, NLMISC::CVector2f(0.08f/2, 0.072f/2));
//		WaterShape->setHeightMapScale(1, NLMISC::CVector2f(0.1f/2, 0.091f/2));
//		WaterShape->setHeightMapSpeed(0, NLMISC::CVector2f(0.06f, 0.051f));
//		WaterShape->setHeightMapSpeed(1, NLMISC::CVector2f(-0.0623f, 0.085f));
//		WaterShape->setWaveHeightFactor(3);

		const float wqSize = 10000.0f;
		CVector2f corners[] =	{ CVector2f(-wqSize, wqSize), CVector2f(wqSize, wqSize),
								  CVector2f(wqSize, -wqSize), CVector2f(-wqSize, -wqSize)
								};
		CPolygon2D waterPoly;
		waterPoly.Vertices.resize(4);
		std::copy(corners, corners + 4, waterPoly.Vertices.begin());
		WaterShape->setShape(waterPoly);

		scene.getShapeBank()->add(shapeName, WaterShape);

		WaterInstance = scene.createInstance(shapeName);
		WaterModel = NLMISC::safe_cast<CWaterModel *>(WaterInstance);
		WaterModel->setPos(0.0f,0.0f,1.0f*GScale);

		//	CWaterHeightMap &whm = GetWaterPoolManager().getPoolByID(0);
		//	whm.enableWaves ();
		//	whm.setWaves (3.0f, 1.0f, 2.0f, false);
	}
	else if(CConfigFileTask::getInstance().configFile().getVar("DisplayWater").asInt() == 1)
	{
		string res;
		res = CResourceManager::getInstance().get("water_light.shape");
		WaterMesh = C3DTask::getInstance().scene().createInstance(res);
		WaterMesh.setPos(0.0f,0.0f,1.0f*GScale);
	}

}