Exemplo n.º 1
0
	void DebugDisplay::init( OverhangTerrainSceneManager * pSceneManager)
	{
		oht_assert_threadmodel(ThrMdl_Main);

		_pSceneManager = pSceneManager;

		MaterialManager & matman = MaterialManager::getSingleton();
		MaterialPtr pMat;
		TextureUnitState * pTexUnit;
		Pass * pPass;

		pMat = matman.create("Debug/Red", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue::Red);
		_pMaterials[MC_Red] = pMat;

		pMat = matman.create("Debug/Green", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue::Green);
		_pMaterials[MC_Green] = pMat;

		pMat = matman.create("Debug/Blue", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue::Blue);
		_pMaterials[MC_Blue] = pMat;

		pMat = matman.create("Debug/Yellow", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.0f, 1.0f, 0.0f));
		_pMaterials[MC_Yellow] = pMat;

		pMat = matman.create("Debug/Turquoise", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(0.0f, 1.0f, 1.0f));
		_pMaterials[MC_Turquoise] = pMat;

		pMat = matman.create("Debug/Magenta", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		pPass = pMat->getTechnique(0) ->getPass(0);
		pPass->setPointSize(5.0f);
		pTexUnit = pPass->createTextureUnitState("color");
		pTexUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.0f, 0.0f, 1.0f));
		_pMaterials[MC_Magenta] = pMat;

		_pScNode = _pSceneManager->getRootSceneNode()->createChildSceneNode("OverhangTerrain::DebugTools");
	}
