Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "ogre_tools/render_system.h"
00031 #include "ogre_tools/render_widget.h"
00032
00033 #include <QApplication>
00034 #include <QTimer>
00035 #include <QVBoxLayout>
00036 #include <QPushButton>
00037
00038 #include <OGRE/OgreRenderWindow.h>
00039 #include <OGRE/OgreEntity.h>
00040
00041 using namespace ogre_tools;
00042
00043 int main( int argc, char** argv )
00044 {
00045
00046 RenderSystem* render_system = RenderSystem::get();
00047
00048 QApplication app( argc, argv );
00049
00050
00051
00052 RenderWidget* window = new RenderWidget( render_system );
00053 window->setWindowTitle( "I hope this is not all black." );
00054
00055 QVBoxLayout* layout = new QVBoxLayout;
00056 layout->addWidget( window );
00057 layout->addWidget( new QPushButton( "chubs" ));
00058
00059 QWidget container;
00060 container.setLayout( layout );
00061 container.resize( 900, 600 );
00062 container.show();
00063
00064
00065 Ogre::SceneManager* scene_manager = render_system->root()->createSceneManager( Ogre::ST_GENERIC );
00066
00067 Ogre::Entity* thing = scene_manager->createEntity( "thing", "ogre_tools_cone.mesh" );
00068 Ogre::SceneNode* node = scene_manager->getRootSceneNode()->createChildSceneNode();
00069 node->attachObject( thing );
00070
00071 scene_manager->setAmbientLight( Ogre::ColourValue( .5, .5, .5 ));
00072 Ogre::Light* light = scene_manager->createLight( "light" );
00073 light->setPosition( 20, 80, 50 );
00074
00075 Ogre::Camera* camera = scene_manager->createCamera( "SampleCam" );
00076 camera->setPosition( Ogre::Vector3( 0, 0, 10 ));
00077 camera->lookAt( Ogre::Vector3( 0, 0, -300 ));
00078 camera->setNearClipDistance( 5 );
00079
00080 Ogre::Viewport* viewport = window->getRenderWindow()->addViewport( camera );
00081 viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 1.0 ));
00082
00083 camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() ));
00084
00085
00086 QTimer timer;
00087 QObject::connect( &timer, SIGNAL(timeout()), window, SLOT(update()) );
00088 timer.start( 33 );
00089
00090
00091 RenderWidget window2( render_system );
00092 window2.resize( 400, 400 );
00093 window2.setWindowTitle( "I hope this is also not all black." );
00094 window2.show();
00095
00096 Ogre::Camera* camera2 = scene_manager->createCamera( "SampleCam2" );
00097 camera2->setPosition( Ogre::Vector3( 0, 10, 0 ));
00098 camera2->setFixedYawAxis( false );
00099 camera2->lookAt( Ogre::Vector3( 0, 0, 0 ));
00100 camera2->setNearClipDistance( 5 );
00101
00102 Ogre::Viewport* viewport2 = window2.getRenderWindow()->addViewport( camera2 );
00103 viewport2->setBackgroundColour( Ogre::ColourValue( 0, 1.0, 0 ));
00104
00105 camera2->setAspectRatio( Ogre::Real( viewport2->getActualWidth() ) / Ogre::Real( viewport2->getActualHeight() ));
00106
00107
00108 QTimer timer2;
00109 QObject::connect( &timer2, SIGNAL(timeout()), &window2, SLOT(update()) );
00110 timer2.start( 33 );
00111
00112
00113 return app.exec();
00114 }