Re: view vector -> hpr

New Message Reply Date view Thread view Subject view Author view

Dan Mapes (dmapes++at++roninworks.com)
Thu, 14 Oct 1999 08:19:55 +0200


You have all the components of a special orthogonal matrix (Foley & Van Dam
et.al. pg 207). The process of extracting hpr from an orthogonal matrix can
be done, but it's not necessary in your case. It's far simpler to build a
valid orientation matrix and apply it directly to the view or DCS/SCS nodes.

In performer with an identity view matrix, Z is up, the view is along
negative Y and the X axis is "to the left".

// Assuming orthogonal and normalized view, up and right direction vectors.
pfVec3 leftDir( rightDir );
leftDir.negate();

pfVec3 invViewDir( viewDir );
invViewDir.negate();

pfMatrix mat;
mat.makeIdent();
mat.setRow( 0, rightDir );
mat.setRow( 1, invViewDir );
mat.setRow( 2, upDir );

channel.setViewMat( mat );
pfSCS scs( mat );
dcs.setMat( mat );

If the mapping given above for some reason does not work correctly in your
app, the basic approach is still valid and can be easily fixed by modifying
the direction and/or order of the vectors.

>given three vectors representing the view direction, the up vector,
>and the right vector, how does one convert to hpr?
>specifically, i know how an object is oriented in a given coordinate
>system by the aforementioned orthogonal vectors. but i need to
>convert to hpr so performer can properly orient the object.

>-----------------------------------------------------------------------
>List Archives, FAQ, FTP: http://www.sgi.com/software/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 Wed Oct 13 1999 - 23:21:28 PDT

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