コード例 #1
0
ファイル: Compositor.cpp プロジェクト: HaohaoLau/stuntrally
CompositorInstance::Listener* HDRLogic::createListener(CompositorInstance* instance)
{
	HDRListener* listener = new HDRListener(mApp);
	Viewport* vp = instance->getChain()->getViewport();
	listener->notifyViewportSize(vp->getActualWidth(), vp->getActualHeight());
	listener->mViewportWidth = vp->getActualWidth();
	listener->mViewportHeight = vp->getActualHeight();
	listener->notifyCompositor(instance);
	return listener;
}
コード例 #2
0
void TutorialApplication::createViewports() {
    Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(ColourValue(0,0,0));
    mCamera->setAspectRatio(
        Real(vp->getActualWidth() /
        Real(vp->getActualHeight())));
}
コード例 #3
0
ファイル: ShortStory.cpp プロジェクト: Cepheus/Short-Story
void ShortStory::initScene ()
{
	// on crée la fenêtre
	mWindow = mRoot->initialise(true, "Short Story");
	// on charge les ressources pour de vrai
	TextureManager::getSingleton().setDefaultNumMipmaps(5);
	ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	// on crée le scene manager
	mSceneMgr = mRoot->createSceneManager("DefaultSceneManager", "Scene Manager");
	mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

	// on crée la caméra
	mCamera = mSceneMgr->createCamera("PlayerCam");
	mCamera->setPosition(Vector3(0, 0, 100));
	mCamera->lookAt(Vector3(0, 0, 0));
	mCamera->setNearClipDistance(5);

    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
    else{
        mCamera->setFarClipDistance(2000);
    }

	Viewport* vp = mWindow->addViewport(mCamera);
	vp->setBackgroundColour(ColourValue(0, 0, 0));
	mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
コード例 #4
0
ファイル: MyApplication.cpp プロジェクト: bjerkins/GEDE2014
	int startup()
	{
		_root = new Root("plugins_d.cfg");
		
		if (!_root->showConfigDialog()) {
			return -1;
		}

		RenderWindow* window = _root->initialise(true, "Lab 4");
		_sceneManager = _root->createSceneManager(ST_GENERIC);

		Camera* camera = _sceneManager->createCamera("Camera");
		camera->setPosition(Ogre::Vector3(0,0,50));
		camera->lookAt(Ogre::Vector3(0,0,0));
		camera->setNearClipDistance(5);

		Viewport *viewPort = window->addViewport(camera);
		viewPort->setBackgroundColour(ColourValue(0.0,0.0,0.0));

		camera->setAspectRatio(Real(viewPort->getActualWidth())/Real(viewPort->getActualHeight()));

		loadResources(); 
		createScene();

		_listener = new MyFrameListener(window, camera, new CylindricalEffect(_myCube, Ogre::Vector3(2.0, 10.0, 0.0), Ogre::Vector3(0.0, 0.0, 0.1)));
		_root->addFrameListener(_listener);
		return 0;
	}
コード例 #5
0
	virtual void execute(SceneManager *sm, RenderSystem *rs)
	{
		// Fire listener
		instance->_fireNotifyMaterialRender(pass_id, mat);

        Rectangle2D * mRectangle=static_cast<Rectangle2D *>(CompositorManager::getSingleton()._getTexturedRectangle2D());
        if (mQuadCornerModified)
        {
            // insure positions are using peculiar render system offsets 
            RenderSystem* rs = Root::getSingleton().getRenderSystem();
            Viewport* vp = rs->_getViewport();
            Real hOffset = rs->getHorizontalTexelOffset() / (0.5 * vp->getActualWidth());
            Real vOffset = rs->getVerticalTexelOffset() / (0.5 * vp->getActualHeight());
            mRectangle->setCorners(mQuadLeft + hOffset, mQuadTop - vOffset, mQuadRight + hOffset, mQuadBottom - vOffset);
        }
        
		// Queue passes from mat
		Technique::PassIterator i = technique->getPassIterator();
		while(i.hasMoreElements())
		{
			sm->_injectRenderWithPass(
				i.getNext(), 
				mRectangle,
				false // don't allow replacement of shadow passes
				);
		}
	}
コード例 #6
0
    //-----------------------------------------------------------------------
    Real DistanceLodStrategyBase::getValueImpl(const MovableObject *movableObject, const Ogre::Camera *camera) const
    {
        Real squaredDepth = getSquaredDepth(movableObject, camera);

        // Check if reference view needs to be taken into account
        if (mReferenceViewEnabled)
        {
            // Reference view only applicable to perspective projection
            assert(camera->getProjectionType() == PT_PERSPECTIVE && "Camera projection type must be perspective!");

            // Get camera viewport
            Viewport *viewport = camera->getViewport();

            // Get viewport area
            Real viewportArea = static_cast<Real>(viewport->getActualWidth() * viewport->getActualHeight());

            // Get projection matrix (this is done to avoid computation of tan(FOV / 2))
            const Matrix4& projectionMatrix = camera->getProjectionMatrix();

            // Compute bias value (note that this is similar to the method used for PixelCountLodStrategy)
            Real biasValue = viewportArea * projectionMatrix[0][0] * projectionMatrix[1][1];

            // Scale squared depth appropriately
            squaredDepth *= (mReferenceViewValue / biasValue);
        }

        // Squared depth should never be below 0, so clamp
        squaredDepth = std::max(squaredDepth, Real(0));

        // Now adjust it by the camera bias and return the computed value
        return squaredDepth * camera->_getLodBiasInverse();
    }
コード例 #7
0
CEGuiOgreBaseApplication::CEGuiOgreBaseApplication() :
        d_ogreRoot(0),
        d_renderer(0),
        d_initialised(false),
        d_frameListener(0),
        d_windowEventListener(0)
{
    using namespace Ogre;

    d_ogreRoot = new Root();

    initialiseResources();

    if (d_ogreRoot->showConfigDialog())
    {
        // initialise system according to user options.
        d_window = d_ogreRoot->initialise(true);

        // Create the scene manager
        SceneManager* sm = d_ogreRoot->
            createSceneManager(ST_GENERIC, "SampleSceneMgr");
        // Create and initialise the camera
        d_camera = sm->createCamera("SampleCam");
        d_camera->setPosition(Vector3(0,0,500));
        d_camera->lookAt(Vector3(0,0,-300));
        d_camera->setNearClipDistance(5);

        // Create a viewport covering whole window
        Viewport* vp = d_window->addViewport(d_camera);
        vp->setBackgroundColour(ColourValue(0,0,0));

        // Update the camera aspect ratio to that of the viewport
        d_camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));

        // initialise resources
        ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

        // initialise GUI system
        d_renderer = new CEGUI::OgreCEGUIRenderer(d_window, RENDER_QUEUE_OVERLAY, false, 0, sm);
        new CEGUI::System(d_renderer);

        // create frame listener
        d_frameListener= new CEGuiDemoFrameListener(this, d_window, d_camera);
        d_ogreRoot->addFrameListener(d_frameListener);

        // add a listener for OS framework window events (for resizing)
        d_windowEventListener = new WndEvtListener(d_renderer);
        WindowEventUtilities::addWindowEventListener(d_window,
                                                     d_windowEventListener);

        d_initialised = true;
    }
    else
    {
        // aborted.  Clean up and set root to 0 so when app attempts to run it knows what happened here.
        delete d_ogreRoot;
        d_ogreRoot = 0;
    }
}
コード例 #8
0
Ray TutorialApplication::getMouseRay() {
    const OIS::MouseState s = mMouse->getMouseState();
    Viewport *vp = m_SceneMgr->getCurrentViewport();

    return mCamera->getCameraToViewportRay(
                (Real) s.X.abs / vp->getActualWidth(),
                (Real) s.Y.abs / vp->getActualHeight());
}
コード例 #9
0
ファイル: BaseApp.cpp プロジェクト: zxc123zxc/OGRE-test
//-------------------------------------------------------------------------------------
void BaseApplication::createViewports(void) {
	// Create one viewport, entire window
	Viewport *vp = _window->addViewport();
	vp->clear(FBT_COLOUR | FBT_DEPTH, Ogre::ColourValue(0,0,0));

	// Alter the camera aspect ratio to match the viewport
	_camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
コード例 #10
0
ファイル: Compositor.cpp プロジェクト: HaohaoLau/stuntrally
CompositorInstance::Listener* FilmGrainLogic::createListener(CompositorInstance* instance)
{
	FilmGrainListener* listener = new FilmGrainListener(mApp);
	Viewport* vp = instance->getChain()->getViewport();
	listener->mViewportWidth = vp->getActualWidth();
	listener->mViewportHeight = vp->getActualHeight();
	return listener;
}
コード例 #11
0
void BunBunApplication::createViewports(){
    // Create one viewport, entire window
    Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(
        Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
コード例 #12
0
ファイル: main.cpp プロジェクト: AnSuGuen/2016-Game-Engine
  void go(void)
  {
    // OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
    mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
    mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


    // 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
    if (!mRoot->restoreConfig()) {
      if (!mRoot->showConfigDialog()) return;
    }
    mWindow = mRoot->initialise(true, "Hello Professor : Copyleft Dae-Hyun Lee");

    // ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
	size_t windowHnd = 0;
	std::ostringstream windowHndStr;
	OIS::ParamList pl;
	mWindow->getCustomAttribute("WINDOW", &windowHnd);
	windowHndStr << windowHnd;
	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	mInputManager = OIS::InputManager::createInputSystem(pl);
	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));

	mESCListener = new ESCListener(mKeyboard);
    mRoot->addFrameListener(mESCListener);

	mSceneMgr = mRoot->createSceneManager(ST_GENERIC);

    mCamera = mSceneMgr->createCamera("camera");
    mCamera->setPosition(0.0f, 200.0f, 300.0f);
    mCamera->lookAt(0.0f, 100.0f, 0.00f);
    mCamera->setNearClipDistance(5.0f);

    mViewport = mWindow->addViewport(mCamera);
    mViewport->setBackgroundColour(ColourValue(0.0f,0.0f,0.5f));
    mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));

    ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

    Entity* daehyunEntity = mSceneMgr->createEntity("Daehyun", "DustinBody.mesh");

    SceneNode* daehyunNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    daehyunNode->attachObject(daehyunEntity);

    mRoot->startRendering();

    mInputManager->destroyInputObject(mKeyboard);
    OIS::InputManager::destroyInputSystem(mInputManager);

    delete mRoot;
  }
