Example #1
0
void ClientApplication::run()
{
    Ogre::Root* root = mGraphicsManager->getRoot();
    Ogre::RenderWindow* window = mGraphicsManager->getWindow();

    root->getRenderSystem()->_initRenderTargets();
    root->clearEventTimes();

    boost::timer timer;

    while( !mShutdown )
    {
        if( mShutdownRequested )
        {
            mStateMachine->popTo( 0 );
            mShutdown = true;
        }

        const Real elapsed = timer.elapsed();
        timer.restart();

        mEarlyUpdateSignal();
        mEarlyFrameSignal( elapsed );
        mUpdateSignal();
        mFrameSignal( elapsed );
        mLateUpdateSignal();
        mLateFrameSignal( elapsed );

        Ogre::WindowEventUtilities::messagePump();

        // Render even when the window is inactive.
        if( window->isActive() )
        {
            root->renderOneFrame();
        }
        else if( window->isVisible() )
        {
            root->renderOneFrame();
            window->update();

#if DIVERSIA_PLATFORM == DIVERSIA_PLATFORM_WIN32
            Sleep( ( 1.0 / 60.0 ) * 1000.0 );
#else
            usleep( ( 1.0 / 60.0 ) * 1000000.0 );
#endif
        }
        else if( !window->isActive() && !window->isVisible() )
        {
#if DIVERSIA_PLATFORM == DIVERSIA_PLATFORM_WIN32
            Sleep( ( 1.0 / 60.0 ) * 1000.0 );
#else
            usleep( ( 1.0 / 60.0 ) * 1000000.0 );
#endif
        }
    }
}
void COrbitViewView::OnMouseMove(UINT nFlags, CPoint point)
{
	Ogre::Vector3 CameraMove(0.0, 0.0, 0.0);

	CEngine * Engine = ((COrbitViewApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
	  return;
	Ogre::Root *Root = Engine->GetRoot();
	if (m_Camera == NULL)
	  return;

	if (m_MouseNavigation)
	{
	if (m_Orbit)
	{
		Ogre::SceneNode* CameraNode = m_SceneManager->getSceneNode("CameraNode");
		CameraMove[1] = m_MousePosition.y - point.y;
		m_Camera->moveRelative(CameraMove);
		CameraNode->yaw(Ogre::Radian(0.01 * (m_MousePosition.x - point.x)));
	}
	else
	{
		CameraMove[0] = -(m_MousePosition.x - point.x);
		CameraMove[1] = m_MousePosition.y - point.y;
		m_Camera->moveRelative(CameraMove);
	}

		m_MousePosition = point;
		Root->renderOneFrame();
	}

	CView::OnMouseMove(nFlags, point);
}
void CUsingControllersView::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_MouseNavigation)
	{
	Ogre::Vector3 CameraMove(0.0, 0.0, 0.0);

	CameraMove[0] = -(m_MousePosition.x - point.x);
	CameraMove[1] = m_MousePosition.y - point.y;

	CEngine * Engine = ((CUsingControllersApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
		return;
	Ogre::Root *Root = Engine->GetRoot();
	if (m_Camera == NULL)
		return;
	Ogre::Vector3 OldPosition = m_Camera->getPosition();
	m_Camera->moveRelative(CameraMove);
		
	m_MousePosition = point;

	Root->renderOneFrame();
	}

	CView::OnMouseMove(nFlags, point);
}
void CGeoImageView::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	switch (nChar)
	{
	case 'W':

		m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);

		break;

	case 'S':

		m_Camera->setPolygonMode(Ogre::PM_SOLID);

		break;

	case 'P':

		m_Camera->setPolygonMode(Ogre::PM_POINTS);

		break;
	}

	Ogre::Root *Root = ((CGeoImageApp*)AfxGetApp())->m_Engine->GetRoot();
	Root->renderOneFrame();

	CView::OnSysKeyDown(nChar, nRepCnt, nFlags);
}
void CUsingControllersView::OnTimer(UINT_PTR nIDEvent)
{
	CEngine *Engine = ((CUsingControllersApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();
    Root->renderOneFrame();

	CView::OnTimer(nIDEvent);
}
Example #6
0
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;
}
void COrbitViewView::OnTimer(UINT_PTR nIDEvent)
{
	m_WalkAnimation->addTime(0.001);

	CEngine *Engine = ((COrbitViewApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();
    Root->renderOneFrame();

	CView::OnTimer(nIDEvent);
}
void CManualObjectView::OnActionsReset()
{
	for (int Index = 0; Index < m_ManualObject->getNumSections(); Index++)
	{
		m_ManualObject->setMaterialName(Index, Materials[Index]);
	}

	Ogre::Root *Root = ((CManualObjectApp*)AfxGetApp())->m_Engine->GetRoot();
	Root->renderOneFrame();
}
void CLinkedAnimationView::OnTimer(UINT_PTR nIDEvent)
{
	CEngine *Engine = ((CLinkedAnimationApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();

	m_AnimationState1->addTime(0.01);
	m_AnimationState2->addTime(0.01);

	Root->renderOneFrame();
	CView::OnTimer(nIDEvent);
}
void CBlendingAnimationsView::OnTimer(UINT_PTR nIDEvent)
{
	CEngine *Engine = ((CBlendingAnimationsApp*)AfxGetApp())->m_Engine;			
	Ogre::Root *Root = Engine->GetRoot();
	Ogre::SceneNode *RobotNode = Root->getSceneManager("Walking")->getSceneNode("Robot");

	Ogre::Entity *RobotEntity = Root->getSceneManager("Walking")->getEntity("Robot");
	Ogre::Skeleton *Skeleton = RobotEntity->getSkeleton();

	if (m_WeightDlg->m_IsAverage)
	{
		Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE);
	}
	else
	{
		Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE);
	}

	double WalkWeight;
	double SlumpWeight;

	switch(nIDEvent)
	{
	case 1:
	
		WalkWeight = m_WeightDlg->m_WalkWeight.GetPos() / 10.0;
		SlumpWeight = m_WeightDlg->m_SlumpWeight.GetPos() / 10.0;

		m_WalkAnimation->setWeight(WalkWeight);
		m_SlumpAnimation->setWeight(SlumpWeight);
		
		m_WalkAnimation->addTime(0.01);
		m_SlumpAnimation->addTime(0.01);

		break;
	
	case 2:

		m_WalkAnimation->addTime(0.01);

	break;

	case 3:
		
		m_SlumpAnimation->addTime(0.01);

		break;
	}

	Root->renderOneFrame();
	CView::OnTimer(nIDEvent);
}
void CSceletalAnimationView::OnTimer(UINT_PTR nIDEvent)
{
	CEngine *Engine = ((CSceletalAnimationApp*)AfxGetApp())->m_Engine;		
	Ogre::Root *Root = Engine->GetRoot();
	Ogre::SceneManager *SceneManager = Root->getSceneManager("Animation");
	Ogre::Entity *Entity = SceneManager->getEntity("Animation");
	Ogre::Skeleton *Skeleton = Entity->getSkeleton();

	m_AnimationState->addTime(0.1);
	Root->renderOneFrame();

	CView::OnTimer(nIDEvent);
}
BOOL CTransparentMaterialView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	Ogre::Vector3 CameraMove(0.0, 0.0, 0.0);

	CameraMove[2] = 0.1 * zDelta;

	CEngine * Engine = ((CTransparentMaterialApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
		return false;
	Ogre::Root *Root = Engine->GetRoot();
	if (m_Camera == NULL)
		return false;
	m_Camera->moveRelative(CameraMove);

	Root->renderOneFrame();
	return CView::OnMouseWheel(nFlags, zDelta, pt);
}
Example #13
0
bool GraphicsImpl::doStep()
{
	if (newWorld) {
		boost::mutex::scoped_lock lock(worldMutex);
		std::swap(frontWorld, backWorld);
		newWorld = false;
	}

	gui->injectFrameEntered(timeSinceLastFrame());

	moveScale = timeSinceLastFrame() * 100;
	camera->moveRelative(movementVector * moveScale);
	updatePositions();
	Ogre::WindowEventUtilities::messagePump();
	caelumSystem->notifyCameraChanged(camera);
	return root->renderOneFrame();
}
Example #14
0
		//-----------------------------------------------------------------------------
		bool Engine::Update()
		{
				bool bContinue = !(m_pRenderWnd->isClosed());

				Ogre::WindowEventUtilities::messagePump();
		
				if(m_pRenderWnd->isActive())
				{
						float timeDelta = 0.033f;
						if(!m_pRoot->renderOneFrame(timeDelta))
								bContinue = false;
				}
				else
				{
						Sleep(1000);
				}

				return bContinue;
		}
void CSunControlDlg::OnBnClickedSunAction()
{
	CMainFrame *MainFrame = (CMainFrame *)((CWeatherControlApp*)AfxGetApp())->GetMainWnd();
	CWeatherControlView *View = (CWeatherControlView *)MainFrame->GetActiveView();
  	CEngine *Engine = ((CWeatherControlApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();

	View->m_Sun->setVisible(!View->m_Sun->getVisible());

	if (View->m_Sun->getVisible())
	{
		m_Action.SetWindowTextA("Stop");
		View->SetTimer(ID_SUN_TIMER, 1, 0);
	}
	else
	{
		m_Action.SetWindowTextA("Start");
		View->KillTimer(ID_SUN_TIMER);
	}

	Root->renderOneFrame();
}
void CUsingControllersView::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CView::OnPaint() for painting messages
	CUsingControllersDoc *Document = GetDocument();
	CEngine *Engine = ((CUsingControllersApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
	  return;

	Ogre::Root *Root = Engine->GetRoot();

	if (m_First && Root != NULL)
    {
        m_First = false;
        EngineSetup();
    }

	if (Root != NULL)
    {
       Root->renderOneFrame();
	}
}
void CManualObjectView::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	CManualObjectDoc *Document = GetDocument();
	CEngine *Engine = ((CManualObjectApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
	  return;

	Ogre::Root *Root = Engine->GetRoot();

	if (m_First && Root != NULL)
    {
        m_First = false;
        EngineSetup();
    }

	if (Root != NULL)
    {
       Root->renderOneFrame();
	}

}
void COrbitViewView::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	COrbitViewDoc *Document = GetDocument();
	CEngine *Engine = ((COrbitViewApp*)AfxGetApp())->m_Engine;
	if (Engine == NULL)
	  return;

	Ogre::Root *Root = Engine->GetRoot();

	if (m_First && Root != NULL)
    {
        m_First = false;
        EngineSetup();
    }

	if (Root != NULL)
    {
       Root->renderOneFrame();
	}	
	// Do not call CView::OnPaint() for painting messages
}
Example #19
0
			void renderOneFrame(){
				Ogre::WindowEventUtilities::messagePump();
				_keepRunning = _root->renderOneFrame();
			}
void CUsingControllersView::EngineSetup(void)
{
	Ogre::Root *Root = ((CUsingControllersApp*)AfxGetApp())->m_Engine->GetRoot();
	Ogre::SceneManager *SceneManager = NULL;
	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Walking");
 
    //
    // 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("Mouse Input");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Mouse Input", 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 = 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(0.0, 0.0, 1000.0));
	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));

	Ogre::SceneNode *SphereNode = SceneManager->getRootSceneNode()->createChildSceneNode("Sphere", Ogre::Vector3(0,0,0));
	Ogre::Entity *SphereEntity = SceneManager->createEntity("Sphere", "sphere.mesh");
	SphereEntity->setMaterialName("Wall/Screen");
	SphereNode->attachObject(SphereEntity);
	SphereEntity->getParentNode()->scale(0.2,0.2,0.2);

	m_Camera->lookAt(Ogre::Vector3(0.0, 0.0, 0.0));

#undef new

	Ogre::ControllerFunctionRealPtr func(OGRE_NEW Ogre::WaveformControllerFunction(Ogre::WFT_SINE, 0.0, 1.0));
	Ogre::ControllerValueRealPtr dest(OGRE_NEW SphereScale(SphereNode, 1.0));

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

	Ogre::ControllerManager& ControllerManager = Ogre::ControllerManager::getSingleton();
	m_SphereController = ControllerManager.createController(ControllerManager.getFrameTimeSource(), dest, func);

	Root->renderOneFrame();
}
void CTerrainWalkingView::OnTimer(UINT_PTR nIDEvent)
{
	Ogre::Quaternion Quaternion;
	CEngine *Engine = ((CTerrainWalkingApp*)AfxGetApp())->m_Engine;		
	Ogre::Root *Root = Engine->GetRoot();
	Ogre::SceneNode *RobotNode = Root->getSceneManager("Walking")->getSceneNode("Robot");
	Ogre::Entity *RobotEntity = Root->getSceneManager("Walking")->getEntity("Robot");
	Ogre::AxisAlignedBox RobotBox = RobotEntity->getBoundingBox();

	Ogre::Entity *TopographyEntity = Root->getSceneManager("Walking")->getEntity("Topography");

	Ogre::AxisAlignedBox TopographyBox = TopographyEntity->getBoundingBox();
		
	Ogre::Vector3 Start = TopographyBox.getMinimum();
	Ogre::Vector3 Finish = TopographyBox.getMaximum();

	double x = Start[0] + (Finish[0] - Start[0]) * m_RelativeDistance;
	double y = Start[1] + (Finish[1] - Start[1]) * m_RelativeDistance;
	double z = Start[2] + (Finish[2] - Start[2]) * m_RelativeDistance;
	
	Ogre::Vector3 Elevation(x, y, z);
	Ogre::Vector3 CameraMove;

	switch (nIDEvent)
	{
		case 1:

			m_Animation->addTime(0.01);
			m_RelativeDistance += 0.01;

			if (m_CollisionTools->collidesWithEntity(Elevation, Ogre::Vector3(x,y - 1,z), Ogre::Vector3(x,y + 1,z), 100.0f, 0.0f, 4294967295))
			{
				x = Elevation[0];
				y = Elevation[1] + RobotBox.getSize()[1];
				z = Elevation[2];
			}

			RobotNode->setPosition(x, y, z);
			m_Camera->lookAt(x, y, z);
			
			if (m_RelativeDistance > 1.0)
			  KillTimer(1);

		break;

		case 2:

			CameraMove[0] = -100;
			CameraMove[1] = 0;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

		break;

		case 3:

			CameraMove[0] = 0;
			CameraMove[1] = 100;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;

		case 4:

			CameraMove[0] = 100;
			CameraMove[1] = 0;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;

		case 5:

			CameraMove[0] = 0;
			CameraMove[1] = -100;
			CameraMove[2] = 0;
			m_Camera->moveRelative(CameraMove);

			break;
	}

	Root->renderOneFrame();
	CView::OnTimer(nIDEvent);
}
void CTerrainWalkingView::EngineSetup(void)
{
	Ogre::Root *Root = ((CTerrainWalkingApp*)AfxGetApp())->m_Engine->GetRoot();
	Ogre::SceneManager *SceneManager = NULL;
	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Walking");
 
    //
    // 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("Walking");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Walking", 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 = SceneManager->createCamera("Camera");
    m_Camera->setNearClipDistance(10);
	m_Camera->setFarClipDistance(10000); 
	m_Camera->setCastShadows(false);
	m_Camera->setUseRenderingDistance(true);

	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));

	Ogre::SceneNode *TopographyNode = SceneManager->getRootSceneNode()->createChildSceneNode("Topography");
	Ogre::Entity *TopographyEntity = SceneManager->createEntity("Topography", "Topography.mesh");
	TopographyNode->attachObject(TopographyEntity);
	
	Ogre::AxisAlignedBox TopographyBox = TopographyEntity->getBoundingBox();
	
	Ogre::Vector3 Minimum = TopographyBox.getMinimum();
	Ogre::Vector3 Center = TopographyBox.getCenter();

	Ogre::SceneNode *RobotNode = SceneManager->getRootSceneNode()->createChildSceneNode("Robot");
	Ogre::Entity *RobotEntity = SceneManager->createEntity("Robot", "robot.mesh");
	RobotNode->attachObject(RobotEntity);
	RobotEntity->getParentNode()->scale(10,10,10);
	Ogre::AxisAlignedBox RobotBox = RobotEntity->getBoundingBox();

	RobotNode->setPosition(Ogre::Vector3(Minimum[0], Minimum[1] + RobotBox.getSize()[1], Minimum[2]));

	m_Camera->setPosition(Ogre::Vector3(Minimum[0], Minimum[1] + 5000, Minimum[2]));
	m_Camera->lookAt(Center);
	
	m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);

	m_Animation = RobotEntity->getAnimationState("Walk");
	m_Animation->setEnabled(true);
	
	m_CollisionTools = new MOC::CollisionTools(SceneManager);

	Root->renderOneFrame();
}
void CLinkedAnimationView::EngineSetup(void)
{
	Ogre::Root *Root = ((CLinkedAnimationApp*)AfxGetApp())->m_Engine->GetRoot();
	Ogre::SceneManager *SceneManager = NULL;
	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Walking");
 
    //
    // 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("Mouse Input");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Mouse Input", 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 = 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(/*20*/0.0, /*5*/0.0, 100.0));
	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));

	Ogre::SceneNode *RobotNode1 = SceneManager->getRootSceneNode()->createChildSceneNode("Robot1", Ogre::Vector3(-50,0,0));
	Ogre::Entity *RobotEntity1 = SceneManager->createEntity("Robot1", "robot.mesh");
	RobotNode1->attachObject(RobotEntity1);
	Ogre::Skeleton *Skeleton1 = RobotEntity1->getSkeleton();
	RobotEntity1->setDisplaySkeleton(true);

	Ogre::SceneNode *RobotNode2 = SceneManager->getRootSceneNode()->createChildSceneNode("Robot2", Ogre::Vector3(50,0,0));
	Ogre::Entity *RobotEntity2 = SceneManager->createEntity("Robot2", "robot.mesh");
	RobotNode2->attachObject(RobotEntity2);
	Ogre::Skeleton *Skeleton2 = RobotEntity2->getSkeleton(); 
	RobotEntity2->setDisplaySkeleton(true);

	Skeleton1->addLinkedSkeletonAnimationSource(Skeleton2->getName(), 2.0);

//	RobotEntity1->_initialise(true);
//	RobotEntity2->_initialise(true);

//	RobotEntity1->refreshAvailableAnimationState();
	m_Camera->lookAt(Ogre::Vector3(0.0, 0.0, 0.0));
	
	m_AnimationState1 = RobotEntity1->getAnimationState("Walk");
	m_AnimationState1->setEnabled(true);

	m_AnimationState2 = RobotEntity2->getAnimationState("Slump");
	m_AnimationState2->setEnabled(true);

	Root->renderOneFrame();
}
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();
}
void CViewManagerView::On3dViews()
{
	int ViewIndex = CMFCRibbonGallery::GetLastSelectedItem(ID_3DVIEWS);
	CEngine *Engine = ((CViewManagerApp*)AfxGetApp())->m_Engine;
	Ogre::Root *Root = Engine->GetRoot();
	m_SceneManager->_updateSceneGraph(m_Camera);
	Ogre::SceneNode *CubeNode = m_SceneManager->getSceneNode("Cube");

	Ogre::AxisAlignedBox Box = m_SceneManager->getRootSceneNode()->_getWorldAABB();
	Ogre::Vector3 Center = Box.getCenter();
	Ogre::Vector3 Position;
	Ogre::Vector3 Destination;

	switch (ViewIndex)
	{
		case 0: //top

			Position = Center;
			Position.y += 4.0 * Box.getSize().y;
			Destination = Center;

		break;
		case 1://bottom
			
			Position = Center;
			Position.y -= 4.0 * Box.getSize().y;
			Destination = Center;

		break;
		case 2:

			Position = Center;
			Position.x += 4.0 * Box.getSize().x;
			Destination = Center;

		break;
		case 3:

			Position = Center;
			Position.x -= 4.0 * Box.getSize().x;
			Destination = Center;

		break;
		case 4:

			Position = Center;
			Position.z -= 4.0 * Box.getSize().z;
			Destination = Center;

		break;
		case 5:

			Position = Center;
			Position.z += 4.0 * Box.getSize().z;
			Destination = Center;

		break;

		case 9:

			CubeNode->roll(Ogre::Radian(-atan(sin(Ogre::Math::PI/4.0))));
			CubeNode->yaw(Ogre::Radian(Ogre::Math::PI/4.0));
			Destination = Center;
			Position = m_Camera->getPosition();

		break;
	}

	m_Camera->setPosition(Position);
	m_Camera->lookAt(Destination);
	Root->renderOneFrame();
}
Example #26
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif

	Ogre::Root *ogre;
	Ogre::RenderWindow *window;
	Ogre::SceneManager *sceneMgr;
	Ogre::SceneManager *guiSceneMgr;
	Ogre::Camera *camera;
	Ogre::Camera *guiCamera;

	// fire up an Ogre rendering window. Clearing the first two (of three) params will let us 
	// specify plugins and resources in code instead of via text file
	ogre = new Ogre::Root("", "");

