Re: view control

New Message Reply Date view Thread view Subject view Author view

Scott McMillan (scott++at++ht.com)
Thu, 15 Aug 1996 10:19:06 -0400 (EDT)


>
> Does anyone have example code for ways to control the view, other
> than the pfiTDFXformer, which you'd be willing to share? I have real
> problems looking where I'd like to with flying models. What I'd really
> like is to be able to do is to adjust spherical coordinates that move
> the eyepoint along a sphere centered on an object of interest, with the
> view direction always towards the sphere's center.
>
> Thanks.
>
> Lisa Desjarlais
> lisa++at++cs.unm.edu

I have developed a few different camera classes, and the one you describe is
a COI (center-of-interest) camera.

Assume the camera travels on a sphere centered at the coi with a desired
radius (distance of camera from the object). The north pole or "up"
direction is along Performer's z-axis.

You also need variables for pitch (angle above below the horizon) and heading
(angle around the sphere). I assume that there is no roll; i.e., "up"
relative to the view is always the direction that points along longitude
lines towards the north pole of the sphere you are on, and "right" always
points east along latitude lines.

 - set the coi in absolute performer coordinates
   pfVec3 m_pos_coi;
   m_pos_coi.set(0.0f, 0.0f, 0.0f);

 - set pitch, heading and radius:
   float m_heading, m_pitch, m_radius;

   I allow the heading to wrap from 180 to -180 so that I can spin around
   continuosly, and I limit the pitch to be between -90 (south pole view, I
   think) to +90 (north pole). I also prevent the radius from going negative.

 - compute sin and cos of pitch and heading:
   float m_sinH, m_cosH, m_sinP, m_cosP;
   pfSinCos(m_heading, &m_sinH, &m_cosH);
   pfSinCos(m_pitch, &m_sinP, &m_cosP);

 - compute the position and orientation of the camera:
   pfCoord m_camera_coord;
   m_camera_coord.xyz.set((m_pos_coi[PF_X] + m_radius*m_sinH*m_cosP),
                          (m_pos_coi[PF_Y] - m_radius*m_cosH*m_cosP),
                          (m_pos_coi[PF_Z] - m_radius*m_sinP));
   m_camera_coord.hpr.set(m_heading,
                          m_pitch,
                          0.0);

 - set the channel view:
   pfMatrix m_view_mat;
   m_view_mat.makeCoord(m_camera_coord);
   channel->setViewMat(m_view_mat);

          OR (I think)

   channel->setView(m_coord_camera.xyz, m_coord_camera.hpr);

Hope this helps,
scott

-- 
  Scott McMillan  |      HT Medical, Inc.      | Developing virtual environ-
   scott++at++ht.com   |     http://www.ht.com      | ment medical and surgical
 Ph: 301-984-3706 | 6001 Montrose Rd., St. 902 | simulations and surgery
Fax: 301-984-2104 |    Rockville, MD 20852     | simulation creation tools.

======================================================================= 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:22 PDT

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