Exemplo n.º 2
0
void PlayPen_testManualBlend::setupContent()
{
	// create material
	MaterialPtr mat = MaterialManager::getSingleton().create("TestMat", 
		TRANSIENT_RESOURCE_GROUP);
	Pass * p = mat->getTechnique(0)->getPass(0);
	p->setLightingEnabled(false);
	p->createTextureUnitState("Dirt.jpg");
	TextureUnitState* t = p->createTextureUnitState("ogrelogo.png");
	t->setColourOperationEx(LBX_BLEND_MANUAL, LBS_TEXTURE, LBS_CURRENT, 
		ColourValue::White, ColourValue::White, 0.75);

	Entity *planeEnt = mSceneMgr->createEntity("Plane", SceneManager::PT_PLANE);
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(planeEnt);
	planeEnt->setMaterialName("TestMat");

	mCamera->setPosition(0,0,600);
	mCamera->lookAt(Vector3::ZERO);
}
OgreDebugDrawer::OgreDebugDrawer( SceneManager *scm )
{
    mContactPoints = &mContactPoints1;
    mLines = new ManualObject("physics lines");
    ASSERT( mLines );
    mTriangles = new ManualObject("physics triangles");
    ASSERT( mTriangles );
    mLines->setDynamic(true);
    mTriangles->setDynamic(true);
    //mLines->estimateVertexCount( 100000 );
    //mLines->estimateIndexCount( 0 );
 
    scm->getRootSceneNode()->attachObject( mLines );
    scm->getRootSceneNode()->attachObject( mTriangles );
 
    static const char * matName = "OgreBulletCollisionsDebugDefault";
    MaterialPtr mtl = MaterialManager::getSingleton().getDefaultSettings()->clone(matName);
    mtl->setReceiveShadows(false);
    mtl->setSceneBlending( SBT_TRANSPARENT_ALPHA );
    mtl->setDepthBias( 0.1, 0 );
    TextureUnitState * tu = mtl->getTechnique(0)->getPass(0)->createTextureUnitState();
    ASSERT( tu );
    tu->setColourOperationEx( LBX_SOURCE1, LBS_DIFFUSE );
    mtl->getTechnique(0)->setLightingEnabled(false);
    //mtl->getTechnique(0)->setSelfIllumination( ColourValue::White ); 
 
    mLines->begin( matName, RenderOperation::OT_LINE_LIST );
    mLines->position( Vector3::ZERO );
    mLines->colour( ColourValue::Blue );
    mLines->position( Vector3::ZERO );
    mLines->colour( ColourValue::Blue );
 
    mTriangles->begin( matName, RenderOperation::OT_TRIANGLE_LIST );
    mTriangles->position( Vector3::ZERO );
    mTriangles->colour( ColourValue::Blue );
    mTriangles->position( Vector3::ZERO );
    mTriangles->colour( ColourValue::Blue );
    mTriangles->position( Vector3::ZERO );
    mTriangles->colour( ColourValue::Blue );
 
    mDebugModes = (DebugDrawModes) DBG_DrawWireframe;
    Root::getSingleton().addFrameListener(this);
}
Exemplo n.º 4
0
    //-----------------------------------------------------------------------
    void Technique::_compileIlluminationPasses(void)
    {
        clearIlluminationPasses();

		if (!checkManuallyOrganisedIlluminationPasses())
		{
			// Build based on our own heuristics

			Passes::iterator i, iend;
			iend = mPasses.end();
			i = mPasses.begin();

			IlluminationStage iStage = IS_AMBIENT;

			bool haveAmbient = false;
			while (i != iend)
			{
				IlluminationPass* iPass;
				Pass* p = *i;
				switch(iStage)
				{
				case IS_AMBIENT:
					// Keep looking for ambient only
					if (p->isAmbientOnly())
					{
						// Add this pass wholesale
						iPass = OGRE_NEW IlluminationPass();
						iPass->destroyOnShutdown = false;
						iPass->originalPass = iPass->pass = p;
						iPass->stage = iStage;
						mIlluminationPasses.push_back(iPass);
						haveAmbient = true;
						// progress to next pass
						++i;
					}
					else
					{
						// Split off any ambient part
						if (p->getAmbient() != ColourValue::Black ||
							p->getSelfIllumination() != ColourValue::Black ||
							p->getAlphaRejectFunction() != CMPF_ALWAYS_PASS)
						{
							// Copy existing pass
							Pass* newPass = OGRE_NEW Pass(this, p->getIndex(), *p);
							if (newPass->getAlphaRejectFunction() != CMPF_ALWAYS_PASS)
							{
								// Alpha rejection passes must retain their transparency, so
								// we allow the texture units, but override the colour functions
								Pass::TextureUnitStateIterator tusi = newPass->getTextureUnitStateIterator();
								while (tusi.hasMoreElements())
								{
									TextureUnitState* tus = tusi.getNext();
									tus->setColourOperationEx(LBX_SOURCE1, LBS_CURRENT);
								}
							}
							else
							{
								// Remove any texture units
								newPass->removeAllTextureUnitStates();
							}
							// Remove any fragment program
							if (newPass->hasFragmentProgram())
								newPass->setFragmentProgram("");
							// We have to leave vertex program alone (if any) and
							// just trust that the author is using light bindings, which
							// we will ensure there are none in the ambient pass
							newPass->setDiffuse(0, 0, 0, newPass->getDiffuse().a);  // Preserving alpha
							newPass->setSpecular(ColourValue::Black);

							// Calculate hash value for new pass, because we are compiling
							// illumination passes on demand, which will loss hash calculate
							// before it add to render queue first time.
							newPass->_recalculateHash();

							iPass = OGRE_NEW IlluminationPass();
							iPass->destroyOnShutdown = true;
							iPass->originalPass = p;
							iPass->pass = newPass;
							iPass->stage = iStage;

							mIlluminationPasses.push_back(iPass);
							haveAmbient = true;

						}

						if (!haveAmbient)
						{
							// Make up a new basic pass
							Pass* newPass = OGRE_NEW Pass(this, p->getIndex());
							newPass->setAmbient(ColourValue::Black);
							newPass->setDiffuse(ColourValue::Black);

							// Calculate hash value for new pass, because we are compiling
							// illumination passes on demand, which will loss hash calculate
							// before it add to render queue first time.
							newPass->_recalculateHash();

							iPass = OGRE_NEW IlluminationPass();
							iPass->destroyOnShutdown = true;
							iPass->originalPass = p;
							iPass->pass = newPass;
							iPass->stage = iStage;
							mIlluminationPasses.push_back(iPass);
							haveAmbient = true;
						}
						// This means we're done with ambients, progress to per-light
						iStage = IS_PER_LIGHT;
					}
					break;
				case IS_PER_LIGHT:
					if (p->getIteratePerLight())
					{
						// If this is per-light already, use it directly
						iPass = OGRE_NEW IlluminationPass();
						iPass->destroyOnShutdown = false;
						iPass->originalPass = iPass->pass = p;
						iPass->stage = iStage;
						mIlluminationPasses.push_back(iPass);
						// progress to next pass
						++i;
					}
					else
					{
						// Split off per-light details (can only be done for one)
						if (p->getLightingEnabled() &&
							(p->getDiffuse() != ColourValue::Black ||
							p->getSpecular() != ColourValue::Black))
						{
							// Copy existing pass
							Pass* newPass = OGRE_NEW Pass(this, p->getIndex(), *p);
							if (newPass->getAlphaRejectFunction() != CMPF_ALWAYS_PASS)
							{
								// Alpha rejection passes must retain their transparency, so
								// we allow the texture units, but override the colour functions
								Pass::TextureUnitStateIterator tusi = newPass->getTextureUnitStateIterator();
								while (tusi.hasMoreElements())
								{
									TextureUnitState* tus = tusi.getNext();
									tus->setColourOperationEx(LBX_SOURCE1, LBS_CURRENT);
								}
							}
							else
							{
								// remove texture units
								newPass->removeAllTextureUnitStates();
							}
							// remove fragment programs
							if (newPass->hasFragmentProgram())
								newPass->setFragmentProgram("");
							// Cannot remove vertex program, have to assume that
							// it will process diffuse lights, ambient will be turned off
							newPass->setAmbient(ColourValue::Black);
							newPass->setSelfIllumination(ColourValue::Black);
							// must be additive
							newPass->setSceneBlending(SBF_ONE, SBF_ONE);

							// Calculate hash value for new pass, because we are compiling
							// illumination passes on demand, which will loss hash calculate
							// before it add to render queue first time.
							newPass->_recalculateHash();

							iPass = OGRE_NEW IlluminationPass();
							iPass->destroyOnShutdown = true;
							iPass->originalPass = p;
							iPass->pass = newPass;
							iPass->stage = iStage;

							mIlluminationPasses.push_back(iPass);

						}
						// This means the end of per-light passes
						iStage = IS_DECAL;
					}
					break;
				case IS_DECAL:
					// We just want a 'lighting off' pass to finish off
					// and only if there are texture units
					if (p->getNumTextureUnitStates() > 0)
					{
						if (!p->getLightingEnabled())
						{
							// we assume this pass already combines as required with the scene
							iPass = OGRE_NEW IlluminationPass();
							iPass->destroyOnShutdown = false;
							iPass->originalPass = iPass->pass = p;
							iPass->stage = iStage;
							mIlluminationPasses.push_back(iPass);
						}
						else
						{
							// Copy the pass and tweak away the lighting parts
							Pass* newPass = OGRE_NEW Pass(this, p->getIndex(), *p);
							newPass->setAmbient(ColourValue::Black);
							newPass->setDiffuse(0, 0, 0, newPass->getDiffuse().a);  // Preserving alpha
							newPass->setSpecular(ColourValue::Black);
							newPass->setSelfIllumination(ColourValue::Black);
							newPass->setLightingEnabled(false);
							newPass->setIteratePerLight(false, false);
							// modulate
							newPass->setSceneBlending(SBF_DEST_COLOUR, SBF_ZERO);

							// Calculate hash value for new pass, because we are compiling
							// illumination passes on demand, which will loss hash calculate
							// before it add to render queue first time.
							newPass->_recalculateHash();

							// NB there is nothing we can do about vertex & fragment
							// programs here, so people will just have to make their
							// programs friendly-like if they want to use this technique
							iPass = OGRE_NEW IlluminationPass();
							iPass->destroyOnShutdown = true;
							iPass->originalPass = p;
							iPass->pass = newPass;
							iPass->stage = iStage;
							mIlluminationPasses.push_back(iPass);

						}
					}
					++i; // always increment on decal, since nothing more to do with this pass

					break;
                case IS_UNKNOWN:
                    break;
				}
			}
		}

    }