#if defined(_DEBUG)
	ogre->loadPlugin("RenderSystem_GL_d");
#else
	ogre->loadPlugin("RenderSystem_GL");
#endif

	Ogre::RenderSystemList *renderSystems = NULL;
	Ogre::RenderSystemList::iterator r_it;

	renderSystems = ogre->getAvailableRenderers();
	r_it = renderSystems->begin();
	ogre->setRenderSystem(*r_it);
	ogre->initialise(false);

	// load common plugins
#if defined(_DEBUG)
	//ogre->loadPlugin("Plugin_CgProgramManager_d");		
	ogre->loadPlugin("Plugin_OctreeSceneManager_d");
#else
	//ogre->loadPlugin("Plugin_CgProgramManager");		
	ogre->loadPlugin("Plugin_OctreeSceneManager");
#endif
	// load the basic resource location(s)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource/gui.zip", "Zip", "GUI");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("meshes", "FileSystem", "Meshes");
#if defined(WIN32)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\windows\\fonts", "FileSystem", "GUI");
#endif

	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Meshes");

	// setup main window; hardcode some defaults for the sake of presentation
	Ogre::NameValuePairList opts;
	opts["resolution"] = "1024x768";
	opts["fullscreen"] = "false";
	opts["vsync"] = "false";

	// create a rendering window with the title "CDK"
	window = ogre->createRenderWindow("Bouwgame Client v0.1", 1024, 768, false, &opts);

	// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article 
	// we'll see how to change this
	sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
	guiSceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);

	guiCamera = guiSceneMgr->createCamera("GUICamera");
	guiCamera->setNearClipDistance(5);
	camera = sceneMgr->createCamera("camera");
	camera->setNearClipDistance(5);
    Ogre::Viewport* vp = window->addViewport(guiCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0.2f,0.2f,0.8f));

	/* ambient light */
	sceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8));
	sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

	/* meshes */
	Ogre::Entity* ent = sceneMgr->createEntity( "BouwPlaatsEntity", "world.mesh" );
	Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("BouwNode", Ogre::Vector3(0, 0, 0));
    node->attachObject(ent);
	//node->setScale(Ogre::Vector3(0.7,0.7,0.7));

	ent = sceneMgr->createEntity("plaats", "bouwplaats_step_00.mesh");
	Ogre::Vector3 size = ent->getBoundingBox().getSize();
	Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats size: ") + Ogre::StringConverter::toString(size));
	size = ent->getBoundingBox().getMaximum();
	Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats max: ") + Ogre::StringConverter::toString(size));
	size = ent->getBoundingBox().getMinimum();
	Ogre::LogManager::getSingletonPtr()->getDefaultLog()->logMessage(Ogre::String("Bouwplaats min: ") + Ogre::StringConverter::toString(size));

    Ogre::Entity* ent1 = sceneMgr->createEntity( "KeetEntity", "keet.mesh" );
	Ogre::SceneNode* scenenode = sceneMgr->getRootSceneNode()->createChildSceneNode("KeetNode", Ogre::Vector3(0, 0, 0));
    scenenode->attachObject(ent1);

	
	Ogre::Entity* ent2 = sceneMgr->createEntity( "HekjeEntity", "hekje.mesh" );
	Ogre::SceneNode* scenenode2 = sceneMgr->getRootSceneNode()->createChildSceneNode("HekjeNode", Ogre::Vector3(0, -100, 0));
    scenenode2->attachObject(ent2);
	scenenode2->setScale(Ogre::Vector3(400,0,100));

	// most examples get the viewport size to calculate this; for now, we'll just 
	// set it to 4:3 the easy way
	camera->setAspectRatio((Ogre::Real)1.333333);
	camera->setPosition(Ogre::Vector3(40,100,10));
	guiCamera->setPosition(0, 0, 300);
	guiCamera->lookAt(node->getPosition());

	// this next bit is for the sake of the input handler
	unsigned long hWnd;
	window->getCustomAttribute("WINDOW", &hWnd);

	
	// set up the input handlers
	Simulation *sim = new Simulation();
	InputHandler *handler = new InputHandler(sim, hWnd, camera);
	DataManager *dataManager = new DataManager();
	GameAI* gameAI = new GameAI(dataManager);

	//Create Network
	Network * net = new Network(dataManager);
	//net->start();

	sim->requestStateChange(GUI);
	gui = new GuiManager();

	// networkshit
	while(!net->isConnected())
	{
		Sleep(1000);
	}
	net->Send(GETGROUPS, "", "", NULL);
	net->Send(LOGIN, "gast", "gast", 1);

	gui->setSimulation(sim);
	gui->init("", ogre, guiSceneMgr, window);
	gui->activate("main");
	handler->setWindowExtents(1024,768);
	
	SimulationState cState;
	Ogre::WindowEventUtilities::addWindowEventListener(window, handler);

	DWORD tFrameStart = 0x0; //in miliseconds
	signed long tFrameX = 0x0;
	float tDelta2 = 0.0f; //in seconds
	float m_fps = 60.0f;
	tFrameStart = GetTickCount();

	float tDelta;

	//testAI->calculateNextPath(40,10);

	while ((cState = sim->getCurrentState()) != SHUTDOWN) {

		tFrameX = GetTickCount() - tFrameStart;
		tDelta2 = (float)tFrameX / 1000.0f;
		if (tDelta2 > 3600) // tDelta > 1 hour
			tDelta2 = 1.0f / m_fps; //< System tick count has highly likely overflowed, so get approximation
		tFrameStart = GetTickCount();
		m_fps = (int)(1.0f / tDelta2);

		tDelta = tDelta2;

		handler->capture();
		handler->update(tDelta);
		gui->update(tDelta);

		//if (sim->getCurrentState() == SIMULATION || sim->getCurrentState() == SIMULATION_MOUSELOOK)
//			testAI->update(tDelta);

		// run the message pump (Eihort)
		Ogre::WindowEventUtilities::messagePump();

		ogre->renderOneFrame();

		if (sim->getCurrentState() != cState) {
			handler->StateSwitched(cState, sim->getCurrentState());
			switch (sim->getCurrentState()) {
				case GUI:
					window->getViewport(0)->setCamera(guiCamera);
					break;
				case SIMULATION:
					window->getViewport(0)->setCamera(camera);
					break;
			}
		}

	}

	// clean up after ourselves
	//delete testAI;
	delete sim;
	delete ogre;
	delete handler;
	delete gameAI;
	delete dataManager;

	return 0;
}
void CSceletalAnimationView::EngineSetup(void)
{
	Ogre::Root *Root = ((CSceletalAnimationApp*)AfxGetApp())->m_Engine->GetRoot();
	Ogre::SceneManager *SceneManager = NULL;
	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Animation");
 
    //
    // 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("Mouse Input");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Mouse Input", 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 = 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(5.0, 5.0, 10.0));
	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
	m_Camera->lookAt(Ogre::Vector3(0.5, 0.5, 0.5));
	m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);

	Ogre::ManualObject* ManualObject = NULL;
	ManualObject = SceneManager->createManualObject("Animation");
	ManualObject->setDynamic(false);
    ManualObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
	//face 1
	ManualObject->position(0, 0, 0);//0
	ManualObject->position(1, 0, 0);//1
	ManualObject->position(1, 1, 0);//2
	ManualObject->triangle(0, 1, 2);//3
	
	ManualObject->position(0, 0, 0);//4
	ManualObject->position(1, 1, 0);//5
	ManualObject->position(0, 1, 0);//6
	ManualObject->triangle(3, 4, 5);//7
	//face 2
	ManualObject->position(0, 0, 1);//8
	ManualObject->position(1, 0, 1);//9
	ManualObject->position(1, 1, 1);//10
	ManualObject->triangle(6, 7, 8);//11

	ManualObject->position(0, 0, 1);//12
	ManualObject->position(1, 1, 1);//13
	ManualObject->position(0, 1, 1);//14
	ManualObject->triangle(9, 10, 11);//15
	//face 3
	ManualObject->position(0, 0, 0);//16
	ManualObject->position(1, 0, 0);//17
	ManualObject->position(1, 0, 1);//18
	ManualObject->triangle(12, 13, 14);//19

	ManualObject->position(0, 0, 0);
	ManualObject->position(1, 0, 1);
	ManualObject->position(0, 1, 1);
	ManualObject->triangle(15, 16, 17);
	//face 4
	ManualObject->position(1, 0, 0);
	ManualObject->position(1, 1, 0);
	ManualObject->position(1, 1, 1);
	ManualObject->triangle(18, 19, 20);

	ManualObject->position(1, 0, 0);
	ManualObject->position(1, 1, 1);
	ManualObject->position(1, 0, 1);
	ManualObject->triangle(21, 22, 23);
	//face 5
	ManualObject->position(0, 1, 0);
	ManualObject->position(1, 1, 0);
	ManualObject->position(0, 1, 1);
	ManualObject->triangle(24, 25, 26);

	ManualObject->position(1, 1, 0);
	ManualObject->position(1, 1, 1);
	ManualObject->position(0, 1, 1);
	ManualObject->triangle(27, 28, 29);
	
	//face 6
	ManualObject->position(0, 0, 0);
	ManualObject->position(0, 1, 1);
	ManualObject->position(0, 0, 1);
	ManualObject->triangle(30, 31, 32);

	ManualObject->position(0, 0, 0);
	ManualObject->position(0, 1, 0);
	ManualObject->position(0, 1, 1);
	ManualObject->triangle(33, 34, 35);

	ManualObject->end();
	Ogre::MeshPtr MeshPtr = ManualObject->convertToMesh("Animation");
	Ogre::SubMesh* sub = MeshPtr->getSubMesh(0);
	
	Ogre::SkeletonPtr Skeleton = Ogre::SkeletonManager::getSingleton().create("Skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	MeshPtr.getPointer()->_notifySkeleton(Skeleton);
	Ogre::Bone *Root1 = NULL;
	Ogre::Bone *Child1 = NULL;
	Ogre::Bone *Child2 = NULL;

	Root1 = Skeleton.getPointer()->createBone("Root");
	Root1->setPosition(Ogre::Vector3(0.0, 0.0, 0.0));
	Root1->setOrientation(Ogre::Quaternion::IDENTITY);
	
	Child1 = Root1->createChild(1);
	Child1->setPosition(Ogre::Vector3(4.0, 0.0, 0.0));
	Child1->setOrientation(Ogre::Quaternion::IDENTITY);
	Child2 = Root1->createChild(2);
	Child2->setPosition(Ogre::Vector3(5.0, 0.0, 0.0));
	Child2->setOrientation(Ogre::Quaternion::IDENTITY);

	Ogre::VertexBoneAssignment Assignment;

	Assignment.boneIndex = 0;
	Assignment.vertexIndex = 0;
	Assignment.weight = 1.0;
	Skeleton->setBindingPose();

	sub->addBoneAssignment(Assignment);

	Assignment.vertexIndex = 1;
	sub->addBoneAssignment(Assignment);

	Assignment.vertexIndex = 2;
	sub->addBoneAssignment(Assignment);

	Ogre::Animation *Animation = MeshPtr->createAnimation("HandAnimation", 100.0);
	Ogre::NodeAnimationTrack *Track = Animation->createNodeTrack(0, Root1);
	Ogre::TransformKeyFrame *KeyFrame = NULL;

	for (float FrameTime = 0.0; FrameTime < 100.0; FrameTime += 0.1)
	{
		KeyFrame = Track->createNodeKeyFrame(FrameTime);
		KeyFrame->setTranslate(Ogre::Vector3(10.0, 0.0, 0.0));
	}

	Root1->setManuallyControlled(true);
	Child1->setManuallyControlled(true);
	Child2->setManuallyControlled(true);
	MeshPtr->load();

	MeshPtr.getPointer()->_notifySkeleton(Skeleton);
		
//	Ogre::SkeletonSerializer skeletonSerializer;
//	skeletonSerializer.exportSkeleton(Skeleton.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.skeleton");
//	Ogre::MeshSerializer ser;
//    ser.exportMesh(MeshPtr.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.mesh");

	Ogre::Entity *Entity = SceneManager->createEntity("Animation", "Animation"/*"testskeleton.mesh"*/);
	Ogre::SceneNode *SceneNode = SceneManager->getRootSceneNode()->createChildSceneNode();
	SceneNode->attachObject(Entity);
	Entity->setDisplaySkeleton(true);

	m_AnimationState = Entity->getAnimationState("HandAnimation");
	m_AnimationState->setEnabled(true);
	m_AnimationState->setLoop(true);
	
	m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
	 
	Root->renderOneFrame();
}
Example #28
0
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif

	#define OGRE_STATIC_ParticleFX 1

	Ogre::Root *ogre;
	Ogre::RenderWindow *window;
	Ogre::SceneManager *sceneMgr;
	Ogre::Camera *camera;

	// fire up an Ogre rendering window. Clearing the first two (of three) params will let us 
	// specify plugins and resources in code instead of via text file
	ogre = new Ogre::Root("", "");


	// This is a VERY minimal rendersystem loading example; we are hardcoding the OpenGL 
	// renderer, instead of loading GL and D3D9. We will add renderer selection support in a 
	// future article.

	// I separate the debug and release versions of my plugins using the same "_d" suffix that
	// the Ogre main libraries use; you may need to remove the "_d" in your code, depending on the
	// naming convention you use 
	ogre->loadPlugin("RenderSystem_GL_d");
	ogre->loadPlugin("Plugin_ParticleFX_d");
	const Ogre::RenderSystemList &renderSystems = ogre->getAvailableRenderers();
	Ogre::RenderSystemList::const_iterator r_it;

	// we do this step just to get an iterator that we can use with setRenderSystem. In a future article
	// we actually will iterate the list to display which renderers are available. 
	// renderSystems = ogre->getAvailableRenderers();
	r_it = renderSystems.begin();
	ogre->setRenderSystem(*r_it);
	ogre->initialise(false);

	// load common plugins
	ogre->loadPlugin("Plugin_CgProgramManager_d");		
	ogre->loadPlugin("Plugin_OctreeSceneManager_d");

	// setup main window; hardcode some defaults for the sake of presentation
	Ogre::NameValuePairList opts;
	opts["resolution"] = "1024x768";
	opts["fullscreen"] = "false";
	opts["vsync"] = "true";

	// create a rendering window with the title "CDK"
	window = ogre->createRenderWindow("CDK", 1024, 768, false, &opts);

		// load the basic resource location(s)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"resource", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"resource/gui.zip", "Zip", "GUI");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"resource/textures", "FileSystem", "Textures");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"resource/particles", "FileSystem", "Particles");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"resource/materials", "FileSystem", "Materials");
