本文整理汇总了C++中ogre::Root::createSceneManager方法的典型用法代码示例。如果您正苦于以下问题:C++ Root::createSceneManager方法的具体用法?C++ Root::createSceneManager怎么用?C++ Root::createSceneManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Root
的用法示例。
在下文中一共展示了Root::createSceneManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testModelMountScaling
void ModelMountTestCase::testModelMountScaling()
{
Ogre::Root root;
Ogre::SceneManager* sceneManager = root.createSceneManager(Ogre::ST_GENERIC);
TestModel model(*sceneManager);
//First test with a straight forward case.
Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode();
//We get an error when it's destroyed. So we don't destroy it.
SceneNodeProvider* nodeProvider = new SceneNodeProvider(node, nullptr);
Model::ModelMount mount(model, nodeProvider);
scaleAndTestMount(model, mount, nodeProvider->getNode());
//Test with the parent node being scaled
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
Ogre::SceneNode* subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount2(model, nodeProvider);
scaleAndTestMount(model, mount2, nodeProvider->getNode());
//Test with the parent node being scaled and rotated
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
node->yaw(Ogre::Degree(42));
node->pitch(Ogre::Degree(76));
node->roll(Ogre::Degree(98));
subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount3(model, nodeProvider);
scaleAndTestMount(model, mount3, nodeProvider->getNode());
}
示例2:
void
TestScene5::runOgre()
{
// initialize framework & open window
Ogre::Root* root = new Ogre::Root();
root->restoreConfig();
root->initialise(false);
auto window = root->createRenderWindow("Ogre RenderWindow", 800, 600, false);
auto sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
// adjust camera
auto cam1 = sceneMgr->createCamera("cam1");
auto camNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode1");
cam1->setNearClipDistance(5);
camNode1->attachObject(cam1);
camNode1->setPosition(100, 100, 100);
camNode1->lookAt(Ogre::Vector3(-1, -1, -1), Ogre::Node::TS_LOCAL);
window->addViewport(cam1);
// load & integrate model
root->addResourceLocation("./resources/Ogre", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
auto model = sceneMgr->createEntity("model", "alexandria.mesh");
auto modelNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
modelNode->attachObject(model);
// position model
modelNode->setPosition(-100, -100, -100);
// loop
runOgreLoop(root);
}
示例3: startup
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
if(!_root->showConfigDialog()){
return -1;
}
Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera* camera = _sceneManager->createCamera("Camera");
camera->setPosition(Ogre::Vector3(500,100,500));
camera->lookAt(Ogre::Vector3(0,0,0));
camera->setNearClipDistance(5);
Ogre::Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()/viewport->getActualHeight()));
_listener = new FrameListenerProyectos(window,camera);
_root->addFrameListener(_listener);
loadResources();
createScene();
_root->startRendering();
return 0;
}
示例4: main
int main(int argc, char* argv[]){
cout << "Test Ogre Program blaha" << endl;
//Relative to where its executed from, not binary location
Ogre::Root *mRoot = new Ogre::Root("configs/plugins.cfg","configs/config.cfg","logs/main.log");
if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())){
delete mRoot;
return -1;
}
// setup resources
// Only add the minimally required resource locations to load up the Ogre head mesh
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs/GLSL", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/scripts", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/textures", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/models", "FileSystem", "General");
//Create the window
Ogre::RenderWindow *mWindow = mRoot->initialise(true, "initial Render Window");
Ogre::SceneManager *sceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera *camera = sceneManager->createCamera("PlayerCam");
camera->setPosition(Ogre::Vector3(0,0,80));
camera->lookAt(Ogre::Vector3(0,0,-300));
camera->setNearClipDistance(5);
Ogre::Viewport* vp = mWindow->addViewport(camera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::Entity* ogreHead = sceneManager->createEntity("Head","ogreHead.mesh");
Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);
sceneManager->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));
//Run the system
bool continueRunning = true;
while(continueRunning){
mRoot->renderOneFrame();
headNode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(0.005));
if(mWindow->isClosed()){
continueRunning = false;
}
}
delete mRoot;
}
示例5: startup
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
if(!_root->showConfigDialog()){
return -1;
}
_window = _root->initialise(true,"Collision Object Exporter");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
loadResources();
createScene();
_root->startRendering();
return 0;
}
示例6: startup
//Funcion que inicializa la aplicacion
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
//Muestra la ventana inicial...
//if(!_root->showConfigDialog()){
// return -1;
//}
// Evitan cargar la ventana inicial...
Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
_root->setRenderSystem(_rs);
_rs->setConfigOption("Full Screen", "No");
_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
_rs->setConfigOption("FSAA", "0");
_rs->setConfigOption("Floating-point mode", "Fastest");
_rs->setConfigOption("Use Multihead", "Auto");
_rs->setConfigOption("VSync", "No");
_rs->setConfigOption("VSync Interval", "1");
Ogre::RenderWindow* window = _root->initialise(true,"Ventana de Ogre3D");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
loadResources();
createScene();
createCamera(window);
_listener = new AppFrameListener(window,camera,_sceneManager);
_root->addFrameListener(_listener);
//_root->startRendering();
return 0;
}
示例7: M
void
TestScene12::runOgre()
{
// initialize framework & open window
Ogre::Root* root = new Ogre::Root();
root->restoreConfig();
root->initialise(false);
auto window = root->createRenderWindow("Ogre RenderWindow", 800, 600, false);
auto sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
// adjust camera
auto cam1 = sceneMgr->createCamera("cam1");
auto camNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode1");
cam1->setNearClipDistance(5);
camNode1->attachObject(cam1);
camNode1->setPosition(Ogre::Vector3(100, 100, 100));
camNode1->lookAt(Ogre::Vector3(-1, -1, -1), Ogre::Node::TS_LOCAL);
window->addViewport(cam1);
// load & integrate model
root->addResourceLocation("./resources/Ogre", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Mesh_Cube M(1);
M.createMesh("cube");
Ogre::SceneNode* groups[ROWS];
std::list<Ogre::SceneNode*> nodes;
for (int i = 0; i < ROWS; i++)
{
groups[i] = sceneMgr->getRootSceneNode()->createChildSceneNode();
nodes.push_back(groups[i]);
}
for (int i = 0; i < ROWS * COLS; i++)
{
auto node = groups[i % ROWS]->createChildSceneNode();
node->attachObject(sceneMgr->createEntity(std::string("model") + boost::lexical_cast<std::string>(i), "cube"));
node->setPosition(
camNode1->getOrientation() * -Ogre::Vector3::UNIT_X * LEFT(i)
+ camNode1->getOrientation() * Ogre::Vector3::UNIT_Y * UP(i)
);
}
root->addFrameListener(new MoveObjectTask_Ogre12(nodes));
// loop
runOgreLoop(root);
}
示例8:
void
TestScene3::runOgre()
{
// initialize framework & open window
Ogre::Root* root = new Ogre::Root();
root->restoreConfig();
root->initialise(false);
auto window = root->createRenderWindow("Ogre RenderWindow", 800, 600, false);
auto sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
// adjust camera
auto cam1 = sceneMgr->createCamera("cam1");
auto camNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode1");
cam1->setNearClipDistance(5);
camNode1->attachObject(cam1);
camNode1->setPosition(100, 100, 100);
camNode1->lookAt(Ogre::Vector3(-1, -1, -1), Ogre::Node::TS_LOCAL);
window->addViewport(cam1);
// loop
runOgreLoop(root);
}
示例9: startup
int startup(){
_root = new Ogre::Root("plugins_d.cfg");
/*
if(!_root->showConfigDialog()){
return -1;
}
*/
Ogre::RenderSystem* _rs = _root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
_root->setRenderSystem(_rs);
_rs->setConfigOption("Full Screen", "No");
_rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
_rs->setConfigOption("FSAA", "0");
_rs->setConfigOption("Floating-point mode", "Fastest");
_rs->setConfigOption("Use Multihead", "Auto");
_rs->setConfigOption("VSync", "No");
_rs->setConfigOption("VSync Interval", "1");
Ogre::RenderWindow* window = _root->initialise(true, "Ventana Ogre");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera* camera = _sceneManager->createCamera("Camera");
camera->setPosition(Ogre::Vector3(0.0f,300.0f,-1000.0f));
camera->lookAt(Ogre::Vector3(0,0,0));
camera->setNearClipDistance(5);
Ogre::Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth()/viewport->getActualHeight()));
_listener = new FrameListenerProyectos(window,camera);
_root->addFrameListener(_listener);
loadResources();
createScene();
_root->startRendering();
return 0;
}
示例10: createTriangleScene
/**
* This is the most basic "triangle" example, done as a Scene in Ogre.
*/
Ogre::SceneManager* createTriangleScene() {
Ogre::SceneManager* scene = mRoot->createSceneManager(Ogre::ST_GENERIC);
// Configure camera (~ view & projection transforms, i.e. gluLookAt + glOrtho)
Ogre::Camera* camera = scene->createCamera("MainCamera"); // We can use an arbitrary name here
camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
camera->setOrthoWindow(2, 2); // ~ glOrtho(-1, 1, -1, 1)
camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight());
camera->setNearClipDistance(0.5);
camera->setPosition(Ogre::Vector3(0,0,1)); // Move camera away from (0, 0, 0), otherwise the triangle at z=0 will be clipped
// Now add some geometry to the scene
Ogre::ManualObject* triangle = scene->createManualObject("Triangle");
// ~ glBegin, glVertex, glEnd
// "BaseWhiteNoLighting" is a built-in name for a basic non-lit material
triangle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
triangle->position(0, 0.5, 0); // ~ glVertex.
// Contrary to OpenGL we *first* must create the vertex
triangle->colour(Ogre::ColourValue::Red); // .. and then provide its attributes such as color (~ glColor)
triangle->position(-0.5, -0.5, 0);
triangle->colour(Ogre::ColourValue::Green);
triangle->position(0.5, -0.5, 0);
triangle->colour(Ogre::ColourValue::Blue);
triangle->end();
// Add the created triangle object to the scene graph
// For this we create a SceneNode object, which will combine information about
// the object's geometry with its modeling transform
// (see frameRenderingQueued to understand how to rotate the triangle by changing this transform)
scene->getRootSceneNode()->createChildSceneNode("Triangle")->attachObject(triangle);
// Exercise 1: Create new object, add vertices, attach the object to a new SceneNode
// ...
return scene;
}
示例11: EngineSetup
void CSceneEditorView::EngineSetup(void)
{
Ogre::Root *Root = ((CSceneEditorApp*)AfxGetApp())->m_Engine->GetRoot();
m_SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "SceneEditor");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("SceneEditor");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("SceneEditor", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = m_SceneManager->createCamera("Camera");
m_Camera->setPosition(Ogre::Vector3(1683, 50, 2116));
m_Camera->lookAt(Ogre::Vector3(0, 0, 0));
m_Camera->setNearClipDistance(0.1);
m_Camera->setFarClipDistance(50000);
if (m_Root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
{
m_Camera->setFarClipDistance(0); // enable infinite far clip distance if we can
}
m_Camera->setAutoTracking(false);
m_Camera->setFixedYawAxis(true);
m_Camera->yaw(Ogre::Radian(0));
m_Camera->pitch(Ogre::Radian(0));
Ogre::SceneNode *CameraNode = NULL;
CameraNode = m_SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
//Create viewport
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
m_SceneManager->setSkyDome(true, "Examples/CloudySky", 5, 8);
Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
lightdir.normalise();
Ogre::Light* light = m_SceneManager->createLight("tstLight");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(lightdir);
light->setDiffuseColour(Ogre::ColourValue::White);
light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(m_SceneManager, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
mTerrainGroup->setFilenameConvention(Ogre::String("Terrain"), Ogre::String("dat"));
mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
configureTerrainDefaults(light);
for (long x = 0; x <= 0; ++x)
for (long y = 0; y <= 0; ++y)
defineTerrain(x, y);
// sync load since we want everything in place when we start
mTerrainGroup->loadAllTerrains(true);
if (mTerrainsImported)
{
Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
//.........这里部分代码省略.........
示例12: choose_scene_mgr
void application::choose_scene_mgr()
{
scene_mgr = root->createSceneManager(Ogre::ST_GENERIC);
overlay = new Ogre::OverlaySystem();
scene_mgr->addRenderQueueListener(overlay);
}
示例13: EngineSetup
void CManualObjectView::EngineSetup(void)
{
Ogre::Root *Root = ((CManualObjectApp*)AfxGetApp())->m_Engine->GetRoot();
m_SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "m_ManualObject");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("m_ManualObject");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("m_ManualObject", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = m_SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(200.0, 50.0, 100.0));
m_Camera->lookAt(0.0, 0.0, 0.0);
Ogre::SceneNode *CameraNode = NULL;
CameraNode = m_SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
CreateManualObject();
Ogre::AxisAlignedBox Box = m_ManualObject->getBoundingBox();
Ogre::Vector3 Center = Box.getCenter();
m_Camera->lookAt(Center);
m_Camera->setPosition(300, 100, 200);
// m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);
Root->renderOneFrame();
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:66,代码来源:ManualObjectView.cpp
示例14: Shutdown
bool
COgreWindowContext::Initialize( const GUI::CString& title ,
const GUI::CVideoSettings& videoSettings ,
const GUI::CString& ogreRenderSystem )
{GUCEF_TRACE;
// Do not initialize twice
Shutdown();
// First create a regular O/S window
if ( m_osWindow->WindowCreate( title ,
0 ,
0 ,
videoSettings.GetResolutionWidthInPixels() ,
videoSettings.GetResolutionHeightInPixels() ) )
{
// Display the new window
m_osWindow->Show();
m_osWindow->SendToForegound();
m_osWindow->GrabFocus();
// Now proceed with setting up the Ogre specifics
// We grab the O/S window identifier 'the handle'
// This is passed to Ogre to tie things together
CORE::Int64 windowRef = 0;
CORE::CString windowIntStr = m_osWindow->GetProperty( "WINDOWINT" );
if ( !windowIntStr.IsNULLOrEmpty() )
{
windowRef = CORE::StringToInt64( windowIntStr );
}
Ogre::NameValuePairList options;
options[ "externalWindowHandle" ] = Ogre::StringConverter::toString( (size_t) windowRef );
Ogre::Root* ogreRoot = Ogre::Root::getSingletonPtr();
if ( ogreRoot == nullptr )
{
ogreRoot = OGRE_NEW Ogre::Root( "", "", "" );
}
if ( !ogreRoot->isInitialised() )
{
// Load any Ogre plugins not loaded yet from the bootstrap group
CORE::CCoreGlobal::Instance()->GetPluginControl().LoadPluginGroup( "Ogre" );
const Ogre::RenderSystemList& rsList = ogreRoot->getAvailableRenderers();
if ( rsList.size() == 0 )
{
GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: No Ogre render systems are available, cannot initialize" );
return false;
}
Ogre::RenderSystem* renderSystem = nullptr;
Ogre::RenderSystemList::const_iterator i = rsList.begin();
while ( i != rsList.end() )
{
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Available Ogre render system: " + (*i)->getFriendlyName() );
if ( ogreRenderSystem == (*i)->getName() )
{
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Found desired/preferred Ogre render system: " + (*i)->getFriendlyName() );
renderSystem = (*i);
}
++i;
}
if ( renderSystem == nullptr )
{
GUCEF_WARNING_LOG( CORE::LOGLEVEL_IMPORTANT, "OgreWindowContext: Preferred Ogre render systems not available, using first available alternative: " + (*rsList.begin())->getFriendlyName() );
renderSystem = *rsList.begin();
}
ogreRoot->setRenderSystem( renderSystem );
m_sceneManager = ogreRoot->createSceneManager( Ogre::ST_GENERIC );
m_renderWindow = ogreRoot->initialise( false, title );
}
m_renderWindow = ogreRoot->createRenderWindow( title,
videoSettings.GetResolutionWidthInPixels(),
videoSettings.GetResolutionHeightInPixels(),
videoSettings.GetFullscreenState(),
&options );
// Grab the main app pulse generator and set the update interval for the context to the desired refresh rate
CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator();
pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() );
SubscribeTo( &pulseGenerator );
GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Succesfully created Ogre rendering context" );
m_initialized = true;
return true;
}
return false;
}
示例15: test
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();
}