Announcement

Collapse
No announcement yet.

a scene orbiter like SoViewingCube

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • a scene orbiter like SoViewingCube

    Dear All,
    Please i'd like to have a scene orbiter like SoViewingCube in OpenInventor 9.x.y;

    My idea is to have sub graph whit a a cubic shape (i don't know how to round corners, maybe i must draw manually the entire cube with the round corners, too) with a soResetTransform (so the camere will not affect this shape sub graph) and a click callback in order to orient the main viewer camera.

    Please, Is it possible to have a little source code to expand?

    Thank You very much in advance.

    Regards,

    Vincenzo

  • #2
    Originally posted by [email protected] View Post
    Dear All,
    Please i'd like to have a scene orbiter like SoViewingCube in OpenInventor 9.x.y;
    My idea is to have sub graph whit a a cubic shape (i don't know how to round corners, maybe i must draw manually the entire cube with the round corners, too) with a soResetTransform (so the camere will not affect this shape sub graph) and a click callback in order to orient the main viewer camera.
    Please, Is it possible to have a little source code to expand?
    Hi Vincenzo,
    The source code for SoViewingCube is quite complicated because of all the options (rounded or flat edges, etc). We probably won't provide that.

    It might be helpful to look at the source code that we provide for the "Gnomon" class in $OIVHOME/source/Medical/nodes
    The implementation is not specific to medical applications. It's under the medical directory because the default geometry displays text for the medical axis names (A for Anterior, P for Posterior, etc). You can easily change the geometry to whatever you need. You will see, for example, that SoResetTransform is not sufficient to solve this problem. A viewing cube must have its own camera node and a callback node that updates that camera to match the scene camera. The callback node also modifies the SoViewportRegionElement to make the viewing cube display in one corner of the 3D window.

    It should be possible to extend this code to modify the scene camera based on a mouse click. Couple things to do:
    • Implement a way to specify the scene camera.
      For example, add an SoSFNode field (or just a setCamera method).
      The current Gnomon class doesn't need a ptr to the scene camera because it gets the view matrix from the traversal state.
    • Add an SoEventCallback node to the internal scene graph.
      When the event callback sees a mouse button event, get the current pick path and test if the path contains the viewing cube node. If yes, then determine which part of the cube was clicked and take the appropriate action.
    Regards,
    Mike

    Comment


    • #3
      Good morning Mike,
      first of all Thank You very much: i'll try to follow Your suggestions.

      Best Regards,
      Vincenzo

      Comment


      • #4
        Dear Mike,
        Please, can You suggest me how to ray pick a node derived from SoAnnotation?

        i have a "SoSceneCubeOrbiter" that is the gnomon class renamed;

        in my viewer event callback i have the following code:

        Code:
        SbViewportRegion myRegion = eventCB->getAction()->getViewportRegion();
        SbVec2s cursorPosition = pEvent->getPosition(myRegion);
        SoNode *pToNode= FindNodeByName(_T("SoSceneCubeOrbiter")); //or SoNode *pToNode= (SoNode *)g_pSceneGraphRootSeparator;
        
        SoRayPickAction myPickAction(myRegion);
        myPickAction.enableTexCoordsGeneration(true);
        myPickAction.enableRadiusForTriangles(true);
        myPickAction.setPoint(cursorPosition);
        myPickAction.setPickingMode(SoRayPickAction:: DEFAULT);
        myPickAction.enableNormalsGeneration(true);
        myPickAction.setRadius(1.f);
        myPickAction.setPickAll(true);
        
        myPickAction.apply(pToNode);
        
        p3DView->GetViewer()->unbindNormalContext();
        
        const SoPickedPointList& ppList = myPickAction.getPickedPointList();
        
        const int nPicked = ppList.getLength();
        but unluckily, using SoRayPickAction in this way, i'm not able to pick the node about "SoSceneCubeOrbiter" also if ray pick action is applyed to entire scene graph root.

        Please, can You suggest me how pick a SoAnnotation derived node?

        Thank You in advance.

        Regards,

        Vincenzo

        Comment


        • #5
          update:
          i've tried to remove the "unpickable" style from the scene cube orbiter geometry, too but nothing to do...i'm not able to pick it...

          Comment


          • #6
            another update:
            also deriving the SoSceneCubeOrbiter from SoSeparator instead of SoAnnotation, nothing changes :-(

            Comment


            • #7
              Hy Mike,
              i've found my fault and now i succed to retrive the face detail about cube geometry.

              Thank You very much for Your precious help.

              Vincenzo

              Comment

              Working...
              X