Problem with SoJackDragger

Problem with SoJackDragger

Post by Jaso » Wed, 09 Apr 2003 05:22:12



I am using TGS Open Inventor++, and I have a problem to use
SoJackDragger class. Initially, the SoJackDragger's
jackTranslatorLineTranslators(x,y,z) are turned on. The default
direction is Z-axis, which you can drag it and move it in Z
direction(translate). By pressing Ctrl key while mouse over the
dragger, it will change to Y direction, do it again to change to X
direction. Note in this way, it does NOT change the rotation value of
the dragger since it's not doing a rotation.(only changing the part)

The problem now I have is, how do I make it default in Y direction
instead of Z when it is created or after created without doing a
rotation? If I do a rotation like this:

pdragger->rotation.setValue(SbRotation(SbVec3f(1,0,0), pi / 2));

it would give me the same visual effect(active part now is in Y
direction), but it also changed the rotation value. The dragger is
connected to a SoTransform, I do not want this happen because it will
rotate the connected shape too.

Please give some advice on how to do it, thanks a lot!

Jason.

 
 
 

Problem with SoJackDragger

Post by Mike He » Thu, 10 Apr 2003 05:17:06



> I am using TGS Open Inventor++, and I have a problem to use
> SoJackDragger class. Initially, the SoJackDragger's
> jackTranslatorLineTranslators(x,y,z) are turned on. The default
> direction is Z-axis, which you can drag it and move it in Z
> direction(translate). By pressing Ctrl key while mouse over the
> dragger, it will change to Y direction, do it again to change to X
> direction. Note in this way, it does NOT change the rotation value of
> the dragger since it's not doing a rotation.(only changing the part)

> The problem now I have is, how do I make it default in Y direction
> instead of Z when it is created or after created without doing a
> rotation? If I do a rotation like this:

It's not at all obvious, :-) but it's not hard.
Try the following utility function.

-Mike
 TGS Inc, http://www.tgs.com

/////////////////////////////////////////////////////////////
//
// Set the "main axis" of a JackDragger to the specified axis
//   0 - X
//   1 - Y
//   2 - Z
//
// By default the main axis is Y.
//
// We are really changing the DragPointDragger underneath,
// which provides showNextDraggerSet to cycle through the
// axes, but does not allow jumping to a specific axis.
//
void
setDraggerMainAxis( SoJackDragger *pJack, int axis )
{
  if (pJack == NULL || axis < 0 || axis > 2)
    return;

  // Get the dragPointDragger
  SoDragPointDragger *pDrag =
    (SoDragPointDragger*) pJack->getPart( "translator", FALSE );

  // Get the switch nodes that control which sub-draggers are displayed.
  // Unfortunately these nodes are not "public" parts of the nodekit so
  // we can't get them by simply calling getPart().  However we can
  // cheat by getting a path to their child, which is public, then
  // getting the switch node from the path.  Note that we must use an
  // SoFullPath pointer to access the hidden nodes.

  SoFullPath *pPath;
  pPath = (SoFullPath*)pDrag->createPathToPart( "xTranslator",  FALSE );
  SoSwitch *xTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );
  pPath = (SoFullPath*)pDrag->createPathToPart( "yTranslator",  FALSE );
  SoSwitch *yTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );
  pPath = (SoFullPath*)pDrag->createPathToPart( "zTranslator",  FALSE );
  SoSwitch *zTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );
  pPath = (SoFullPath*)pDrag->createPathToPart( "yzTranslator",  FALSE );
  SoSwitch *yzTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );
  pPath = (SoFullPath*)pDrag->createPathToPart( "xzTranslator",  FALSE );
  SoSwitch *xzTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );
  pPath = (SoFullPath*)pDrag->createPathToPart( "xyTranslator",  FALSE );
  SoSwitch *xyTranslatorSwitch = (SoSwitch *)pPath->getNodeFromTail( 1 );

  // Switch to X axis
  if (axis == 0) {
    xTranslatorSwitch->whichChild  = 0;
    yTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    zTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    yzTranslatorSwitch->whichChild = 0;
    xzTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    xyTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    return;
  }

  // Switch to Y axis
  if (axis == 1) {
    xTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    yTranslatorSwitch->whichChild  = 0;
    zTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    yzTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    xzTranslatorSwitch->whichChild = 0;
    xyTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    return;
  }

  // Switch to Z axis
  if (axis == 2) {
    xTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    yTranslatorSwitch->whichChild  = SO_SWITCH_NONE;
    zTranslatorSwitch->whichChild  = 0;
    yzTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    xzTranslatorSwitch->whichChild = SO_SWITCH_NONE;
    xyTranslatorSwitch->whichChild = 0;
    return;
  }

Quote:}


 
 
 

1. Problem about using SoJackDragger

Hello,

        My problem is:

        After I change the appearance of SoRotateSphericalDragger part of
        SoJackDragger by setPart, I found that the other part of the dragger
        didn't move coherently with it! So, I connect the rotation field of
        SoJackDragger from the that of the newly created
        SoRotateSphericalDragger. Moreover, I need to connect another
        SoRotation field to the overall rotation of that SoJackDragger.

        However, the motion is still not coherent. Have anyone come across
        with this?

                                                        Philip
                                                               CUHK

2. NVIDIA OpenGL for win32 question

3. SoJackDragger

4. Announce: GIF-video without plug-ins

5. soJackdragger

6. PC 3D Graphics Accelerators FAQ (Part 2 of 2)

7. Problems..Problems..Problems

8. 3d house needed - heeelp

9. UDO importation problem/POV-ray rendering problem?

10. (new Problems) FINAL: 8-bit colormap problems

11. TEXT PROBLEM: Unwanted grey box behind text and other problems

12. problem with rotating objects and other problems