コード例 #13
0
ファイル: main.cpp プロジェクト: ramyD/boksey
    void createViewports(void){
        // Create one viewport, entire window, and tie it to our camera
        vp = mWindow->addViewport(mCamera);

        vp->setBackgroundColour(ColourValue(0,0,0));

        // Alter the camera aspect ratio to match the viewport
        mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    }
コード例 #14
0
ファイル: ex_ogre3d.cpp プロジェクト: sesc4mt/mvcdecoder
   virtual void createViewports()
   {
      // Create one viewport, entire window.
      Viewport *vp = mWindow->addViewport(mCamera);
      vp->setBackgroundColour(ColourValue(0, 0.25, 0.5));

      // Alter the camera aspect ratio to match the viewport.
      mCamera->setAspectRatio(
         Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
   }
コード例 #15
0
void Project_Gravity::createViewports(void)
{
	std::cout<<"create viewports"<<std::endl;
	// Create one viewport, entire window
	Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(
        Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
コード例 #16
0
ファイル: main.cpp プロジェクト: jfyne/Black-Comrade
void Main::createViewPort() {

    Viewport *vp = window->addViewport(camera);
    vp->setBackgroundColour(ColourValue(0,0,0));

    camera->setAspectRatio(
        Real(vp->getActualWidth()) / Real(vp->getActualHeight()*1.17));
    //camera->setAspectRatio(1.17);

    vp->update();
}
コード例 #17
0
void TerrainManager::initHDR()
{
	Viewport *vp = gEnv->mainCamera->getViewport();
	CompositorInstance *instance = CompositorManager::getSingleton().addCompositor(vp, "HDR", 0);
	CompositorManager::getSingleton().setCompositorEnabled(vp, "HDR", true);

	// HDR needs a special listener
	hdr_listener = new HDRListener();
	instance->addListener(hdr_listener);
	hdr_listener->notifyViewportSize(vp->getActualWidth(), vp->getActualHeight());
	hdr_listener->notifyCompositor(instance);
}
コード例 #18
0
void BaseApplication::setupScene() {
	mSceneMgr = mRoot->createSceneManager("TerrainSceneManager");

	mCamera = mSceneMgr->createCamera("Camera");
	mCamera->setNearClipDistance(1.0);

	Viewport *vp = mWindow->addViewport(mCamera);
	// Alter the camera aspect ratio to match the viewport
	mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));

	vp->setBackgroundColour(ColourValue(0.1,0.1,0.1));
}
コード例 #19
0
ファイル: menuSystem.cpp プロジェクト: jfyne/Black-Comrade
void MenuSystem::init() {
    window->removeAllViewports();
    Camera *camera = sceneMgr->createCamera("menuCam");
    Viewport *vp = window->addViewport(camera);
    vp->setBackgroundColour(ColourValue(0,0,0));
    camera->setAspectRatio(
        Real(vp->getActualWidth()) / Real(vp->getActualHeight()*1.17));

    vp->update();
    CEGUI::System::getSingleton().setDefaultMouseCursor("Cursor", "Cursor");

    menuLoop->addTickable(inputState,"inputState");
}
コード例 #20
0
ファイル: Application.cpp プロジェクト: Leph/SMA
void Application::createCamera()
{
    _camera = _scene->createCamera("camera");
    _camera->setPosition(Vector3(1000,1000,1000));
    _camera->lookAt(Vector3(0,-1000,0));
    _camera->setNearClipDistance(1);
    _camera->setFarClipDistance(100000);

    Viewport* vp = _window->addViewport(_camera);
    _camera->setAspectRatio(Real(vp->getActualWidth())/Real(vp->getActualHeight()));
    //_camera->setPolygonMode(Ogre::PM_WIREFRAME);
    vp->setBackgroundColour(ColourValue(0,0,0));
}
コード例 #21
0
ファイル: Engine.cpp プロジェクト: prsolucoes/PR3DEngine
void Engine::createViewports() {
	//criamos uma viewport, ocupando toda a janela
	Viewport* vp = _window->addViewport(_camera);
	vp->setBackgroundColour(ColourValue(0,0,0));
	
	//define alguns atributos da viewport
	vp->setShadowsEnabled( EngineGlobalObjects::getInstance().getConfiguration()->getViewportShadown() );
	vp->setSkiesEnabled( EngineGlobalObjects::getInstance().getConfiguration()->getViewportSkies() );
	vp->setOverlaysEnabled( EngineGlobalObjects::getInstance().getConfiguration()->getViewportOverlays() );

	//alteramos o aspect ratio da camera para encaixar no viewport
	_camera->setAspectRatio( Real(vp->getActualWidth()) / Real(vp->getActualHeight()) );
}
コード例 #22
0
//-----------------------------------------------------------------------
Renderable *CompositorManager::_getTexturedRectangle2D()
{
	if(!mRectangle)
	{
		/// 2D rectangle, to use for render_quad passes
		mRectangle = new Rectangle2D(true);
	}
	RenderSystem* rs = Root::getSingleton().getRenderSystem();
	Viewport* vp = rs->_getViewport();
	Real hOffset = rs->getHorizontalTexelOffset() / (0.5 * vp->getActualWidth());
	Real vOffset = rs->getVerticalTexelOffset() / (0.5 * vp->getActualHeight());
	mRectangle->setCorners(-1 + hOffset, 1 - vOffset, 1 + hOffset, -1 - vOffset);
	return mRectangle;
}
コード例 #23
0
//-----------------------------------------------------------------------
Renderable *CompositorManager::_getTexturedRectangle2D()
{
    if(!mRectangle)
    {
        /// 2D rectangle, to use for render_quad passes
        mRectangle = OGRE_NEW Rectangle2D(true, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
    }
    RenderSystem* rs = Root::getSingleton().getRenderSystem();
    Viewport* vp = rs->_getViewport();
    Real hOffset = rs->getHorizontalTexelOffset() / (0.5f * vp->getActualWidth());
    Real vOffset = rs->getVerticalTexelOffset() / (0.5f * vp->getActualHeight());
    mRectangle->setCorners(-1 + hOffset, 1 - vOffset, 1 + hOffset, -1 - vOffset);
    return mRectangle;
}
コード例 #24
0
ファイル: main.cpp プロジェクト: hujiajie/KnowledgeBase
int main()
{
  Root *root = new Root(StringUtil::BLANK, StringUtil::BLANK);
  GLPlugin *glPlugin = new GLPlugin();
  root->installPlugin(glPlugin);
  RenderSystem *renderSystem = root->getAvailableRenderers().at(0);
  renderSystem->setConfigOption("Fixed Pipeline Enabled", "No");
  root->setRenderSystem(renderSystem);
  root->initialise(false);
  RenderWindow *window = root->createRenderWindow("Hello, OGRE", 800, 600, false);
  SceneManager *sceneManager = root->createSceneManager(ST_GENERIC);
  ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
  RTShader::ShaderGenerator::initialize();
  RTShader::ShaderGenerator::getSingleton().addSceneManager(sceneManager);

  createSphereMesh("SphereMesh", 10.f, 16, 16);
  ResourceGroupManager::getSingleton().addResourceLocation("shader", "FileSystem");
  createSphereMaterial("SphereMaterial", 1.f, 0.f, 0.f);

  Camera *camera = sceneManager->createCamera("Camera");
  camera->setPosition(0.f, 0.f, 80.f);
  camera->lookAt(0.f, 0.f, 0.f);
  camera->setNearClipDistance(5.f);
  Viewport *viewport = window->addViewport(camera);
  viewport->setBackgroundColour(ColourValue(0.f, 0.f, 0.f));
  viewport->setMaterialScheme(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
  camera->setAspectRatio((Real)(viewport->getActualWidth()) / (Real)(viewport->getActualHeight()));

  sceneManager->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
  Light *light = sceneManager->createLight("Light");
  light->setPosition(50.f, 50.f, 50.f);

  Entity *sphereEntity = sceneManager->createEntity("SphereEntity", "SphereMesh");
  sphereEntity->setMaterialName("SphereMaterial");
  SceneNode *sphereNode = sceneManager->getRootSceneNode()->createChildSceneNode();
  sphereNode->attachObject(sphereEntity);

  HelloOgreFrameListener *frameListener = new HelloOgreFrameListener(window);
  root->addFrameListener(frameListener);
  root->startRendering();

  delete frameListener;
  delete root;
  delete glPlugin;

  return 0;
}
コード例 #25
0
void GameState::onLeftPressed(const OIS::MouseEvent &evt)
{
    Viewport* vp = m_pSceneMgr->getCurrentViewport();

    float x = evt.state.X.abs/float(vp->getActualWidth());
    float z = 0;
    float y = evt.state.Y.abs/float(vp->getActualHeight());

    Ogre::Ray mouseRay = m_pCamera->getCameraToViewportRay(x, y);
    mRaySceneQuery->setRay(mouseRay);

    Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
    Ogre::RaySceneQueryResult::iterator itr = result.begin( );

    // Get results, create a node/entity on the position
    if (itr != result.end() && itr->worldFragment) {
        m_pNpc01->addLocation(Ogre::Vector3(-100.0f,0.0f,-100.0f));
        // m_pNpc01->addLocation(itr->worldFragment->singleIntersection);
    }
}
コード例 #26
0
void BaseApplication::createScene()
{

    mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");


    SceneNode *mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "mNode1", Vector3( 0, 0, 0 ) );
    //std::cout << "OUCHHHHHHHHHHH" << std::endl;
    mCamera = mSceneMgr->createCamera("Camera");
    Viewport* vp = mWindow->addViewport(mCamera);

    vp->setBackgroundColour(ColourValue(0,0,0));
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) );

    // Position it at 500 in Z direction
    mCamera->setPosition(Vector3( 0, 10, 500));
    mCamera->lookAt(Vector3(0,0,0));
    mCamera->setNearClipDistance(5);

    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
    // Create a light
    Ogre::Light* l = mSceneMgr->createLight("MainLight");
    l->setPosition(20, 80, 50);

    try{
            loader = new DotSceneLoader();
               loader->parseDotScene(mSceneFilePath, "General", mSceneMgr, mNode);
         //DSL->parseDotScene(,"General",mSceneMgr,mNode);
        }catch(Ogre::Exception& e){
            std::cout << "OUCHHHHHHHHHHH" << std::endl;
        }

//    Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");

//    Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
//    headNode->attachObject(ogreHead);

}
コード例 #27
0
ファイル: ogreapp.cpp プロジェクト: dorgonman/cocos2d-x-ogre
void OgreApp::createViewports(void){
	// Create one viewport, entire window
	Viewport* vp = mWindow->addViewport(mCamera);
	vp->setBackgroundColour(ColourValue(0.0,0.0,0.3));

	// Alter the camera aspect ratio to match the viewport
	mCamera->setAspectRatio(
			Real(vp->getActualWidth()) / Real(vp->getActualHeight()));

#if( CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID )
	Ogre::RTShader::ShaderGenerator::initialize();
	Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
	gMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
	Ogre::MaterialManager::getSingleton().addListener(gMatListener);

	Ogre::RTShader::ShaderGenerator::getSingletonPtr()->addSceneManager(mSceneMgr);

	vp->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);    
	Ogre::RTShader::ShaderGenerator::getSingletonPtr()->invalidateScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