Exemplo n.º 5
0
void PlayPen_testProjectSphere::setupContent()
{
	mSceneMgr->setAmbientLight(ColourValue::White);


	Plane plane;
	plane.normal = Vector3::UNIT_Y;
	plane.d = 0;
	MeshManager::getSingleton().createPlane("Myplane",
		TRANSIENT_RESOURCE_GROUP, plane,
		4500,4500,10,10,true,1,5,5,Vector3::UNIT_Z);
	Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
	pPlaneEnt->setMaterialName("Examples/GrassFloor");
	pPlaneEnt->setCastShadows(false);
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);

	mProjectionSphere = new Sphere(Vector3(0, 2000, 0), 1500.0);

	ManualObject* debugSphere = mSceneMgr->createManualObject("debugSphere");
	debugSphere->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP);
	for (int i = 0; i <= 20; ++i)
	{
		Vector3 basePos(mProjectionSphere->getRadius(), 0, 0);
		Quaternion quat;
		quat.FromAngleAxis(Radian(((float)i/(float)20)*Math::TWO_PI), Vector3::UNIT_Y);
		basePos = quat * basePos;
		debugSphere->position(basePos);
	}
	for (int i = 0; i <= 20; ++i)
	{
		Vector3 basePos(mProjectionSphere->getRadius(), 0, 0);
		Quaternion quat;
		quat.FromAngleAxis(Radian(((float)i/(float)20)*Math::TWO_PI), Vector3::UNIT_Z);
		basePos = quat * basePos;
		debugSphere->position(basePos);
	}
	debugSphere->end();

	mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,2000,0))->attachObject(debugSphere);

	MaterialPtr mat = MaterialManager::getSingleton().create("scissormat", 
		TRANSIENT_RESOURCE_GROUP);
	Pass* p = mat->getTechnique(0)->getPass(0);
	p->setDepthWriteEnabled(false);
	p->setSceneBlending(SBT_TRANSPARENT_ALPHA);
	TextureUnitState* t = p->createTextureUnitState();
	t->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 
		ColourValue::Red);
	t->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.5f);


	mScissorRect = mSceneMgr->createManualObject("mScissorRect");
	mScissorRect->setUseIdentityProjection(true);
	mScissorRect->setUseIdentityView(true);
	AxisAlignedBox aabb;
	aabb.setInfinite();
	mScissorRect->setBoundingBox(aabb);
	mScissorRect->begin(mat->getName());
	mScissorRect->position(Vector3::ZERO);
	mScissorRect->position(Vector3::ZERO);
	mScissorRect->position(Vector3::ZERO);
	mScissorRect->quad(0, 1, 2, 3);
	mScissorRect->end();
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(mScissorRect);

	mCamera->setPosition(0,3000,5000);
	mCamera->lookAt(mProjectionSphere->getCenter());


}
Exemplo n.º 6
0
// Create the background nebulae
void createBackground(SceneManager *sceneMgr) {
	
	// Get the background image
	String bgImage = ScriptSystem::getSingleton().getScriptString("backgroundImage");
	MaterialPtr mat = MaterialManager::getSingleton().getByName("Background");
	mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(bgImage);

	// Get the nebula textures, and set their colors
	ColourValue col;
	col.r = ScriptSystem::getSingleton().getScriptNumber("nebula1_R");
	col.g = ScriptSystem::getSingleton().getScriptNumber("nebula1_G");
	col.b = ScriptSystem::getSingleton().getScriptNumber("nebula1_B");
	mat = MaterialManager::getSingleton().getByName("BackgroundNebula1");
	TextureUnitState *tu = mat->getTechnique(0)->getPass(0)->getTextureUnitState(1);
	tu->setColourOperationEx(LBX_MODULATE, LBS_CURRENT, LBS_MANUAL, col, col);

	col.r = ScriptSystem::getSingleton().getScriptNumber("nebula2_R");
	col.g = ScriptSystem::getSingleton().getScriptNumber("nebula2_G");
	col.b = ScriptSystem::getSingleton().getScriptNumber("nebula2_B");
	mat = MaterialManager::getSingleton().getByName("BackgroundNebula2");
	tu = mat->getTechnique(0)->getPass(0)->getTextureUnitState(1);
	tu->setColourOperationEx(LBX_MODULATE, LBS_CURRENT, LBS_MANUAL, col, col);

	col.r = ScriptSystem::getSingleton().getScriptNumber("nebula3_R");
	col.g = ScriptSystem::getSingleton().getScriptNumber("nebula3_G");
	col.b = ScriptSystem::getSingleton().getScriptNumber("nebula3_B");
	mat = MaterialManager::getSingleton().getByName("BackgroundNebula3");
	tu = mat->getTechnique(0)->getPass(0)->getTextureUnitState(1);
	tu->setColourOperationEx(LBX_MODULATE, LBS_CURRENT, LBS_MANUAL, col, col);


	// Create background rectangle covering the whole screen
	bgRect = new Rectangle2D(true);
	// Flipping and mirroring
	Real bgx = rand()%100 < 50 ? -1.0f : 1.0f;
	Real bgy = rand()%100 < 50 ? -1.0f : 1.0f;
	bgRect->setCorners(-bgx, bgy, bgx, -bgy);
	bgRect->setMaterial(MaterialManager::getSingleton().getByName("Background"));

	// Render the background before everything else
	bgRect->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY);
	AxisAlignedBox box; box.setInfinite();
	bgRect->setBoundingBox(box);

	// Attach background to the scene
	SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("Background");
	node->attachObject(bgRect);


	// Background stars
	int starsCount = (int)ScriptSystem::getSingleton().getScriptNumber("starsCount");
	ManualObject *stars[4];
	for(int ii=0; ii<4; ii++) {
		stars[ii] = sceneMgr->createManualObject("BackgroundStars" + StringConverter::toString(ii+1));
		stars[ii]->begin("BackgroundStars", RenderOperation::OT_POINT_LIST);
		for(int j=0; j<starsCount; j++) {
			Vector3 pos;
			pos.x = Math::RangeRandom(-playfieldWidth, playfieldWidth);
			pos.y = Math::RangeRandom(-playfieldHeight, playfieldHeight);
			pos.z = Math::RangeRandom(-140, -5);
			stars[ii]->position(pos);

			Real c = Math::RangeRandom(0.1f, 1.0f);
			stars[ii]->colour(c, c, c);
			stars[ii]->index(j);
		}
		stars[ii]->end();
		stars[ii]->setRenderQueueGroup(RENDER_QUEUE_1);
		stars[ii]->setCastShadows(false);
	}

	// Create four groups of stars
	SceneNode *starsNode = sceneMgr->getRootSceneNode()->createChildSceneNode("BackgroundStars1");
	starsNode->attachObject(stars[0]);
	starsNode->translate(-playfieldWidth/2, -playfieldHeight/2, 0);

	starsNode = sceneMgr->getRootSceneNode()->createChildSceneNode("BackgroundStars2");
	starsNode->attachObject(stars[1]);
	starsNode->translate(+playfieldWidth/2, -playfieldHeight/2, 0);

	starsNode = sceneMgr->getRootSceneNode()->createChildSceneNode("BackgroundStars3");
	starsNode->attachObject(stars[2]);
	starsNode->translate(+playfieldWidth/2, +playfieldHeight/2, 0);

	starsNode = sceneMgr->getRootSceneNode()->createChildSceneNode("BackgroundStars4");
	starsNode->attachObject(stars[3]);
	starsNode->translate(-playfieldWidth/2, +playfieldHeight/2, 0);


	// Create the nebulae
	nebulaCount = (int)ScriptSystem::getSingleton().getScriptNumber("nebulaCount");
	for(int f=0; f<nebulaCount; f++) {
		Entity *ent = sceneMgr->createEntity("BackgroundNebula" + StringConverter::toString(f), "Plane.mesh");
		ent->setMaterialName("BackgroundNebula" + StringConverter::toString(f%3 + 1));
		ent->setCastShadows(false);
		ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY);

		Vector3 pos;
		pos.x = Math::RangeRandom(-playfieldWidth, playfieldWidth);
		pos.y = Math::RangeRandom(-playfieldHeight, playfieldHeight);
		pos.z = Math::RangeRandom(-30, -5);

		SceneNode *node = sceneMgr->getRootSceneNode()->createChildSceneNode("NebulaNode" + StringConverter::toString(f), pos);
		node->attachObject(ent);

		Real s = Math::RangeRandom(25, 55);
		node->scale(s,s,s);
		node->roll(Degree(Math::RangeRandom(0,360)));
		node->yaw(Degree(Math::RangeRandom(-15,15)));
	}
}
Exemplo n.º 7
0
//-------------------------------------------------------------------------------------
void BasicTutorial2::createScene(void)
{

	mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
	//mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

	Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja", "ninja.mesh");
	entNinja->setCastShadows(true);
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);

	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);

	Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);

	Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);

	entGround->setMaterialName("Examples/Rockwall");
	//entGround->setMaterialName("RttMat");
	entGround->setCastShadows(false);

	Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
	Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
	headNode->attachObject(ogreHead);
	headNode->setPosition(50,120,0);

	Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
	pointLight->setType(Ogre::Light::LT_POINT);
	pointLight->setPosition(Ogre::Vector3(0, 150, 250));

	pointLight->setDiffuseColour(1.0, 0.0, 0.0);
	pointLight->setSpecularColour(1.0, 0.0, 0.0);

	Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
	directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
	directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
	directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));

	directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 )); 

	Ogre::Light* spotLight = mSceneMgr->createLight("spotLight");
	spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
	spotLight->setDiffuseColour(0, 0, 1.0);
	spotLight->setSpecularColour(0, 0, 1.0);

	spotLight->setDirection(-1, -1, 0);
	spotLight->setPosition(Ogre::Vector3(300, 300, 0));

	spotLight->setSpotlightRange(Ogre::Degree(35), Ogre::Degree(50));


	//------------------
	using namespace Ogre;
	TexturePtr texture = TextureManager::getSingleton().
		createManual( "RttTex",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
		TEX_TYPE_2D,512, 512, 0, PF_R8G8B8, TU_RENDERTARGET );
	RenderTarget *rttTex = texture->getBuffer()->getRenderTarget();

	mReflectCam = mSceneMgr->createCamera("ReflectCam");
	mReflectCam->setOrientation(mCamera->getOrientation());
	mReflectCam->setPosition(mCamera->getPosition());
	mReflectCam->setNearClipDistance(mCamera->getNearClipDistance());

	mReflectCam->setFarClipDistance(mCamera->getFarClipDistance());

	mReflectCam->setAspectRatio(
		(Real)mWindow->getViewport(0)->getActualWidth() /
		(Real)mWindow->getViewport(0)->getActualHeight());
	Viewport *v = rttTex->addViewport( mReflectCam );
	v->setClearEveryFrame( true );
	v->setBackgroundColour( ColourValue::Black );

	//MaterialPtr mat = MaterialManager::getSingleton().create("RttMat",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	//TextureUnitState* t = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RustedMetal.jpg");

	MaterialPtr mat;
	TextureUnitState *t = NULL;

	Entity *entMaterial = entGround ;

	int nCnt = entGround->getNumSubEntities();
	for ( int i=0; i<nCnt; i++)
	{
		SubEntity* _SubEnt = entMaterial->getSubEntity(i);
		MaterialPtr _MaterPtr;
		Pass * _Pass;
		mat = _SubEnt->getMaterial();
		break;
	}

	t = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
	// Blend with base texture
	t->setColourOperationEx(LBX_BLEND_MANUAL, LBS_TEXTURE, LBS_CURRENT,ColourValue::White,  ColourValue::White, 0.65);
	t->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
	t->setProjectiveTexturing(true, mReflectCam);
	rttTex->addListener(this);
	// set up linked reflection
	mReflectCam->enableReflection(plane);
	// Also clip
	mReflectCam->enableCustomNearClipPlane(plane);
	//------------------
