Esempio n. 1
0
void CsCameraManager::SetupDefaultCamera() {
	//for proper orientation
	Ogre::Quaternion q(Ogre::Radian(Ogre::Degree(0.0)), Ogre::Vector3::UNIT_Z);
	
	// Free movable Camera
	mDefaultCamNode  =  mSceneMgr->createSceneNode("DefaultCamNode");

	mDefaultCam = mSceneMgr->createCamera("DefaultCam");

	mDefaultCam->setNearClipDistance(0.1);
	mDefaultCam->setFarClipDistance(5000);

	mDefaultCam->setAspectRatio(Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight()));
	mDefaultCam->setPosition(0,0,0);
	mDefaultCam->setFixedYawAxis(false);

	mDefaultCamNode->translate(0, 200, -600);
	mDefaultCamNode->setFixedYawAxis(false);
	//mDefaultCamNode->lookAt(Ogre::Vector3(0,0,0), Ogre::Node::TS_LOCAL);

	mDefaultCamNode->attachObject(mDefaultCam);
	
	AddCamera(mDefaultCam, Chaos::FREE_CAMERA);
	mCurrentCamera = mCameraList.size() - 1;
	
	ApplyCamera();
	mViewport->setCamera(mCameraList[mCurrentCamera].first);

	Ogre::SceneNode *orbitNode = mSceneMgr->createSceneNode("OrbitCamera");
	Ogre::Camera *orbitCam = mSceneMgr->createCamera("OrbitCamera");
	orbitCam->setAspectRatio(Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight()));
	orbitCam->setFixedYawAxis(true);
	orbitNode->attachObject(orbitCam);
	orbitNode->setInheritOrientation(false);

	AddCamera(orbitCam, Chaos::ORBIT_CAMERA);

}
Esempio n. 2
0
void OgreApplication::InitViewport(void){

    try {

        /* Retrieve scene manager and root scene node */
        Ogre::SceneManager* scene_manager = ogre_root_->createSceneManager(Ogre::ST_GENERIC, "MySceneManager");
        Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();

        /* Create camera object */
        Ogre::Camera* camera = scene_manager->createCamera("MyCamera");
        Ogre::SceneNode* camera_scene_node = root_scene_node->createChildSceneNode("MyCameraNode");
        camera_scene_node->attachObject(camera);

		camera->setNearClipDistance(camera_near_clip_distance_g);
        camera->setFarClipDistance(camera_far_clip_distance_g); 

		camera->setPosition(camera_position_g);
		camera->lookAt(camera_look_at_g);
		camera->setFixedYawAxis(true, camera_up_g);

        /* Create viewport */
        Ogre::Viewport *viewport = ogre_window_->addViewport(camera, viewport_z_order_g, viewport_left_g, viewport_top_g, viewport_width_g, viewport_height_g);

        viewport->setAutoUpdated(true);
        viewport->setBackgroundColour(viewport_background_color_g);

		/* Set aspect ratio */
		float ratio = float(viewport->getActualWidth()) / float(viewport->getActualHeight());
        camera->setAspectRatio(ratio);
    }
    catch (Ogre::Exception &e){
        throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what())));
    }
    catch(std::exception &e){
        throw(OgreAppException(std::string("std::Exception: ") + std::string(e.what())));
    }
}
Esempio n. 3
0
void test()
{
	Ogre::Root* pOgre = new Ogre::Root("", "");

    pOgre->loadPlugin(RENDER_SYSTEM);
	pOgre->setRenderSystem(pOgre->getAvailableRenderers().front());

	pOgre->initialise(false);
	
	Ogre::NameValuePairList lArgs;
	//lArgs["externalWindowHandle"] = bk::format("%d", (bk::uint)l_window.get_handle()).astr;
	Ogre::RenderWindow* pWindow = pOgre->createRenderWindow("Heart|Dockyard", 1024, 768, false, &lArgs);

	Ogre::SceneManager* pSceneManager = pOgre->createSceneManager(Ogre::ST_GENERIC,"SceneManager");
	pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
	pSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
	pSceneManager->setAmbientLight(Ogre::ColourValue(0.1f, 0.1f, 0.1f));

	Ogre::Camera* pCamera = pSceneManager->createCamera("Camera");
	pCamera->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
	pCamera->setPosition(Ogre::Vector3(0.0f, 50.0f, 20.0f));
	pCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f)); 
	pCamera->setNearClipDistance(0.1f);
	pCamera->setFarClipDistance(100.0f);
	Ogre::Viewport* pViewport = pWindow->addViewport(pCamera);
	pViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
	pCamera->setAspectRatio(Ogre::Real(pViewport->getActualWidth()) / Ogre::Real(pViewport->getActualHeight()));

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data/dockyard.zip", "Zip", "Dockyard", true);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	Ogre::MeshManager::getSingleton().createPlane("GroundPlane", "Dockyard", Ogre::Plane(0.0f, 0.0f, 1.0f, 0.0f), 100.0f, 100.0f, 100, 100, true, 1, 3.0f, 3.0f);
	Ogre::Entity* pGroundEntity = pSceneManager->createEntity("GroundPlane");
	pGroundEntity->setMaterialName("Examples/Rockwall");
	pGroundEntity->setCastShadows(false);
	pGroundEntity->getSubEntity(0)->getMaterial()->setShadingMode(Ogre::SO_PHONG);
	Ogre::SceneNode* pGroundNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
	pGroundNode->attachObject(pGroundEntity);

	Ogre::Entity* pCubeEntity = pSceneManager->createEntity("Cube", Ogre::SceneManager::PT_CUBE);
	pCubeEntity->setMaterialName("Examples/10PointBlock");
	pCubeEntity->setCastShadows(true);
	Ogre::SceneNode* pCubeNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
	pCubeNode->attachObject(pCubeEntity);
	pCubeNode->setPosition(0.0f, 0.0f, 5.f);
	pCubeNode->setScale(0.1f, 0.1f, 0.1f);

	Ogre::ColourValue lColour1(1.0f, 1.0f, 1.0f);
	Ogre::ColourValue lColour2(1.0f, 1.0f, 1.0f);
	Ogre::ColourValue lColour3(1.0f, 1.0f, 1.0f);
	Ogre::Light* pLight1 = pSceneManager->createLight();
	pLight1->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight1->setPosition(30.0f, 30.0f, 30.0f);
	pLight1->setDirection(-1.0f, -1.0f, -1.0f);
	pLight1->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight1->setDiffuseColour(lColour1 * 0.5f);
	Ogre::Light* pLight2 = pSceneManager->createLight();
	pLight2->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight2->setPosition(-30.0f, 30.0f, 30.0f);
	pLight2->setDirection(1.0f, -1.0f, -1.0f);
	pLight2->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight2->setDiffuseColour(lColour2 * 0.5f);
	Ogre::Light* pLight3 = pSceneManager->createLight();
	pLight3->setType(Ogre::Light::LT_SPOTLIGHT);
	pLight3->setPosition(30.0f, -30.0f, 30.0f);
	pLight3->setDirection(-1.0f, 1.0f, -1.0f);
	pLight3->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
	pLight3->setDiffuseColour(lColour3 * 0.5f);

	Ogre::Overlay* pMenuOverlay = Ogre::OverlayManager::getSingleton().create("Menu");
	Ogre::OverlayElement* pMenu = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Menu");
    pMenu->setMetricsMode(Ogre::GMM_PIXELS);
    pMenu->setWidth(200);
    pMenu->setHeight(200);
    pMenu->setTop(30);
    pMenu->setLeft(30);
    pMenu->setMaterialName("Examples/BumpyMetal");
	if (pMenu->isContainer()) pMenuOverlay->add2D(static_cast<Ogre::OverlayContainer*>(pMenu));
	pMenuOverlay->show();

	pOgre->startRendering();
}
Esempio n. 4
0
//Ogre::Camera::setFixedYawAxis(bool, Ogre::Vector3 const&)
void camera_set_fixed_yaw_axis(CameraHandle handle, int on, const coiVector3* fixed_axis)
{
    Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
    Ogre::Vector3 axis(fixed_axis->x, fixed_axis->y, fixed_axis->z);
    camera->setFixedYawAxis(on, axis);
}