#endif

}
コード例 #28
0
    //-----------------------------------------------------------------------
    Real DistanceLodStrategy::getValueImpl(const MovableObject *movableObject, const Ogre::Camera *camera) const
    {
        // Get squared depth taking into account bounding radius
        // (d - r) ^ 2 = d^2 - 2dr + r^2, but this requires a lot 
        // more computation (including a sqrt) so we approximate 
        // it with d^2 - r^2, which is good enough for determining 
        // lod.
        Real squaredDepth = movableObject->getParentNode()->getSquaredViewDepth(camera) - Math::Sqr(movableObject->getBoundingRadius());

        // Check if reference view needs to be taken into account
        if (mReferenceViewEnabled)
        {
            // Reference view only applicable to perspective projection
            assert(camera->getProjectionType() == PT_PERSPECTIVE && "Camera projection type must be perspective!");

            // Get camera viewport
            Viewport *viewport = camera->getViewport();

            // Get viewport area
            Real viewportArea = static_cast<Real>(viewport->getActualWidth() * viewport->getActualHeight());

            // Get projection matrix (this is done to avoid computation of tan(fov / 2))
            const Matrix4& projectionMatrix = camera->getProjectionMatrix();

            // Compute bias value (note that this is similar to the method used for PixelCountLodStrategy)
            Real biasValue = viewportArea * projectionMatrix[0][0] * projectionMatrix[1][1];

            // Scale squared depth appropriately
            squaredDepth *= (mReferenceViewValue / biasValue);
        }

        // Squared depth should never be below 0, so clamp
        squaredDepth = std::max(squaredDepth, Real(0));

        // Now adjust it by the camera bias and return the computed value
        return squaredDepth * camera->_getLodBiasInverse();
    }