#if 0
	// skybox
	//mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");//, 10);
	//mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 5000, false);
#endif
#if 0
	// skydome
	mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
#endif
#if 0
	//skyplane
	Ogre::Plane plane2;
	plane2.d = 1000;
	plane2.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;
	//mSceneMgr->setSkyPlane(true, plane2, "Examples/SpaceSkyPlane", 1500, 75);
	mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 1500, 40, true, 1.5f, 150, 150);
#endif

#if 0
	Ogre::ColourValue fadeColour(0.9, 0.9, 0.9);
	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
	//mSceneMgr->setFog(Ogre::FOG_LINEAR, fadeColour, 0.0, 50, 500);
	//mSceneMgr->setFog(Ogre::FOG_EXP, fadeColour, 0.005);
	mSceneMgr->setFog(Ogre::FOG_EXP2, fadeColour, 0.003);
#endif
	{
		Ogre::ColourValue fadeColour(0.1, 0.1, 0.1);
		mWindow->getViewport(0)->setBackgroundColour(fadeColour);
		mSceneMgr->setFog(Ogre::FOG_LINEAR, fadeColour, 0.0, 10, 150);

		Ogre::Plane plane;
		plane.d = 10;
		plane.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;

		mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane", 100, 45, true, 0.5, 150, 150);
	}
}