Simon.Mills++at++esa.int
Date: 08/01/2003 09:40:34
Hi,
there isn't a direct equivalent, however I saved this posting with a reply to
your question it from a long time ago (and never actually used it). May it
can help you.
---- Quote ---
>From guest++at++holodeck.asd.sgi.com Mon Apr 8 19:00 MET 1996
From: "Nicolas Gauvin" <nicolas++at++cae.ca>
Date: Mon, 8 Apr 1996 11:57:11 -0400
To: dnouls++at++luc.ac.be
Subject: Re: LookAt in Performer
Cc: hatch++at++sgi.sgi.com, info-performer++at++sgi.sgi.com
Mime-Version: 1.0
David Nouls <dnouls++at++luc.ac.be> was saying:
> How can I simulate gluLookAt with Performer calls ?
You need to compute a pfMatrix containing the correct rotations and
translations. Then you set this matrix as the viewing matrix of your
pfChannel
via the C pfChanSetViewMat or C++ pfChannel::setViewMat call.
Here is an implementation of a function that will create this matrix for you:
Note that the restriction that the up vector must not be parallel to
the viewing direction still holds.
/* C version */
void pfMakeLookAtMat( pfMatrix mat, pfVec3 eye, pfVec3 center, pfVec3 up )
{
/* row unit vectors representing axis rotations */
pfVec3 x,y,z;
/* Y vector points from eye to center */
y[PF_X] = center[PF_X] - eye[PF_X];
y[PF_Y] = center[PF_Y] - eye[PF_Y];
y[PF_Z] = center[PF_Z] - eye[PF_Z];
pfNormalizeVec3(y);
/* Z vector is UP */
z[PF_X] = up[PF_X];
z[PF_Y] = up[PF_Y];
z[PF_Z] = up[PF_Z];
/* X vector = Y cross Z */
pfCrossVec3(x, y, z);
pfNormalizeVec3(x);
/* Recompute Z = X cross Y to make it perpendicular to the others */
pfCrossVec3(z, x, y);
pfNormalizeVec3(z);
/* create final matrix */
/* first set translation */
pfMakeTransMat(mat,eye[PF_X],eye[PF_Y],eye[PF_Z]);
/* then set normalized axis rotation row vectors */
pfSetMatRowVec3(mat,0,x);
pfSetMatRowVec3(mat,1,y);
pfSetMatRowVec3(mat,2,z);
}
/* C++ version */
void pfMakeLookAtMat( pfMatrix& mat, pfVec3& eye, pfVec3& center, pfVec3& up
)
{
// row unit vectors representing axis rotations
pfVec3 x,y,z;
// Y vector points from eye to center
y = center - eye;
y.normalize();
// Z vector is UP
z = up;
// X vector = Y cross Z
x.cross(y,z);
x.normalize();
// Recompute Z vector = X cross Y to make it perpendicular to the others
z.cross(x,y);
z.normalize();
// create final matrix
// first set translation
mat.makeTrans(eye[PF_X],eye[PF_Y],eye[PF_Z]);
// then set normalized axis rotation row vectors
mat.setRow(0,x);
mat.setRow(1,y);
mat.setRow(2,z);
}
For the Performer team:
How about adding a similar pfMatrix function in a future Performer release?
Something like pfMatrix::makeLookAt would be nice.
--
___/ | ___/ Nicolas Gauvin e-mail: nicolas++at++cae.ca
/ / | / Software Developper voice: (514) 341-2000
x2275
/ / | __/ CAE Electronics Ltd. fax: (514) 340-5496
/ ___ | / 8585 Cote De Liesse, P.O. Box 1800
_____/ _/ _| _____/ Saint-Laurent, Quebec, Canada, H4L-4X4
---- End Quote ---
Regards, Simon
_______________________________________________________________________
Simon Mills
Silicon Worlds S.A.
c/o Modelling & Simulation Section (TOS-EMM) Tel: +31 (0)71 565 3725
European Space Agency (ESA/ESTEC) Fax: +31 (0)71 565 5420
Postbus 299, 2200AG Noordwijk e-mail: Simon.Mills++at++esa.int
The Netherlands http://www.estec.esa.nl/wmwww/EMM
_______________________________________________________________________
"Dennen, Kevin M Mr. ERC"
<Kevin.Dennen++at++rttc.army.mil> To: "'info-performer++at++sgi.com'" <info-performer++at++sgi.com>
Sent by: cc:
owner-info-performer++at++holodeck.e Subject: [info-performer] Performer equivalent to OpenGl lookat function
ngr.sgi.com
31/07/03 20:10
Guys,
Is there an equivalent Performer call for the GL lookat function? I'm
wanting to define a viewing transformation based on x,y,z points rather than
angles.
KD
---------------------------------------------
Kevin Dennen
Senior Staff Engineer
ERC, Inc.
(256) 842-2030
kdennen++at++rttc.redstone.army.mil
"Do not worry about your difficulties in Mathematics. I can assure you mine
are still greater." - Albert Einstein
---------------------------------------------
-----------------------------------------------------------------------
List Archives, Info, FAQ: http://www.sgi.com/software/performer/
Open Development Project: http://oss.sgi.com/projects/performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
-----------------------------------------------------------------------
SIGGRAPH 2003 Friends of Performer Meeting:
Wednesday July 30 6:00pm San Diego Hilton Hotel Santa Rosa Room
-----------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Fri Aug 01 2003 - 08:42:51 PDT