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 "rviz/ogre_helpers/render_system.h"
00031 #include "rviz/ogre_helpers/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 rviz;
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 QPushButton* hide_button = new QPushButton( "hide" );
00058 layout->addWidget( hide_button );
00059 QPushButton* show_button = new QPushButton( "show" );
00060 layout->addWidget( show_button );
00061
00062 QWidget container;
00063 container.setLayout( layout );
00064 container.resize( 900, 600 );
00065 container.show();
00066
00067
00068 Ogre::SceneManager* scene_manager = render_system->root()->createSceneManager( Ogre::ST_GENERIC );
00069
00070 Ogre::Entity* thing = scene_manager->createEntity( "thing", "rviz_cone.mesh" );
00071 Ogre::SceneNode* node = scene_manager->getRootSceneNode()->createChildSceneNode();
00072 node->attachObject( thing );
00073
00074 scene_manager->setAmbientLight( Ogre::ColourValue( .5, .5, .5 ));
00075 Ogre::Light* light = scene_manager->createLight( "light" );
00076 light->setPosition( 20, 80, 50 );
00077
00078 Ogre::Camera* camera = scene_manager->createCamera( "SampleCam" );
00079 camera->setPosition( Ogre::Vector3( 0, 0, 10 ));
00080 camera->lookAt( Ogre::Vector3( 0, 0, -300 ));
00081 camera->setNearClipDistance( 5 );
00082
00083 Ogre::Viewport* viewport = window->getRenderWindow()->addViewport( camera );
00084 viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 1.0 ));
00085
00086 camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() ));
00087
00088
00089 QTimer timer;
00090 QObject::connect( &timer, SIGNAL(timeout()), window, SLOT(update()) );
00091 timer.start( 33 );
00092
00093
00094 RenderWidget window2( render_system );
00095 window2.resize( 400, 400 );
00096 window2.setWindowTitle( "I hope this is also not all black." );
00097 window2.show();
00098
00099 hide_button->connect( hide_button, SIGNAL( clicked() ), &window2, SLOT( hide() ));
00100 show_button->connect( show_button, SIGNAL( clicked() ), &window2, SLOT( show() ));
00101
00102 Ogre::Camera* camera2 = scene_manager->createCamera( "SampleCam2" );
00103 camera2->setPosition( Ogre::Vector3( 0, 10, 0 ));
00104 camera2->setFixedYawAxis( false );
00105 camera2->lookAt( Ogre::Vector3( 0, 0, 0 ));
00106 camera2->setNearClipDistance( 5 );
00107
00108 Ogre::Viewport* viewport2 = window2.getRenderWindow()->addViewport( camera2 );
00109 viewport2->setBackgroundColour( Ogre::ColourValue( 0, 1.0, 0 ));
00110
00111 camera2->setAspectRatio( Ogre::Real( viewport2->getActualWidth() ) / Ogre::Real( viewport2->getActualHeight() ));
00112
00113
00114 QTimer timer2;
00115 QObject::connect( &timer2, SIGNAL(timeout()), &window2, SLOT(update()) );
00116 timer2.start( 33 );
00117
00118
00119 return app.exec();
00120 }