Changeset 20214
- Timestamp:
- 05/14/07 15:42:31 (2 years ago)
- Files:
-
- juggler/trunk/modules/vrjuggler/ChangeLog (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/VERSION (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/Makefile.in (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/OpenSGNavGrab.cpp (modified) (21 diffs)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/OpenSGNavGrab.h (modified) (7 diffs)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/Makefile.in (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/OpenSGNav.cpp (modified) (4 diffs)
- juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/OpenSGNav.h (modified) (2 diffs)
- juggler/trunk/modules/vrjuggler/vrj/Draw/OpenSG/OpenSGApp.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vrjuggler/ChangeLog
r20209 r20214 1 1 DATE AUTHOR CHANGE 2 2 ----------- ----------- ------------------------------------------------------- 3 May-14-2007 patrick Finished making vrj::OpenSGApp work with both OpenSG 4 1.x and 2.0. 5 NEW VERSION: 2.3.8 3 6 May-11-2007 patrick Made the data member of vrj::Frustum private and added 4 7 vrj::Frustum::getValues() as the accessor for that juggler/trunk/modules/vrjuggler/VERSION
r20209 r20214 1 2.3.8-0 @05/14/2007 20:45:00 UTC@ 1 2 2.3.7-0 @05/12/2007 00:50:00 UTC@ 2 3 2.3.6-0 @05/07/2007 00:35:00 UTC@ juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/Makefile.in
r19729 r20214 44 44 OPENSG_LIBS= $(shell osg-config --libs) -lOSGBase -lOSGSystem 45 45 OPENSG_CFLAGS= $(shell osg-config --cflags) 46 #OPENSG_LIBS= $(shell osg2-config OSGFileIO OSGWindow OSGRenderTraversal --libs) 47 #OPENSG_CFLAGS= $(shell osg2-config OSGFileIO OSGWindow OSGRenderTraversal --cflags) 46 48 47 49 EXTRA_CXXFLAGS+= $(OPENSG_CFLAGS) juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/OpenSGNavGrab.cpp
r20137 r20214 36 36 #include <gmtl/Vec.h> 37 37 38 #if OSG_MAJOR_VERSION >= 2 39 # include <OpenSG/OSGTypedGeoIntegralProperty.h> 40 #endif 41 38 42 #include <OpenSGNavGrab.h> 39 43 … … 44 48 : vrj::OpenSGApp(kern) 45 49 , mVelocity(0.0f) 46 , mIntersectedObj(NULL)47 , mGrabbedObj(NULL)48 50 , mIntersectColor(1.0f, 1.0f, 0.0f) 49 51 , mGrabColor(1.0f, 0.0f, 1.0f) … … 54 56 OpenSGNavGrab::~OpenSGNavGrab() 55 57 { 56 for ( std::vector<GrabObject*>::iterator i = mObjects.begin(); 57 i != mObjects.end(); 58 ++i ) 59 { 60 delete *i; 61 } 58 /* Do nothing. */ ; 62 59 } 63 60 … … 101 98 mModelGroup = OSG::Group::create(); 102 99 103 OSG::beginEditCP(mModelRoot); 104 mModelRoot->setCore(mModelGroup); 105 OSG::endEditCP(mModelRoot); 100 #if OSG_MAJOR_VERSION < 2 101 CPEdit(mModelRoot, OSG::Node::CoreFieldMask); 102 #endif 103 104 mModelRoot->setCore(mModelGroup); 106 105 107 106 // Load the model to use. … … 114 113 // Box geometry: 2.5x2.5x2.5 (units are in feet) 115 114 // Center point: (0,0,0) 116 OSG::NodePtr geom_node = OSG::makeBox(2.5f, 2.5f, 2.5f, 1, 1, 1); 117 OSG::addRefCP(geom_node); 115 OSG::NodeRefPtr geom_node(OSG::makeBox(2.5f, 2.5f, 2.5f, 1, 1, 1)); 118 116 119 117 // Move it so that it would butt up against a wall five feet in front … … 131 129 OSG::Pnt3f::RealReturnType max_dist(0.0f); 132 130 133 std::vector<OSG::Node Ptr> nodes;131 std::vector<OSG::NodeRefPtr> nodes; 134 132 135 133 // Load all the models that the user told us to load. 136 for ( std::vector<std::string>::iterator i = mFilesToLoad.begin(); 137 i != mFilesToLoad.end(); 138 ++i ) 134 typedef std::vector<std::string>::iterator iter_type; 135 for ( iter_type i = mFilesToLoad.begin(); i != mFilesToLoad.end(); ++i ) 139 136 { 140 137 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 141 138 << "[OpenSGNavGrab::initScene()] Loading '" << *i << "' ..." 142 139 << std::endl << vprDEBUG_FLUSH; 143 OSG::NodePtr geom_node = 144 OSG::SceneFileHandler::the().read((OSG::Char8*) (*i).c_str()); 145 OSG::addRefCP(geom_node); 140 const OSG::Char8* file = (*i).c_str(); 141 OSG::NodeRefPtr geom_node( 142 #if OSG_MAJOR_VERSION < 2 143 OSG::SceneFileHandler::the().read(file) 144 #else 145 OSG::SceneFileHandler::the()->read(file) 146 #endif 147 ); 146 148 147 149 nodes.push_back(geom_node); … … 175 177 if ( ! nodes.empty() ) 176 178 { 177 const std::vector<OSG::Node Ptr>::size_type num_objs(nodes.size());179 const std::vector<OSG::NodeRefPtr>::size_type num_objs(nodes.size()); 178 180 const OSG::Real32 interval_dist(distance_vec[0]); 179 181 … … 187 189 -(interval_dist * OSG::Real32(num_objs) - interval_dist) / 2.0f; 188 190 189 for ( std::vector<OSG::NodePtr>::iterator i = nodes.begin(); 191 typedef std::vector<OSG::NodeRefPtr>::iterator iter_type; 192 for ( iter_type i = nodes.begin(); 190 193 i != nodes.end(); 191 194 ++i, x_offset += interval_dist ) … … 220 223 light_pos.setTransform(OSG::Vec3f(2.0f, 5.0f, 4.0f)); 221 224 222 OSG::beginEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask); 223 light_beacon_core->setMatrix(light_pos); 224 OSG::endEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask); 225 226 OSG::beginEditCP(mLightBeacon); 227 mLightBeacon->setCore(light_beacon_core); 228 OSG::endEditCP(mLightBeacon); 225 #if OSG_MAJOR_VERSION < 2 226 CPEdit(light_beacon_core, OSG::Transform::MatrixFieldMask); 227 CPEdit(mLightBeacon, OSG::Node::CoreFieldMask); 228 CPEdit(mLightNode, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); 229 CPEditAll(light_core); 230 #endif 231 232 light_beacon_core->setMatrix(light_pos); 233 234 mLightBeacon->setCore(light_beacon_core); 229 235 230 236 // Set up light node 231 OSG::addRefCP(mLightNode); 232 OSG::beginEditCP(mLightNode); 233 mLightNode->setCore(light_core); 234 mLightNode->addChild(mLightBeacon); 235 OSG::endEditCP(mLightNode); 236 237 OSG::beginEditCP(light_core); 238 light_core->setAmbient(0.9, 0.8, 0.8, 1); 239 light_core->setDiffuse(0.6, 0.6, 0.6, 1); 240 light_core->setSpecular(1, 1, 1, 1); 241 light_core->setDirection(0, 0, 1); 242 light_core->setBeacon(mLightNode); 243 OSG::endEditCP(light_core); 237 mLightNode->setCore(light_core); 238 mLightNode->addChild(mLightBeacon); 239 240 light_core->setAmbient(0.9, 0.8, 0.8, 1); 241 light_core->setDiffuse(0.6, 0.6, 0.6, 1); 242 light_core->setSpecular(1, 1, 1, 1); 243 light_core->setDirection(0, 0, 1); 244 light_core->setBeacon(mLightNode); 244 245 245 246 // --- Set up scene -- // 246 247 // add the loaded scene to the light node, so that it is lit by the light 247 248 OSG::beginEditCP(mLightNode); 249 mLightNode->addChild(mModelRoot); 250 OSG::endEditCP(mLightNode); 248 mLightNode->addChild(mModelRoot); 251 249 252 250 // create the root part of the scene … … 254 252 mSceneTransform = OSG::Transform::create(); 255 253 254 #if OSG_MAJOR_VERSION < 2 255 CPEdit(mSceneRoot, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); 256 #endif 257 256 258 // Set up the root node 257 OSG::beginEditCP(mSceneRoot); 258 mSceneRoot->setCore(mSceneTransform); 259 mSceneRoot->addChild(mLightNode); 260 OSG::endEditCP(mSceneRoot); 259 mSceneRoot->setCore(mSceneTransform); 260 mSceneRoot->addChild(mLightNode); 261 261 } 262 262 … … 308 308 updateGrabbing(wand_mat); 309 309 updateNavigation(wand_mat); 310 311 vrj::OpenSGApp::preFrame(); 310 312 } 311 313 … … 314 316 mVelocity = 0.0f; 315 317 316 OSG::beginEditCP(mSceneTransform, OSG::Transform::MatrixFieldMask); 317 mSceneTransform->getMatrix().setIdentity(); 318 OSG::endEditCP(mSceneTransform, OSG::Transform::MatrixFieldMask); 319 320 for ( std::vector<GrabObject*>::iterator i = mObjects.begin(); 321 i != mObjects.end(); 322 ++i ) 323 { 324 OSG::beginEditCP((*i)->xformCore, OSG::Transform::MatrixFieldMask); 325 (*i)->xformCore->getMatrix().setValue((*i)->homePos); 326 OSG::endEditCP((*i)->xformCore, OSG::Transform::MatrixFieldMask); 327 } 318 #if OSG_MAJOR_VERSION < 2 319 CPEdit(mSceneTransform, OSG::Transform::MatrixFieldMask); 320 321 mSceneTransform->getMatrix().setIdentity(); 322 #else 323 mSceneTransform->editMatrix().setIdentity(); 324 #endif 325 326 typedef std::vector<GrabObjectPtr>::iterator iter_type; 327 for ( iter_type i = mObjects.begin(); i != mObjects.end(); ++i ) 328 { 329 #if OSG_MAJOR_VERSION < 2 330 OSG::TransformPtr core = (*i)->getXformNode(); 331 CPEdit(core, OSG::Transform::MatrixFieldMask); 332 core->getMatrix().setValue((*i)->getHomePos()); 333 #else 334 (*i)->getXformNode()->editMatrix().setValue((*i)->getHomePos()); 335 #endif 336 } 337 } 338 339 void OpenSGNavGrab::exit() 340 { 341 mObjects.clear(); 342 343 mIntersectedObj = GrabObjectPtr(); 344 mGrabbedObj = GrabObjectPtr(); 345 346 mSceneRoot = OSG::NullFC; 347 mSceneTransform = OSG::NullFC; 348 mModelRoot = OSG::NullFC; 349 mModelGroup = OSG::NullFC; 350 mLightNode = OSG::NullFC; 351 mLightBeacon = OSG::NullFC; 352 mHighlight = OSG::NullFC; 353 mHighlightNode = OSG::NullFC; 354 mHighlightPoints = OSG::NullFC; 355 mHighlightMaterial = OSG::NullFC; 356 357 vrj::OpenSGApp::exit(); 328 358 } 329 359 … … 336 366 } 337 367 338 OpenSGNavGrab::GrabObject* OpenSGNavGrab::makeGrabbable(OSG::NodePtr model, 339 const OSG::Matrix& modelPos) 340 { 341 OSG::TransformPtr model_xform_core = OSG::Transform::create(); 342 OSG::beginEditCP(model_xform_core, OSG::Transform::MatrixFieldMask); 343 model_xform_core->setMatrix(modelPos); 344 OSG::endEditCP(model_xform_core, OSG::Transform::MatrixFieldMask); 345 346 OSG::NodePtr model_xform_node = OSG::Node::create(); 347 OSG::beginEditCP(model_xform_node); 348 model_xform_node->setCore(model_xform_core); 349 model_xform_node->addChild(model); 350 OSG::endEditCP(model_xform_node); 351 352 OSG::beginEditCP(mModelRoot, OSG::Node::ChildrenFieldMask); 353 mModelRoot->addChild(model_xform_node); 354 OSG::endEditCP(mModelRoot, OSG::Node::ChildrenFieldMask); 355 356 return new GrabObject(model_xform_node, model_xform_core, modelPos); 368 OpenSGNavGrab::GrabObjectPtr 369 OpenSGNavGrab::makeGrabbable(OSG::NodeRefPtr model, 370 const OSG::Matrix& modelPos) 371 { 372 OSG::TransformNodePtr model_xform_node = OSG::TransformNodePtr::create(); 373 374 #if OSG_MAJOR_VERSION < 2 375 OSG::TransformPtr core = model_xform_node; 376 CPEdit(core, OSG::Transform::MatrixFieldMask); 377 OSG::CPEditor e(model_xform_node.node(), 378 OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); 379 CPEdit(mModelRoot, OSG::Node::ChildrenFieldMask); 380 #endif 381 382 model_xform_node->setMatrix(modelPos); 383 model_xform_node.node()->addChild(model); 384 385 mModelRoot->addChild(model_xform_node.node()); 386 387 return GrabObject::create(model_xform_node, modelPos); 357 388 } 358 389 … … 381 412 // Only perform the intersection testing when we are not already grabbing 382 413 // an object. 383 if ( mGrabbedObj == NULL )384 { 385 GrabObject * intersect_obj(NULL);414 if ( mGrabbedObj.get() == NULL ) 415 { 416 GrabObjectPtr intersect_obj; 386 417 387 418 // Find the first object--if any--in mObjects with which the wand 388 419 // intersects. 389 for ( std::vector<GrabObject*>::iterator o = mObjects.begin(); 390 o != mObjects.end(); 391 ++o ) 420 typedef std::vector<GrabObjectPtr>::iterator iter_type; 421 for ( iter_type o = mObjects.begin(); o != mObjects.end(); ++o ) 392 422 { 393 const OSG::DynamicVolume& bbox = (*o)->xformNode->getVolume(); 423 const OSG::DynamicVolume& bbox = 424 (*o)->getXformNode().node()->getVolume(); 394 425 395 426 if ( bbox.intersect(wand_point) ) … … 406 437 // If mIntersectedObj was not NULL, then we need to remove the 407 438 // bounding box rendering that is now out of date. 408 if ( mIntersectedObj != NULL )439 if ( mIntersectedObj.get() != NULL ) 409 440 { 410 OSG::beginEditCP(mIntersectedObj->xformNode, 411 OSG::Node::ChildrenFieldMask);412 mIntersectedObj->xformNode->subChild(mHighlightNode);413 OSG::endEditCP(mIntersectedObj->xformNode, 414 OSG::Node::ChildrenFieldMask);441 #if OSG_MAJOR_VERSION < 2 442 OSG::CPEditor e(mIntersectedObj->getXformNode().node(), 443 OSG::Node::ChildrenFieldMask); 444 #endif 445 mIntersectedObj->getXformNode().node()->subChild(mHighlightNode); 415 446 } 416 447 … … 419 450 // If mIntersectedObj is non-NULL, we have selected a new object. 420 451 // Create a new bounding box around that object. 421 if ( mIntersectedObj != NULL )452 if ( mIntersectedObj.get() != NULL ) 422 453 { 423 mHighlight = mIntersectedObj->xformNode->getChild(0); 454 mHighlight = mIntersectedObj->getXformNode().node()->getChild(0); 455 456 #if OSG_MAJOR_VERSION < 2 457 CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask); 458 OSG::CPEditor e(mIntersectedObj->getXformNode().node(), 459 OSG::Node::ChildrenFieldMask); 460 #endif 424 461 425 462 // Set the highlight color to mIntersectColor. 426 OSG::beginEditCP(mHighlightMaterial, 427 OSG::SimpleMaterial::DiffuseFieldMask); 428 mHighlightMaterial->setDiffuse(mIntersectColor); 429 OSG::endEditCP(mHighlightMaterial, 430 OSG::SimpleMaterial::DiffuseFieldMask); 431 432 OSG::beginEditCP(mIntersectedObj->xformNode, 433 OSG::Node::ChildrenFieldMask); 434 mIntersectedObj->xformNode->addChild(mHighlightNode); 435 OSG::endEditCP(mIntersectedObj->xformNode, 436 OSG::Node::ChildrenFieldMask); 463 mHighlightMaterial->setDiffuse(mIntersectColor); 464 465 mIntersectedObj->getXformNode().node()->addChild(mHighlightNode); 466 437 467 updateHighlight(); 438 468 } … … 442 472 // Enable grabbing only when no other object is currently grabbed, when 443 473 // the wand button is intersecting an object, and when button 0 is pressed. 444 if ( mIntersectedObj != NULL && mGrabbedObj== NULL &&474 if ( mIntersectedObj.get() != NULL && mGrabbedObj.get() == NULL && 445 475 mButton0->getData() == gadget::Digital::ON ) 446 476 { 447 477 mGrabbedObj = mIntersectedObj; 448 478 479 #if OSG_MAJOR_VERSION < 2 480 CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask); 481 #endif 482 449 483 // Set the highlight color to mGrabColor. 450 OSG::beginEditCP(mHighlightMaterial, 451 OSG::SimpleMaterial::DiffuseFieldMask); 452 mHighlightMaterial->setDiffuse(mGrabColor); 453 OSG::endEditCP(mHighlightMaterial, 454 OSG::SimpleMaterial::DiffuseFieldMask); 484 mHighlightMaterial->setDiffuse(mGrabColor); 455 485 } 456 486 // We cannot be grabbing anything unless button 0 is pressed. … … 459 489 // If we are dropping a grabbed object, then set the highlight color 460 490 // back to mIntersectColor. 461 if ( mGrabbedObj != NULL )491 if ( mGrabbedObj.get() != NULL ) 462 492 { 463 OSG::beginEditCP(mHighlightMaterial, 464 OSG::SimpleMaterial::DiffuseFieldMask);465 mHighlightMaterial->setDiffuse(mIntersectColor); 466 OSG::endEditCP(mHighlightMaterial, 467 OSG::SimpleMaterial::DiffuseFieldMask);493 #if OSG_MAJOR_VERSION < 2 494 CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask); 495 #endif 496 497 mHighlightMaterial->setDiffuse(mIntersectColor); 468 498 } 469 499 470 mGrabbedObj = NULL;500 mGrabbedObj = GrabObjectPtr(); 471 501 } 472 502 473 503 // If mGrabbedObj is non-NULL, then we are grabbing the object pointed at 474 504 // by mGrabbedObj. 475 if ( mGrabbedObj != NULL ) 476 { 477 OSG::beginEditCP(mGrabbedObj->xformCore, OSG::Transform::MatrixFieldMask); 478 mGrabbedObj->xformCore->getMatrix().setTranslate(wand_point); 479 OSG::endEditCP(mGrabbedObj->xformCore, OSG::Transform::MatrixFieldMask); 505 if ( mGrabbedObj.get() != NULL ) 506 { 507 #if OSG_MAJOR_VERSION < 2 508 OSG::TransformPtr core = mGrabbedObj->getXformNode(); 509 CPEdit(core, OSG::Transform::MatrixFieldMask); 510 mGrabbedObj->getXformNode()->getMatrix().setTranslate(wand_point); 511 #else 512 mGrabbedObj->getXformNode()->editMatrix().setTranslate(wand_point); 513 #endif 480 514 } 481 515 } … … 492 526 trans_mat.setTranslate(trans[0], trans[1], trans[2]); 493 527 494 OSG::beginEditCP(mSceneTransform, OSG::Transform::MatrixFieldMask); 495 mSceneTransform->getMatrix().multLeft(trans_mat); 496 OSG::endEditCP(mSceneTransform, OSG::Transform::MatrixFieldMask); 528 #if OSG_MAJOR_VERSION < 2 529 CPEdit(mSceneTransform, OSG::Transform::MatrixFieldMask); 530 mSceneTransform->getMatrix().multLeft(trans_mat); 531 #else 532 mSceneTransform->editMatrix().multLeft(trans_mat); 533 #endif 497 534 } 498 535 … … 505 542 mHighlightMaterial = OSG::SimpleMaterial::create(); 506 543 507 OSG::beginEditCP(mHighlightMaterial); 508 mHighlightMaterial->setLit(false); 509 OSG::endEditCP(mHighlightMaterial); 544 #if OSG_MAJOR_VERSION < 2 545 CPEdit(mHighlightMaterial, OSG::SimpleMaterial::LitFieldMask); 546 #endif 547 548 mHighlightMaterial->setLit(false); 510 549 } 511 550 512 551 if ( mHighlightNode == OSG::NullFC ) 513 552 { 514 OSG::GeoPTypesPtr type = OSG::GeoPTypesUI8::create(); 515 OSG::beginEditCP(type); 516 type->push_back(GL_LINE_STRIP); 517 type->push_back(GL_LINES); 518 OSG::endEditCP(type); 519 520 OSG::GeoPLengthsPtr lens = OSG::GeoPLengthsUI32::create(); 521 OSG::beginEditCP(lens); 522 lens->push_back(10); 523 lens->push_back(6); 524 OSG::endEditCP(lens); 525 553 #if OSG_MAJOR_VERSION < 2 554 OSG::GeoPTypesPtr type = OSG::GeoPTypesUI8::create(); 555 OSG::GeoPLengthsPtr lens = OSG::GeoPLengthsUI32::create(); 556 #else 557 OSG::GeoPTypesUI8Ptr type = OSG::GeoPTypesUI8::create(); 558 OSG::GeoPLengthsUI32Ptr lens = OSG::GeoPLengthsUI32::create(); 559 #endif 526 560 OSG::GeoIndicesUI32Ptr index = OSG::GeoIndicesUI32::create(); 527 OSG::beginEditCP(index); 528 index->getFieldPtr()->push_back(0); 529 index->getFieldPtr()->push_back(1); 530 index->getFieldPtr()->push_back(3); 531 index->getFieldPtr()->push_back(2); 532 index->getFieldPtr()->push_back(0); 533 index->getFieldPtr()->push_back(4); 534 index->getFieldPtr()->push_back(5); 535 index->getFieldPtr()->push_back(7); 536 index->getFieldPtr()->push_back(6); 537 index->getFieldPtr()->push_back(4); 538 539 index->getFieldPtr()->push_back(1); 540 index->getFieldPtr()->push_back(5); 541 index->getFieldPtr()->push_back(2); 542 index->getFieldPtr()->push_back(6); 543 index->getFieldPtr()->push_back(3); 544 index->getFieldPtr()->push_back(7); 545 OSG::endEditCP(index); 546 547 mHighlightPoints = OSG::GeoPositions3f::create(); 548 OSG::beginEditCP(mHighlightPoints); 549 mHighlightPoints->push_back(OSG::Pnt3f(-1, -1, -1)); 550 mHighlightPoints->push_back(OSG::Pnt3f( 1, -1, -1)); 551 mHighlightPoints->push_back(OSG::Pnt3f(-1, 1, -1)); 552 mHighlightPoints->push_back(OSG::Pnt3f( 1, 1, -1)); 553 mHighlightPoints->push_back(OSG::Pnt3f(-1, -1, 1)); 554 mHighlightPoints->push_back(OSG::Pnt3f( 1, -1, 1)); 555 mHighlightPoints->push_back(OSG::Pnt3f(-1, 1, 1)); 556 mHighlightPoints->push_back(OSG::Pnt3f( 1, 1, 1)); 557 OSG::endEditCP(mHighlightPoints); 558 559 OSG::GeometryPtr geo = OSG::Geometry::create(); 560 OSG::beginEditCP(geo); 561 geo->setTypes(type); 562 geo->setLengths(lens); 563 geo->setIndices(index); 564 geo->setPositions(mHighlightPoints); 565 geo->setMaterial(mHighlightMaterial); 566 OSG::endEditCP(geo); 567 OSG::addRefCP(geo); 568 569 mHighlightNode = OSG::Node::create(); 570 OSG::beginEditCP(mHighlightNode); 571 mHighlightNode->setCore(geo); 572 OSG::endEditCP(mHighlightNode); 573 OSG::addRefCP(mHighlightNode); 561 mHighlightPoints = OSG::GeoPositions3f::create(); 562 OSG::GeometryPtr geo = OSG::Geometry::create(); 563 mHighlightNode = OSG::Node::create(); 564 565 #if OSG_MAJOR_VERSION < 2 566 CPEditAll(type); 567 CPEditAll(lens); 568 CPEditAll(index); 569 CPEditAll(mHighlightPoints); 570 CPEditAll(geo); 571 CPEdit(mHighlightNode, OSG::Node::CoreFieldMask); 572 #endif 573 574 type->push_back(GL_LINE_STRIP); 575 type->push_back(GL_LINES); 576 577 lens->push_back(10); 578 lens->push_back(6); 579 580 #if OSG_MAJOR_VERSION < 2 581 OSG::GeoIndicesUI32::StoredFieldType* index_field = 582 index->getFieldPtr(); 583 #else 584 OSG::GeoIndicesUI32::StoredFieldType* index_field = 585 index->editFieldPtr(); 586 #endif 587 588 index_field->push_back(0); 589 index_field->push_back(1); 590 index_field->push_back(3); 591 index_field->push_back(2); 592 index_field->push_back(0); 593 index_field->push_back(4); 594 index_field->push_back(5); 595 index_field->push_back(7); 596 index_field->push_back(6); 597 index_field->push_back(4); 598 599 index_field->push_back(1); 600 index_field->push_back(5); 601 index_field->push_back(2); 602 index_field->push_back(6); 603 index_field->push_back(3); 604 index_field->push_back(7); 605 606 mHighlightPoints->push_back(OSG::Pnt3f(-1, -1, -1)); 607 mHighlightPoints->push_back(OSG::Pnt3f( 1, -1, -1)); 608 mHighlightPoints->push_back(OSG::Pnt3f(-1, 1, -1)); 609 mHighlightPoints->push_back(OSG::Pnt3f( 1, 1, -1)); 610 mHighlightPoints->push_back(OSG::Pnt3f(-1, -1, 1)); 611 mHighlightPoints->push_back(OSG::Pnt3f( 1, -1, 1)); 612 mHighlightPoints->push_back(OSG::Pnt3f(-1, 1, 1)); 613 mHighlightPoints->push_back(OSG::Pnt3f( 1, 1, 1)); 614 615 geo->setTypes(type); 616 geo->setLengths(lens); 617 geo->setIndices(index); 618 geo->setPositions(mHighlightPoints); 619 geo->setMaterial(mHighlightMaterial); 620 621 mHighlightNode->setCore(geo); 574 622 } 575 623 } … … 589 637 vol.getBounds(min, max); 590 638 591 OSG::beginEditCP(mHighlightPoints); 592 mHighlightPoints->setValue(OSG::Pnt3f(min[0], min[1], min[2]), 0); 593 mHighlightPoints->setValue(OSG::Pnt3f(max[0], min[1], min[2]), 1); 594 mHighlightPoints->setValue(OSG::Pnt3f(min[0], max[1], min[2]), 2); 595 mHighlightPoints->setValue(OSG::Pnt3f(max[0], max[1], min[2]), 3); 596 mHighlightPoints->setValue(OSG::Pnt3f(min[0], min[1], max[2]), 4); 597 mHighlightPoints->setValue(OSG::Pnt3f(max[0], min[1], max[2]), 5); 598 mHighlightPoints->setValue(OSG::Pnt3f(min[0], max[1], max[2]), 6); 599 mHighlightPoints->setValue(OSG::Pnt3f(max[0], max[1], max[2]), 7); 600 OSG::endEditCP(mHighlightPoints); 601 602 OSG::beginEditCP(mHighlightNode->getCore(), 603 OSG::Geometry::PositionsFieldMask); 604 OSG::endEditCP(mHighlightNode->getCore(), 605 OSG::Geometry::PositionsFieldMask); 606 } 639 #if OSG_MAJOR_VERSION < 2 640 CPEditAll(mHighlightPoints); 641 OSG::CPEditor e(mHighlightNode->getCore(), 642 OSG::Geometry::PositionsFieldMask); 643 #endif 644 645 mHighlightPoints->setValue(OSG::Pnt3f(min[0], min[1], min[2]), 0); 646 mHighlightPoints->setValue(OSG::Pnt3f(max[0], min[1], min[2]), 1); 647 mHighlightPoints->setValue(OSG::Pnt3f(min[0], max[1], min[2]), 2); 648 mHighlightPoints->setValue(OSG::Pnt3f(max[0], max[1], min[2]), 3); 649 mHighlightPoints->setValue(OSG::Pnt3f(min[0], min[1], max[2]), 4); 650 mHighlightPoints->setValue(OSG::Pnt3f(max[0], min[1], max[2]), 5); 651 mHighlightPoints->setValue(OSG::Pnt3f(min[0], max[1], max[2]), 6); 652 mHighlightPoints->setValue(OSG::Pnt3f(max[0], max[1], max[2]), 7); 653 654 #if OSG_MAJOR_VERSION >= 2 655 OSG::commitChanges(); 656 #endif 657 } juggler/trunk/modules/vrjuggler/samples/OpenSG/advanced/OpenSGNavGrab/OpenSGNavGrab.h
r19729 r20214 30 30 #include <string> 31 31 #include <vector> 32 33 #include <OpenSG/OSGGeoPropPtrs.h> 32 #include <boost/shared_ptr.hpp> 33 34 34 #include <OpenSG/OSGNode.h> 35 35 #include <OpenSG/OSGSimpleMaterial.h> 36 36 #include <OpenSG/OSGTransform.h> 37 37 #include <OpenSG/OSGGL.h> 38 #if OSG_MAJOR_VERSION < 2 39 # include <OpenSG/OSGGeoPropPtrs.h> 40 #else 41 # include <OpenSG/OSGTypedGeoVectorProperty.h> 42 #endif 38 43 39 44 #include <gmtl/Matrix.h> … … 97 102 virtual void reset(); 98 103 104 virtual void exit(); 105 99 106 private: 100 struct GrabObject 101 { 102 GrabObject(OSG::NodePtr node, OSG::TransformPtr xform, 103 const OSG::Matrix& pos) 104 : xformNode(node) 105 , xformCore(xform) 106 , homePos(pos) 107 class GrabObject; 108 typedef boost::shared_ptr<GrabObject> GrabObjectPtr; 109 110 class GrabObject 111 { 112 public: 113 static GrabObjectPtr create(OSG::TransformNodePtr node, 114 const OSG::Matrix& pos) 115 { 116 return GrabObjectPtr(new GrabObject(node, pos)); 117 } 118 119 OSG::TransformNodePtr getXformNode() const 120 { 121 return mXformNode; 122 } 123 124 const OSG::Matrix& getHomePos() const 125 { 126 return mHomePos; 127 } 128 129 private: 130 GrabObject(OSG::TransformNodePtr node, const OSG::Matrix& pos) 131 : mXformNode(node) 132 , mHomePos(pos) 107 133 { 108 134 ; … … 110 136 111 137 /** The transform node (parent) for the grabbable object. */ 112 OSG::NodePtr xformNode; 113 114 /** The transform core for the grabbable object. */ 115 OSG::TransformPtr xformCore; 138 OSG::TransformNodePtr mXformNode; 116 139 117 140 /** … … 119 142 * for resetting the scene. 120 143 */ 121 const OSG::Matrix homePos;144 const OSG::Matrix mHomePos; 122 145 }; 123 146 … … 136 159 * caller to release the memory. 137 160 */ 138 GrabObject* makeGrabbable(OSG::NodePtr model, const OSG::Matrix& modelPos); 161 GrabObjectPtr makeGrabbable(OSG::NodeRefPtr model, 162 const OSG::Matrix& modelPos); 139 163 140 164 void updateGrabbing(const gmtl::Matrix44f& wandMatrix); … … 155 179 // | 156 180 // mModelRoot:[mModelGroup] 157 OSG::Node PtrmSceneRoot; /**< The root of the scene */158 OSG::Transform PtrmSceneTransform; /**< Transform core */159 OSG::Node PtrmModelRoot; /**< Root of the loaded model */160 OSG::Group PtrmModelGroup;161 162 OSG::Node PtrmLightNode; /**< Light node to use */163 OSG::Node PtrmLightBeacon; /**< A beacon for the light */181 OSG::NodeRefPtr mSceneRoot; /**< The root of the scene */ 182 OSG::TransformRefPtr mSceneTransform; /**< Transform core */ 183 OSG::NodeRefPtr mModelRoot; /**< Root of the loaded model */ 184 OSG::GroupRefPtr mModelGroup; 185 186 OSG::NodeRefPtr mLightNode; /**< Light node to use */ 187 OSG::NodeRefPtr mLightBeacon; /**< A beacon for the light */ 164 188 165 189 gadget::PositionInterface mWandPos; /**< The position of the wand */ … … 172 196 /** @name Grabbed object management */ 173 197 //@{ 174 std::vector<GrabObject *> mObjects;175 GrabObject *mIntersectedObj;176 GrabObject *mGrabbedObj;198 std::vector<GrabObjectPtr> mObjects; 199 GrabObjectPtr mIntersectedObj; 200 GrabObjectPtr mGrabbedObj; 177 201 //@} 178 202 179 203 /** @name Highlight node management */ 180 204 //@{ 181 OSG::Color3f mIntersectColor;182 OSG::Color3f mGrabColor;183 184 OSG::Node Ptr mHighlight;/**< The node to highlight */185 OSG::Node Ptr mHighlightNode;/**< The highlight node */186 OSG::GeoPositions3fPtr mHighlightPoints;/**< Points for mHighlightNode */187 188 OSG::SimpleMaterial Ptr mHighlightMaterial;205 OSG::Color3f mIntersectColor; 206 OSG::Color3f mGrabColor; 207 208 OSG::NodeRefPtr mHighlight; /**< The node to highlight */ 209 OSG::NodeRefPtr mHighlightNode; /**< The highlight node */ 210 OSG::GeoPositions3fPtr mHighlightPoints; /**< Points for mHighlightNode */ 211 212 OSG::SimpleMaterialRefPtr mHighlightMaterial; 189 213 //@} 190 214 }; juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/Makefile.in
r19729 r20214 44 44 OPENSG_LIBS= $(shell osg-config --libs) -lOSGBase -lOSGSystem 45 45 OPENSG_CFLAGS= $(shell osg-config --cflags) 46 #OPENSG_LIBS= $(shell osg2-config OSGFileIO OSGWindow OSGRenderTraversal --libs) 47 #OPENSG_CFLAGS= $(shell osg2-config OSGFileIO OSGWindow OSGRenderTraversal --cflags) 46 48 47 49 EXTRA_CXXFLAGS+= $(OPENSG_CFLAGS) juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/OpenSGNav.cpp
r20137 r20214 111 111 trans_mat.setTranslate(trans[0], trans[1], trans[2]); 112 112 113 OSG::beginEditCP(mSceneTransform); 114 mSceneTransform->getMatrix().multLeft(trans_mat); 115 OSG::endEditCP(mSceneTransform); 113 #if OSG_MAJOR_VERSION < 2 114 CPEdit(mSceneTransform, OSG::Transform::MatrixFieldMask); 115 mSceneTransform->getMatrix().multLeft(trans_mat); 116 #else 117 mSceneTransform->editMatrix().multLeft(trans_mat); 118 #endif 119 120 vrj::OpenSGApp::preFrame(); 121 } 122 123 void OpenSGNav::exit() 124 { 125 // Ensure that we release all the OSG::RefPtr<T> objects that we hold so 126 // that OpenSG can shut down cleanly. 127 mSceneRoot = OSG::NullFC; 128 mSceneTransform = OSG::NullFC; 129 mModelRoot = OSG::NullFC; 130 mLightNode = OSG::NullFC; 131 mLightBeacon = OSG::NullFC; 132 133 vrj::OpenSGApp::exit(); 116 134 } 117 135 … … 153 171 << "[OpenSGNav::initScene()] Loading '" << mFileToLoad << "' ..." 154 172 << std::endl << vprDEBUG_FLUSH; 155 mModelRoot = 156 OSG::SceneFileHandler::the().read((OSG::Char8*) (mFileToLoad.c_str())); 173 const OSG::Char8* file = mFileToLoad.c_str(); 174 #if OSG_MAJOR_VERSION < 2 175 mModelRoot = OSG::SceneFileHandler::the().read(file); 176 #else 177 mModelRoot = OSG::SceneFileHandler::the()->read(file); 178 #endif 157 179 } 158 180 … … 169 191 light_pos.setTransform(OSG::Vec3f(2.0f, 5.0f, 4.0f)); 170 192 171 OSG::beginEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask); 172 light_beacon_core->setMatrix(light_pos); 173 OSG::endEditCP(light_beacon_core, OSG::Transform::MatrixFieldMask); 174 175 OSG::beginEditCP(mLightBeacon); 176 mLightBeacon->setCore(light_beacon_core); 177 OSG::endEditCP(mLightBeacon); 193 #if OSG_MAJOR_VERSION < 2 194 CPEdit(light_beacon_core, OSG::Transform::MatrixFieldMask); 195 CPEdit(mLightBeacon, OSG::Node::CoreFieldMask); 196 CPEdit(mLightNode, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); 197 CPEditAll(light_core); 198 CPEdit(mSceneRoot, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); 199 #endif 200 201 light_beacon_core->setMatrix(light_pos); 202 203 mLightBeacon->setCore(light_beacon_core); 178 204 179 205 // Setup light node 180 OSG::addRefCP(mLightNode); 181 OSG::beginEditCP(mLightNode); 182 mLightNode->setCore(light_core); 183 mLightNode->addChild(mLightBeacon); 184 OSG::endEditCP(mLightNode); 185 186 OSG::beginEditCP(light_core); 187 light_core->setAmbient (0.9, 0.8, 0.8, 1); 188 light_core->setDiffuse (0.6, 0.6, 0.6, 1); 189 light_core->setSpecular (1, 1, 1, 1); 190 light_core->setDirection (0, 0, 1); 191 light_core->setBeacon (mLightNode); 192 OSG::endEditCP(light_core); 206 mLightNode->setCore(light_core); 207 mLightNode->addChild(mLightBeacon); 208 209 light_core->setAmbient (0.9, 0.8, 0.8, 1); 210 light_core->setDiffuse (0.6, 0.6, 0.6, 1); 211 light_core->setSpecular (1, 1, 1, 1); 212 light_core->setDirection(0, 0, 1); 213 light_core->setBeacon (mLightNode); 193 214 194 215 // --- Setup Scene -- // 195 216 // add the loaded scene to the light node, so that it is lit by the light 196 OSG::addRefCP(mModelRoot); 197 OSG::beginEditCP(mLightNode); 198 mLightNode->addChild(mModelRoot); 199 OSG::endEditCP(mLightNode); 217 mLightNode->addChild(mModelRoot); 200 218 201 219 // create the root part of the scene … … 204 222 205 223 // Set up the root node 206 OSG::beginEditCP(mSceneRoot); 207 mSceneRoot->setCore(mSceneTransform); 208 mSceneRoot->addChild(mLightNode); 209 OSG::endEditCP(mSceneRoot); 210 } 224 mSceneRoot->setCore(mSceneTransform); 225 mSceneRoot->addChild(mLightNode); 226 } juggler/trunk/modules/vrjuggler/samples/OpenSG/simple/OpenSGNav/OpenSGNav.h
r19729 r20214 95 95 } 96 96 97 virtual void exit(); 98 97 99 void setModelFileName(std::string filename) 98 100 { … … 115 117 // | 116 118 // mModelRoot 117 OSG::Node Ptr mSceneRoot; /**< The root of the scene */118 OSG::Transform Ptr mSceneTransform; /**< Transform core */119 OSG::Node Ptr mModelRoot; /**< Root of the loaded model */119 OSG::NodeRefPtr mSceneRoot; /**< The root of the scene */ 120 OSG::TransformRefPtr mSceneTransform; /**< Transform core */ 121 OSG::NodeRefPtr mModelRoot; /**< Root of the loaded model */ 120 122 121 OSG::Node Ptr mLightNode; /**< Light node to use */122 OSG::Node Ptr mLightBeacon; /**< A beacon for the light */123 OSG::NodeRefPtr mLightNode; /**< Light node to use */ 124 OSG::NodeRefPtr mLightBeacon; /**< A beacon for the light */ 123 125 124 126 public: juggler/trunk/modules/vrjuggler/vrj/Draw/OpenSG/OpenSGApp.h
r20202 r20214 126 126 127 127 /** 128 * Shuts down OpenSG. If overridden, the overriding method call this128 * Shuts down OpenSG. If overridden, the overriding method must call this 129 129 * method.
