All pastes #408308 Raw Edit

Unnamed

public text v1 · immutable
#408308 ·published 2007-03-24 19:06 UTC
rendered paste body
void createScene(void)
{
       // setup GUI system
       mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
       mGUISystem = new CEGUI::System(mGUIRenderer);

       // load scheme and set up defaults
       CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
       mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");

	
       mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

       Entity* test = mSceneMgr->createEntity("corridor", "c:\\v2.mesh");

       SceneNode* testNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
       testNode->attachObject(test);

}

-------


    bool frameStarted(const FrameEvent &evt)
    {
        // Process the base frame listener code.  Since we are going to be
        // manipulating the translate vector, we need this to happen first.
        if ( !ExampleFrameListener::frameStarted( evt ) )
            return false;

		// Setup the scene query
        Vector3 camPos = mCamera->getPosition( );
        Ray cameraRay( Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y );
        mRaySceneQuery->setRay( cameraRay );

		// Perform the scene query
        RaySceneQueryResult &result = mRaySceneQuery->execute();
        RaySceneQueryResult::iterator itr = result.begin( );

		// Get the results, set the camera height
        if ( itr != result.end() && itr->worldFragment )
        {
			Real terrainHeight = itr->worldFragment->singleIntersection.y;
            if ((terrainHeight + 10.0f) > camPos.y)
                mCamera->setPosition( camPos.x, terrainHeight + 10.0f, camPos.z );
        }

        return true;
    }