Kris Dale wrote:
[quote="omdown"]
Chris 'Xenon' Hanson wrote:
Tony Horrobin wrote:

Hi Kris,
Is the target moving too?
Cheers,

Not at the moment.  Currently I'm only worried about figuring out how to orient 
in the right direction, I'll worry about tracking at a later time.  =)



Chris 'Xenon' Hanson wrote:
Thrall, Bryan wrote:

There's osg::Matrix::makeLookAt()

Wow. if only that were named something intuitive that I would have thought to 
look for.
Or Look At, as the case may be. ;)

Does that answer your question, Kris?

--
Chris 'Xenon' Hanson, omo sanza lettere                  Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen
_______________________________________________
osg-users mailing list

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 ------------------
Post generated by Mail2Forum

Sort of..  that definitely looks like it's going to be what I need, but I can't 
seem to get it implemented properly.  I've tried it this way:


Code:

osg::MatrixTransform* pMatTrans = dynamic_cast<osg::MatrixTransform*>(node);
osg::Matrix m = pMatTrans->getMatrix();
osg::Vec3d   v =  osg::Vec3d( m(3,0) , m(3,1) , m(3,2) ); // save the location 
for the eye point

// if I understand right, the vectors in order are:  eye point, lookat point, 
up vector, right?
m.makeLookAt( v, osg::Vec3d(0.0, 0.0, 0.0), osg::Vec3d(0.0, 0.0, 1.0) );

pMatTrans->setMatrix( m );




When I run the code with this lookat call, the model is translated across the 
XY plane and doesn't remotely look toward 0,0,0...

Prior to lookat the getMatrix call the model's getmatrix result is:

Code:


Stars between numbers for ease of reading...  someone really needs to make up a 
matrix forum manipulator! =P
____________________________________

|       1.65951e-16   *   1     *  0    *  0 |
|       -2.47158e-15    *  -3.85743e-31   *  1  *  0 |
|       1    *   -1.65951e-16   *   -2.81642e-16   *   0 |
|       -6366.2   *   3182.6       *   3193.6    *   1 |
____________________________________





After calling makeLookAt the matrix is:

Code:

____________________________________

|       -0.447157   *   0.366172   *   -0.816069   *   0 |
|       -0.894455   *   -0.183057   *   0.40797   *   0 |
|       0   *   0.912364   *   0.40938   *   0 |
|       -1.26565e-13   *   3.71925e-13   *   -7801.06   *   1 |
____________________________________





I assume I'm simply calling something wrong somewhere...  can someone point me 
in the right direction?[/code]




Okay an update on this, I've tried it with a far more simple example and tried 
working through the equations in the source code by hand...  something isn't 
quite right somewhere and I'm not understanding what, but I come up with the 
same results by hand as I do using the makeLookAt...

I tried just using:
eye ( 0, 0, 100 )
center ( 0, 0, 0 )
up ( 0, -1, 0 )

The resulting matrix I get from this is:

Code:

-1     0        0     0
 0    -1        0     0
 0     0        1     0
0 0 -100 0

I just read the man page for gluLookAt, and I think I get the problem. Hopefully, I can describe the issue adequately :-)

gluLookAt (and, by extension, osg::Matrix::makeLookAt), is designed to create a ModelView matrix with the given parameters. If you know how OpenGL works, you'll understand that a modelview matrix combines the modeling matrix (which places objects in the world) with the view matrix (which places the world with respect to the view).

With this in mind, the resulting matrix makes perfect sense. Think of it this way, instead of moving the viewpoint to (0, 0, 100), you keep the view at the origin and move the world to (0, 0, -100).

Does that help?

To get what you're looking for, you might try inverting the result of makeLookAt (not sure if this is the answer, but it could be).

--"J"

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to