// Forward Declarations SoSeparator* startUpScene(SoNode* avatar) { //************************************************************** // ================ STARTING WORLD STRUCTURE ================== // Separator (root0) // | // Selection Node (root)__ ----> selection_callback // |______________ ----> un_select_callback // | // Camera Node // | // World Skeleton & Floor // from external files // | // Avatar ( Separator ) // | // Event Callback Node (for keyboard) -->kbd_callback function // | // One Shot sensor ( repeat keyboard status check ) // _____________________|_________________________________ // | | | | // Separator Separator Separator Separator //(sciences area) (bioSciences) (Arts Area) (Unassigned area) // | | | | // Translation Translation Translation Translation // //************************************************************** // callbacks for selecting objects SoSelection* root = new SoSelection; selection = root; root->ref(); root->addSelectionCallback( made_selection, (void *)1L ); root->addDeselectionCallback( made_selection, (void *)0L ); root->policy = SoSelection::TOGGLE; //CAMERA camera = new SoPerspectiveCamera(); camera->nearDistance = 4; camera->farDistance = 4096; root->addChild( camera ); root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/world.wrl") ); root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/grass.wrl") ); root->addChild( avatar ); ////////// move camera and avatar with directional keys // keyboard handling SoEventCallback *cb = new SoEventCallback; cb->addEventCallback(SoKeyboardEvent::getClassTypeId(), keyboardEvent_cb, NULL); root->insertChild(cb, 0); // sensor for infinite processing of simulationStep SoOneShotSensor *sensor = new SoOneShotSensor(simulationStep, NULL); sensor->schedule(); SoSeparator* scienceArea = new SoSeparator; SoTranslation* sciTransl = new SoTranslation; sciTransl->translation.setValue(150, 0 ,150 ); scienceArea->setName(VRML_UTILS_SCIENCES_AREA_NAME); root->addChild( scienceArea ); scienceArea->addChild( sciTransl ); scienceArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_sci.wrl") ); SoSeparator* bioArea = new SoSeparator; SoTranslation* bioTransl = new SoTranslation; bioTransl->translation.setValue(-150, 0 ,150 ); bioArea->setName(VRML_UTILS_BIO_AREA_NAME); root->addChild( bioArea ); bioArea->addChild( bioTransl ); bioArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_bio.wrl") ); SoSeparator* artsArea = new SoSeparator; SoTranslation* artsTransl = new SoTranslation; artsTransl->translation.setValue(150, 0 ,-150 ); artsArea->setName(VRML_UTILS_ARTS_AREA_NAME); root->addChild( artsArea ); artsArea->addChild( artsTransl ); artsArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_arts.wrl") ); SoSeparator* freeArea = new SoSeparator; SoTranslation* freeTransl = new SoTranslation; freeTransl->translation.setValue(-150, 0 ,-150 ); freeArea->setName(VRML_UTILS_FREE_AREA_NAME); root->addChild( freeArea ); freeArea->addChild( freeTransl ); freeArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_free.wrl") ); // load resources from server root->unrefNoDelete(); return root; }
int main(int argc, char **argv) { // Initialize Inventor and Qt QWidget *myWindow = SoQt::init(argv[0]); GsTL_SoNode::initClass(); if (myWindow == NULL) exit(1); SmartPtr<Named_interface> ni_cmaps = Root::instance()->new_interface("directory://colormaps", colormap_manager ); Manager* dir = dynamic_cast<Manager*>( ni_cmaps.raw_ptr() ); if( !dir ) { GsTLlog << "could not create directory " << colormap_manager << "\n"; return 1; } dir->factory( "colormap", Color_scale::create_new_interface ); Root::instance()->new_interface( "colormap://rainbow.map", colormap_manager + "/rainbow" ); Root::instance()->new_interface( "colormap://cyan_red.map", colormap_manager + "/cyan_red" ); Root::instance()->list_all( cout ); int nx=5; int ny=3; int nz=6; Cartesian_grid grid; grid.set_dimensions( nx, ny, nz, 1, 1, 1 ); grid.origin( GsTLPoint( -0.5, -0.5, -0.5 ) ); GsTLGridProperty* prop = grid.add_property( "toto", typeid( float ) ); for( int i=0; i < nx*ny*nz; i ++ ) prop->set_value( i, i ); Oinv_cgrid oinv_grid; oinv_grid.init( &grid ); oinv_grid.set_property( "toto" ); oinv_grid.oinv_node()->visible = true; cout << "Setting up oinv scene" << endl; SoSelection* root = new SoSelection; SoSeparator* line_sep = new SoSeparator; SoLightModel* light_model = new SoLightModel; light_model->model = SoLightModel::BASE_COLOR; line_sep->addChild( light_model ); SoMaterial* material = new SoMaterial; material->diffuseColor.setValue( 1.0, 0.0, 0.0 ); line_sep->addChild( material ); SoDrawStyle* draw_style = new SoDrawStyle; draw_style->style = SoDrawStyle::LINES; draw_style->lineWidth = 2; line_sep->addChild( draw_style ); oinv_grid.property_display_mode( Oinv::NOT_PAINTED ); line_sep->addChild( oinv_grid.oinv_node() ); root->addChild( line_sep ); SoSeparator* filled_sep = new SoSeparator; SoDrawStyle* draw_style_filled = new SoDrawStyle; draw_style_filled->style = SoDrawStyle::FILLED; filled_sep->addChild( draw_style_filled ); oinv_grid.property_display_mode( Oinv::PAINTED ); filled_sep->addChild( oinv_grid.oinv_node() ); root->addChild( filled_sep ); SoQtGsTLViewer* myViewer = new SoQtGsTLViewer( (QWidget*) myWindow, "camera" ); //SoQtExaminerViewer *myViewer = new SoQtExaminerViewer(myWindow); myViewer->setSceneGraph(root); myViewer->show(); SoQt::show(myWindow); SoQt::mainLoop(); }