Trackball xformer

New Message Reply Date view Thread view Subject view Author view

Mihir Mehta (mehta++at++turing.rdd.lmsc.lockheed.com)
Thu, 22 Aug 1996 12:23:33 -0700 (PDT)


Hi,

   I am trying to incorporate the trackball transform in my code.
I am having problem in the initial values that I get from the
trackball transform. Even though I have initialized the trackball
with setCoord (view->xyzhpr), it prints xyzhpr = ({0,0,0},{0,0,0})
after the first call to update which should not be the case as my
initial view position is xyzhpr = ({0 -4.19156 0},{0 0 0}).
It seems I am missing some call in the initialization that should
tell the trackball to start with a transformation that corresponds
with the initial view position. Thanks for any help.

Mihir

Here is the code that I use.

  // Initialization and trackball setup
  pfiInit();

  xTrackball = pfiCreate2DIXformTrackball(pfGetSharedArena());
  xTrackball->xMotionCoord.startSpeed = 3.0f;
   
  pfBox box;

  pfuTravCalcBBox(getPfScene(),&box);
  xTrackball->setDBLimits(&box);

  pfCoord coord;

  getViewCoord(&coord);
  xTrackball->setResetCoord(&coord);
  xTrackball->setCoord(&coord);

  .
  .
  .
  .
  .
  .
  .

  // Event handling in the trackball mode

  pfCoord coord;
  pfMatrix mat;

  // stop when button is released
  if(button_released)
    {
      xTrackball->setMode(PFIXTK_MODE_MOTION,
                          PFIXTK_MOTION_STOP);
      xTrackball->setFocus(0);
      return;
    }

  // supply the trackball xform with the normalized mouse pos
  // and activate trackball
  pfiInputCoord* icoord = xTrackball->getInputCoordPtr();
  icoord->setVec(event->normalized_mouse_position.vec);
  xTrackball->setMode(PFIX_MODE_AUTO, 0);
  xTrackball->setFocus(1);

  // actions according to mouse button clicked
  switch(event->button)
    {
    case 1:
      xTrackball->setMode(PFIXTK_MODE_MOTION,
                          PFIXTK_MOTION_TRANSXZ);
      break;

    case 2:
      xTrackball->setMode(PFIXTK_MODE_MOTION,
                          PFIXTK_MOTION_ROTXZ);
      break;
       
    case 3:
      xTrackball->setMode(PFIXTK_MODE_MOTION,
                          PFIXTK_MOTION_TRANSY);
      break;
    }

  // update the view with the trackball xform
  xTrackball->update();
  xTrackball->getMat(mat);
  mat.getOrthoCoord(&coord);
  setViewCoord(&coord);
   
  .
  .
  .
  .
  .
  .

-- 
Mihir Mehta                              Address : Orgn H1-41 Bldg 255
mehta++at++stc.lockheed.com                             3170 Porter Drive
Ph  415-424-3555                                   Palo Alto, CA 94304-1211
Fax 415-354-5235
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:24 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.