コード例 #29
0
void GPUSurfApplication::createScene(void) 
{
	//configure camera
	Viewport* vp = mWindow->getViewport(0);
	mCamera->setAspectRatio((float) vp->getActualWidth() / (float) vp->getActualHeight());	
	vp->setCamera(mCamera);

	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
	mSceneMgr->setSkyBox(true, "Examples/Grid", 50);
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.6,0.6,0.6));
	mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

    Ogre::Light* light =  mSceneMgr->createLight("SunLight");
	light->setPosition(Ogre::Vector3(150, 100, -150) );

	mSceneMgr->getRootSceneNode()->createChild("mesh")->setScale(20, 20, 20);
	
	createWebcamMaterial();
	createWebcamPlane(300.0f); //45000.0f

	Ogre::Vector2 dim = mVideo->getDimensions();
	mGPUSurf->init(dim.x, dim.y);
	mGPUSurf->createOverlays();
}
コード例 #30
0
ファイル: main.cpp プロジェクト: Jungmu/OgreStudy
	void go(void)
	{
		// OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
		mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
		mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif


		// 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
		if (!mRoot->restoreConfig()) {
			if (!mRoot->showConfigDialog()) return;
		}

		mWindow = mRoot->initialise(true, CLIENT_DESCRIPTION " : Copyleft by Dae-Hyun Lee");

		mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "main");
		mCamera = mSceneMgr->createCamera("main");


		mCamera->setPosition(0.0f, 150.0f, 1000.0f);
		mCamera->lookAt(0.0f, 100.0f, 0.0f);

		mViewport = mWindow->addViewport(mCamera);
		mViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.5f));
		mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));


		ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

		mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));

		// 좌표축 표시
		Ogre::Entity* mAxesEntity = mSceneMgr->createEntity("Axes", "axes.mesh");
		mSceneMgr->getRootSceneNode()->createChildSceneNode("AxesNode", Ogre::Vector3(0, 0, 0))->attachObject(mAxesEntity);
		mSceneMgr->getSceneNode("AxesNode")->setScale(5, 5, 5);

		_drawGridPlane();


		Entity* entity1 = mSceneMgr->createEntity("Ninja", "ninja.mesh");
		SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Ninja", Vector3(-100.0f, 0.0f, 0.0f));
		node1->attachObject(entity1);

		Entity* entity2 = mSceneMgr->createEntity("Professor", "DustinBody.mesh");
		SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Professor", Vector3(200.0f, 0.0f, 200.0f));
		node2->attachObject(entity2);


#if 0
		Entity* entity2 = mSceneMgr->createEntity("Ninja", "ninja.mesh");
		SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Ninja", Vector3(0.0f, 0.0f, 0.0f));
		node2->attachObject(entity2);
		node2->setOrientation(Ogre::Quaternion(Ogre::Degree(180), Ogre::Vector3::UNIT_Y));
#endif

		size_t windowHnd = 0;
		std::ostringstream windowHndStr;
		OIS::ParamList pl;
		mWindow->getCustomAttribute("WINDOW", &windowHnd);
		windowHndStr << windowHnd;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
		pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
		pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
		mInputManager = OIS::InputManager::createInputSystem(pl);


		mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
		mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));

		InputController* inputController = new InputController(mRoot, mKeyboard, mMouse);
		mRoot->addFrameListener(inputController);


		ProfessorController* professorController = new ProfessorController(mRoot);
		mRoot->addFrameListener(professorController);

		mRoot->startRendering();

		mInputManager->destroyInputObject(mKeyboard);
		mInputManager->destroyInputObject(mMouse);
		OIS::InputManager::destroyInputSystem(mInputManager);

		delete professorController;
		delete inputController;

		delete mRoot;
	}