#if defined(WIN32)
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
		"c:\\windows\\fonts", "FileSystem", "GUI"); 
#endif
	//Must initialize resource groups after window if using particle effects.
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Textures");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Materials");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Particles");

	// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article 
	// we'll see how to change this
	sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
	camera = sceneMgr->createCamera("camera");
	camera->setNearClipDistance(1);
    Ogre::Viewport* vp = window->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

	// most examples get the viewport size to calculate this; for now, we'll just 
	// set it to 4:3 the easy way
	camera->setAspectRatio((Ogre::Real)1.333333);

// with a scene manager and window, we can create a the GUI renderer
	
	// new way to instantiate a CEGUIOgreRenderer (Ogre 1.7)
	Ogre::RenderTarget *mRenderTarget = window;
	CEGUI::OgreRenderer* pGUIRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*mRenderTarget);
 
	// create the root CEGUI class
	CEGUI::System* pSystem = CEGUI::System::getSingletonPtr();
 
	// tell us a lot about what is going on (see CEGUI.log in the working directory)
	CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
 
	// use this CEGUI scheme definition (see CEGUI docs for more)
	CEGUI::SchemeManager::getSingleton().create((CEGUI::utf8*)"TaharezLookSkin.scheme", (CEGUI::utf8*)"GUI");
 
	// show the CEGUI mouse cursor (defined in the look-n-feel)
	pSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
 
	// use this font for text in the UI
	CEGUI::FontManager::getSingleton().create("Tahoma-8.font", (CEGUI::utf8*)"GUI");
	pSystem->setDefaultFont((CEGUI::utf8*)"Tahoma-8");
 
	// load a layout from the XML layout file (you'll find this in resources/gui.zip), and 
	// put it in the GUI resource group
	CEGUI::Window* pLayout = CEGUI::WindowManager::getSingleton().loadWindowLayout("katana.layout", "", "GUI");
 
	// you need to tell CEGUI which layout to display. You can call this at any time to change the layout to
	// another loaded layout (i.e. moving from screen to screen or to load your HUD layout). Note that this takes
	// a CEGUI::Window instance -- you can use anything (any widget) that serves as a root window.
	pSystem->setGUISheet(pLayout);

	// this next bit is for the sake of the input handler
	unsigned long hWnd;
	// WINDOW is generic to all platforms now as of Eihort
	window->getCustomAttribute("WINDOW", &hWnd);

	// set up the input handlers
	Simulation *sim = new Simulation();

	// since the input handler deals with pushing input to CEGUI, we need to give it a pointer
	// to the CEGUI System instance to use
	InputHandler *handler = new InputHandler(pSystem, sim, hWnd);

	// put us into our "main menu" state
	sim->requestStateChange(GUI);

	// make an instance of our GUI sheet handler class
	MainMenuDlg* pDlg = new MainMenuDlg(pSystem, pLayout, sim);
	
	//testing shit
	Ogre::SceneNode *systemNode = sceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0,0,0));
	

	
	SphereMesh *sphere = NULL;
	sphere->createSphere("sphereMesh", 80, 64, 64);


	/*
	// Now I can create several entities using that mesh
	Ogre::Entity *MoonEntity = sceneMgr->createEntity("Moon", planetMesh);
	// Now I attach it to a scenenode, so that it becomes present in the scene.
	Ogre::SceneNode *EarthOrbitNode = systemNode->createChildSceneNode("Earth Orbit", Ogre::Vector3(0,0,0));
	Ogre::SceneNode *EarthNode = EarthOrbitNode->createChildSceneNode("Earth", Ogre::Vector3(200,0,0));
	Ogre::SceneNode *MoonNode = EarthNode->createChildSceneNode("Moon", Ogre::Vector3(150,0,0));
	MoonNode->attachObject(MoonEntity);
	MoonEntity->getParentNode()->scale(0.5,0.5,0.5);
	*/
	//Material Tests
	Ogre::MaterialManager& lMaterialManager = Ogre::MaterialManager::getSingleton();
	Ogre::String lNameOfResourceGroup = "Mission 1 : Deliver Tom";
	
	Ogre::ResourceGroupManager& lRgMgr = Ogre::ResourceGroupManager::getSingleton();
	lRgMgr.createResourceGroup(lNameOfResourceGroup);

	{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("M_Lighting+OneTexture",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
 
			lFirstPass->setDiffuse(0.8f, 0.8f, 0.8f,1.0f);
			lFirstPass->setAmbient(0.3f, 0.3f, 0.3f);
			lFirstPass->setSpecular(1.0f, 1.0f, 1.0f, 1.0f);
			lFirstPass->setShininess(64.0f);
			lFirstPass->setSelfIllumination(0.1f, 0.1f, 0.1f);

			Ogre::TextureUnitState* lTextureUnit = lFirstPass->createTextureUnitState();
			lTextureUnit->setTextureName("SimpleTexture.bmp", Ogre::TEX_TYPE_2D);
			lTextureUnit->setTextureCoordSet(0);
	}
	
	
	// 3/ Lighting color.
	// To have the feeling of '3D', the lighting is good feeling.
		// It often requires the object to have correct normals (see my manual object construction), 
		// and some lights in the scene.
		
	{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("Sun",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
			
			// Lighting is allowed on this pass.
			lFirstPass->setLightingEnabled(true);

			// Emissive / self illumination is the color 'produced' by the object.
			// Color values vary between 0.0(minimum) to 1.0 (maximum).
			Ogre::ColourValue lSelfIllumnationColour(0.5f, 0.0f, 0.0f, 1.0f);
			lFirstPass->setSelfIllumination(lSelfIllumnationColour);

			// diffuse color is the traditionnal color of the lit object.
			Ogre::ColourValue lDiffuseColour(1.0f, 0.4f, 0.4f, 1.0f);
			lFirstPass->setDiffuse(lDiffuseColour);

			// ambient colour is linked to ambient lighting.
			// If there is no ambient lighting, then this has no influence.
			// It the ambient lighting is at 1, then this colour is fully added.
			// This is often use to change the general feeling of a whole scene.
			Ogre::ColourValue lAmbientColour(0.4f, 0.1f, 0.1f, 1.0f);
			lFirstPass->setAmbient(lAmbientColour);

			// specular colour, is the colour of the 'little light reflection'
			// that you can see on some object. For example, my bald head skin
			// reflect the sun. This make a 'round of specular lighting'.
			// Set this to black if you don't want to see it.
			Ogre::ColourValue lSpecularColour(1.0f, 1.0f, 1.0f, 1.0f);
			lFirstPass->setSpecular(lSpecularColour);

			// Shininess is the 'inverse of specular color splattering' coefficient.
			// If this is big (e.g : 64) you get a very tiny dot with a quite strong color (on round surface).
			// If this is 0, you get a simple color layer (the dot has become very wide).
			Ogre::Real lShininess = 64.0f;
			lFirstPass->setShininess(lShininess);
	}
		{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("mars",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
			
			// Lighting is allowed on this pass.
			lFirstPass->setLightingEnabled(true);

			// Emissive / self illumination is the color 'produced' by the object.
			// Color values vary between 0.0(minimum) to 1.0 (maximum).
			Ogre::ColourValue lSelfIllumnationColour(0.6f, 0.1f, 0.1f, 0.0f);
			lFirstPass->setSelfIllumination(lSelfIllumnationColour);

			// diffuse color is the traditionnal color of the lit object.
			Ogre::ColourValue lDiffuseColour(1.0f, 0.2f, 0.0f, 0.0f);
			lFirstPass->setDiffuse(lDiffuseColour);

			// ambient colour is linked to ambient lighting.
			// If there is no ambient lighting, then this has no influence.
			// It the ambient lighting is at 1, then this colour is fully added.
			// This is often use to change the general feeling of a whole scene.
			Ogre::ColourValue lAmbientColour(1.0f, 0.2f, 0.0f, 0.0f);
			lFirstPass->setAmbient(lAmbientColour);

			// specular colour, is the colour of the 'little light reflection'
			// that you can see on some object. For example, my bald head skin
			// reflect the sun. This make a 'round of specular lighting'.
			// Set this to black if you don't want to see it.
			Ogre::ColourValue lSpecularColour(1.0f, 0.3f, 0.3f, 0.3f);
			lFirstPass->setSpecular(lSpecularColour);

			// Shininess is the 'inverse of specular color splattering' coefficient.
			// If this is big (e.g : 64) you get a very tiny dot with a quite strong color (on round surface).
			// If this is 0, you get a simple color layer (the dot has become very wide).
			Ogre::Real lShininess = 34.0f;
			lFirstPass->setShininess(lShininess);
		}

	{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("gaia",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
			
			// Lighting is allowed on this pass.
			lFirstPass->setLightingEnabled(true);

			// Emissive / self illumination is the color 'produced' by the object.
			// Color values vary between 0.0(minimum) to 1.0 (maximum).
			Ogre::ColourValue lSelfIllumnationColour(0.0f, 0.0f, 0.1f, 0.3f);
			lFirstPass->setSelfIllumination(lSelfIllumnationColour);

			// diffuse color is the traditionnal color of the lit object.
			Ogre::ColourValue lDiffuseColour(0.1f, 0.2f, 0.8f, 1.0f);
			lFirstPass->setDiffuse(lDiffuseColour);

			// ambient colour is linked to ambient lighting.
			// If there is no ambient lighting, then this has no influence.
			// It the ambient lighting is at 1, then this colour is fully added.
			// This is often use to change the general feeling of a whole scene.
			Ogre::ColourValue lAmbientColour(0.0f, 0.1f, 0.4f, 1.0f);
			lFirstPass->setAmbient(lAmbientColour);

			// specular colour, is the colour of the 'little light reflection'
			// that you can see on some object. For example, my bald head skin
			// reflect the sun. This make a 'round of specular lighting'.
			// Set this to black if you don't want to see it.
			Ogre::ColourValue lSpecularColour(0.0f, 0.3f, 1.0f, 1.0f);
			lFirstPass->setSpecular(lSpecularColour);

			// Shininess is the 'inverse of specular color splattering' coefficient.
			// If this is big (e.g : 64) you get a very tiny dot with a quite strong color (on round surface).
			// If this is 0, you get a simple color layer (the dot has become very wide).
			Ogre::Real lShininess = 34.0f;
			lFirstPass->setShininess(lShininess);
		}
		{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("barren",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
			
			// Lighting is allowed on this pass.
			lFirstPass->setLightingEnabled(true);

			// Emissive / self illumination is the color 'produced' by the object.
			// Color values vary between 0.0(minimum) to 1.0 (maximum).
			Ogre::ColourValue lSelfIllumnationColour(0.1f, 0.1f, 0.1f, 0.1f);
			lFirstPass->setSelfIllumination(lSelfIllumnationColour);

			// diffuse color is the traditionnal color of the lit object.
			Ogre::ColourValue lDiffuseColour(0.3f, 0.3f, 0.3f, 0.3f);
			lFirstPass->setDiffuse(lDiffuseColour);

			// ambient colour is linked to ambient lighting.
			// If there is no ambient lighting, then this has no influence.
			// It the ambient lighting is at 1, then this colour is fully added.
			// This is often use to change the general feeling of a whole scene.
			Ogre::ColourValue lAmbientColour(0.3f, 0.3f, 0.3f, 0.3f);
			lFirstPass->setAmbient(lAmbientColour);

			// specular colour, is the colour of the 'little light reflection'
			// that you can see on some object. For example, my bald head skin
			// reflect the sun. This make a 'round of specular lighting'.
			// Set this to black if you don't want to see it.
			Ogre::ColourValue lSpecularColour(0.7f, 0.7f, 0.7f, 0.7f);
			lFirstPass->setSpecular(lSpecularColour);

			// Shininess is the 'inverse of specular color splattering' coefficient.
			// If this is big (e.g : 64) you get a very tiny dot with a quite strong color (on round surface).
			// If this is 0, you get a simple color layer (the dot has become very wide).
			Ogre::Real lShininess = 34.0f;
			lFirstPass->setShininess(lShininess);
		}
	{
			Ogre::MaterialPtr lMaterial = lMaterialManager.create("gasgiant",lNameOfResourceGroup);
			Ogre::Technique* lFirstTechnique = lMaterial->getTechnique(0);
			Ogre::Pass* lFirstPass = lFirstTechnique->getPass(0);
			
			// Lighting is allowed on this pass.
			lFirstPass->setLightingEnabled(true);

			// Emissive / self illumination is the color 'produced' by the object.
			// Color values vary between 0.0(minimum) to 1.0 (maximum).
			Ogre::ColourValue lSelfIllumnationColour(0.0f, 0.3f, 0.0f, 0.1f);
			lFirstPass->setSelfIllumination(lSelfIllumnationColour);

			// diffuse color is the traditionnal color of the lit object.
			Ogre::ColourValue lDiffuseColour(0.1f, 0.7f, 0.1f, 0.3f);
			lFirstPass->setDiffuse(lDiffuseColour);

			// ambient colour is linked to ambient lighting.
			// If there is no ambient lighting, then this has no influence.
			// It the ambient lighting is at 1, then this colour is fully added.
			// This is often use to change the general feeling of a whole scene.
			Ogre::ColourValue lAmbientColour(0.1f, 0.7f, 0.3f, 0.3f);
			lFirstPass->setAmbient(lAmbientColour);

			// specular colour, is the colour of the 'little light reflection'
			// that you can see on some object. For example, my bald head skin
			// reflect the sun. This make a 'round of specular lighting'.
			// Set this to black if you don't want to see it.
			Ogre::ColourValue lSpecularColour(0.2f, 1.0f, 0.6f, 0.6f);
			lFirstPass->setSpecular(lSpecularColour);

			// Shininess is the 'inverse of specular color splattering' coefficient.
			// If this is big (e.g : 64) you get a very tiny dot with a quite strong color (on round surface).
			// If this is 0, you get a simple color layer (the dot has become very wide).
			Ogre::Real lShininess = 34.0f;
			lFirstPass->setShininess(lShininess);
		}

	//end material tests

	//System Creator
	std::string systemDefinition[10] = {"15000,0,0,false,false,false,700000,0", "300,0,0,false,false,barren,2500,1",
		"300,x,y,false,co2,barren,6000,2", "300,x,y,h2o,n2/o2,gaia,6300,3", "300,x,y,false,co2,mars,3400,4",
		"300,x,y,false,h2/he,gasgiant,71000,5", "300,x,y,false,h2/he,gasgiant,60000,6", "300,x,y,false,h2/he,gasgiant,25001,7",
		"300,x,y,false,h2/he,gasgiant,25000,8", "300,x,y,false,n-ice,ice,1100,9"};

	StarSystem sol = StarSystem::StarSystem(sceneMgr, systemDefinition);

	//Star Creator
	/*
	{
	int x = 0;
	int y = 0;
	int kelvin = 15000;
	CelestialBody newstar = CelestialBody::CelestialBody(kelvin, 100, systemNode, sceneMgr, x, y);
	}

	// Spectrum testing and multi star generation.
	
	int time = 200;
	int x = -500;
	int y = 500;

	for ( int count = 1; count <= time; count++){
	
		int kelvin = count * (40000/time);
		Star newstar = Star::Star(kelvin, 100, systemNode, sceneMgr, x, y);
		x += 20;

		if (count % 10 == 0) {
			y -= 20;
			x = -500;
		}
	}
	*/

	// I move the SceneNode back 15 so that it is visible to the camera.
	float PositionOffset = 0.0;
	float distance = -2000.0;

	systemNode->translate(0, PositionOffset, distance);
	
	camera->lookAt(Ogre::Vector3(0,0,distance));

	while (sim->getCurrentState() != SHUTDOWN) {
		
		sol.rotateOrbits();
		
		handler->capture();

		ogre->renderOneFrame();

		// run the message pump (uncomment for Eihort)
		Ogre::WindowEventUtilities::messagePump();
	}

	{
		window->removeAllViewports();
	}
	{
		sceneMgr->destroyAllCameras();
		sceneMgr->destroyAllManualObjects();
		sceneMgr->destroyAllEntities();
		sceneMgr->destroyAllLights();
		systemNode->removeAndDestroyAllChildren();
	}

	{
		Ogre::ResourceGroupManager& lRgMgr = Ogre::ResourceGroupManager::getSingleton();
		lRgMgr.destroyResourceGroup(lNameOfResourceGroup);
	}

	// clean up after ourselves
	delete pDlg;
	delete handler;
	delete sim;
	delete ogre;

	return 0;
}
Example #29
0
int main() {
    Ogre::Root* root = new Ogre::Root();
    root->addResourceLocation("/home/soulmerge/projects/Diplomarbeit/Prototype/resources/Ogre/", "FileSystem");
    if (!root->restoreConfig() && !root->showConfigDialog()) {
        throw 1;
    }
    root->initialise(false);
    Ogre::SceneManager* sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
    sceneMgr->setAmbientLight(Ogre::ColourValue::White * 10);
    Ogre::RenderWindow* window = root->createRenderWindow("Ogre RenderWindow", 800, 600, false, NULL);
    Ogre::Camera* cam1 = sceneMgr->createCamera("cam1");
    Ogre::Camera* cam2 = sceneMgr->createCamera("cam2");
    Ogre::Camera* cam3 = sceneMgr->createCamera("cam3");
    Ogre::Camera* cam4 = sceneMgr->createCamera("cam4");
	Ogre::Viewport* vp1 = window->addViewport(cam1, 1, 0  , 0  , 0.5, 0.5);
	Ogre::Viewport* vp2 = window->addViewport(cam2, 2, 0.5, 0  , 0.5, 0.5);
	Ogre::Viewport* vp3 = window->addViewport(cam3, 3, 0  , 0.5, 0.5, 0.5);
	Ogre::Viewport* vp4 = window->addViewport(cam4, 4, 0.5, 0.5, 0.5, 0.5);
    vp1->setBackgroundColour(Ogre::ColourValue(1, 1, 1));
    vp2->setBackgroundColour(Ogre::ColourValue(1, 1, 1) * 0.95);
    vp3->setBackgroundColour(Ogre::ColourValue(1, 1, 1) * 0.95);
    vp4->setBackgroundColour(Ogre::ColourValue(1, 1, 1));
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    Ogre::Entity* model = sceneMgr->createEntity("model", "alexandria.mesh");
    Ogre::SceneNode* modelNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("modelnode1");
    modelNode1->attachObject(model);
    cam1->setNearClipDistance(5);
    cam2->setNearClipDistance(5);
    cam3->setNearClipDistance(5);
    cam4->setNearClipDistance(5);
	/*
    cam1->setPolygonMode(Ogre::PM_WIREFRAME);
    cam2->setPolygonMode(Ogre::PM_WIREFRAME);
    cam3->setPolygonMode(Ogre::PM_WIREFRAME);
    cam4->setPolygonMode(Ogre::PM_WIREFRAME);
	*/
    Ogre::SceneNode* camNode1 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode1");
    Ogre::SceneNode* camNode2 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode2");
    Ogre::SceneNode* camNode3 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode3");
    Ogre::SceneNode* camNode4 = sceneMgr->getRootSceneNode()->createChildSceneNode("camnode4");
    camNode1->attachObject(cam1);
    camNode2->attachObject(cam2);
    camNode3->attachObject(cam3);
    camNode4->attachObject(cam4);
	Ogre::Quaternion q;
	q.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3::UNIT_Y);
	camNode1->lookAt(Ogre::Vector3(-1, -1, -1), Ogre::Node::TS_LOCAL);
	camNode2->setOrientation(q * camNode1->getOrientation());
	camNode3->setOrientation(q * camNode2->getOrientation());
	camNode4->setOrientation(q * camNode3->getOrientation());
    camNode1->setPosition(100, 100, 100);
    camNode2->setPosition(100, 100, -100);
    camNode3->setPosition(-100, 100, -100);
    camNode4->setPosition(-100, 100, 100);
    while(true) {
        Ogre::WindowEventUtilities::messagePump();
        if (window->isClosed()) {
            return 0;
        }
        if (!root->renderOneFrame()) {
            return 0;
        }
    }
    return 0;
}