Re: [osg-users] changing the up direction of the SphericalManiuplator

2010-10-21 Thread J.P. Delport

Hi,

On 20/10/10 21:55, Cory Riddell wrote:

  Tim

Thanks for the reassurance and the explanation. My code is working well
now and I'm very happy with it. I hardly had to change anything, so that
makes me think I got it right.

I do kind of wish I could always have my orbits be around the center of
my scene rather than the center of the view. I typically only have one
blob of stuff in my entire scene and it would be nice to make it look
like my blob of stuff is being rotated rather than I'm orbiting the
camera around some arbitrary center point (which starts at the center of
my blob but can be moved by a pan).


Just force the _center value to be what you want and disallow 
modification of it.


jp



Cory


On 10/20/2010 2:24 AM, Tim Moore wrote:

On Mon, Oct 18, 2010 at 10:23 PM, Cory Riddell c...@codeware.com
mailto:c...@codeware.com wrote:

I've been plowing through this and I can almost get what I need, I
just don't entirely understand a couple of things.

Is it safe to think of the view matrix as the camera position and
orientation? By doing so, I think I understand
SphericalManipulator::getMatrix() method. It returns:

As was mentioned recently, the view matrix is actually the inverse of
camera position and orientation in the world. You can also think of it
as the position and orientation of the world in eye space. The
matrix returned by the manipulator classes is the camera pose; the
matrix returned by getInverseMatrix() is the view matrix.

return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
osg::Matrixd::translate(m_center);

This manipulator has two parameters - heading and elevation.
Heading is the angle from the x-axis in the x-y plane and
elevation is the angle from the x-y plane (pi/2 would give you the
z-axis).

If I want the x-axis to be up rather than the z-axis, I add an
additional rotation:

return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0)* // NEW!
osg::Matrixd::translate(m_center);

Am I tinkering with the right stuff here? (I've also made the
appropriate change to my getInverseMatrix() method.)

Yes, that looks fine.
Tim


It's feeling ok, but I do need to make more changes to the
manipulators code that handles pans.

Cory


On 10/15/2010 5:03 PM, Cory Riddell wrote:

I have been using the SphericalManipulator and it works really
well for my application.

One thing I would like to do is change which direction is up. The
default is Z == up. Sometimes I want X to be up. If I understand
the code, I need to make fairly extensive modifications to the
existing manipulator. Before I start down that road, I just
wanted to ask if that sounds right. I'm hoping I'm not missing
some place where I obviously just need to apply some
transformation matrix.

I actually want my entire scene to go sideways, not just orbit up
and down on my screen rather than right and left. For example, if
I were modeling a pencil (coaxial the z axis), I sometimes want
it standing on end, and sometimes lying on its side on my screen.

I think I'm asking a question that has been asked before:
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html

Cory



___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto:osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto:osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


___
osg-users mailing list
osg-users@lists.openscenegraph.org

Re: [osg-users] changing the up direction of the SphericalManiuplator

2010-10-21 Thread Tom Pearce
I haven't tried it, but wouldn't changing the order of multiplication in the 
get(Inverse)Matrix methods do the trick:

return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
osg::Matrixd::translate(m_center)*
osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0);//  NEW!

You essentially want the m_center point to rotate around the object in 
addition to the camera-offset vector (m_distance) rotating - that way you can 
still pan, but the object would stay at the same location on the screen when 
you're rotating.  So apply both translations before/after the rotations, 
instead of splitting them up.

Again, haven't tested this, just throwing the idea out.

Cheers,
Tom

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32938#32938





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] changing the up direction of the SphericalManiuplator

2010-10-20 Thread Tim Moore
On Mon, Oct 18, 2010 at 10:23 PM, Cory Riddell c...@codeware.com wrote:

  I've been plowing through this and I can almost get what I need, I just
 don't entirely understand a couple of things.

 Is it safe to think of the view matrix as the camera position and
 orientation? By doing so, I think I understand
 SphericalManipulator::getMatrix() method. It returns:

 As was mentioned recently, the view matrix is actually the inverse of
camera position and orientation in the world. You can also think of it as
the position and orientation of the world in eye space. The matrix
returned by the manipulator classes is the camera pose; the matrix returned
by getInverseMatrix() is the view matrix.


 return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
 osg::Matrixd::translate(m_center);

 This manipulator has two parameters - heading and elevation. Heading is the
 angle from the x-axis in the x-y plane and elevation is the angle from the
 x-y plane (pi/2 would give you the z-axis).

 If I want the x-axis to be up rather than the z-axis, I add an additional
 rotation:

 return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
 osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0)*//  NEW!
 osg::Matrixd::translate(m_center);

 Am I tinkering with the right stuff here? (I've also made the appropriate
 change to my getInverseMatrix() method.)

Yes, that looks fine.
Tim


 It's feeling ok, but I do need to make more changes to the manipulators
 code that handles pans.

 Cory


 On 10/15/2010 5:03 PM, Cory Riddell wrote:

 I have been using the SphericalManipulator and it works really well for my
 application.

 One thing I would like to do is change which direction is up. The default
 is Z == up. Sometimes I want X to be up. If I understand the code, I need to
 make fairly extensive modifications to the existing manipulator. Before I
 start down that road, I just wanted to ask if that sounds right. I'm hoping
 I'm not missing some place where I obviously just need to apply some
 transformation matrix.

 I actually want my entire scene to go sideways, not just orbit up and down
 on my screen rather than right and left. For example, if I were modeling a
 pencil (coaxial the z axis), I sometimes want it standing on end, and
 sometimes lying on its side on my screen.

 I think I'm asking a question that has been asked before:

 http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.htmlhttp://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html

 Cory



 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] changing the up direction of the SphericalManiuplator

2010-10-20 Thread Cory Riddell


  
  
Tim

Thanks for the reassurance and the explanation. My code is working
well now and I'm very happy with it. I hardly had to change
anything, so that makes me think I got it right.

I do kind of wish I could always have my orbits be around the center
of my scene rather than the center of the view. I typically only
have one blob of stuff in my entire scene and it would be nice to
make it look like my blob of stuff is being rotated rather than I'm
orbiting the camera around some arbitrary center point (which starts
at the center of my blob but can be moved by a pan).

Cory


On 10/20/2010 2:24 AM, Tim Moore wrote:
On Mon, Oct 18, 2010 at 10:23 PM, Cory Riddell c...@codeware.com
  wrote:
  

   I've been plowing
through this and I can almost get what I need, I just don't
entirely understand a couple of things.

Is it safe to think of the view matrix as the camera
position and orientation? By doing so, I think I understand
SphericalManipulator::getMatrix() method. It returns:

  

As was mentioned recently, the view matrix is actually the
  inverse of camera position and orientation in the world. You
  can also think of it as the position and orientation of the
  world in eye space. The "matrix" returned by the manipulator
  classes is the camera pose; the matrix returned by
  getInverseMatrix() is the view matrix.


return
osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0,
0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0,
1.0)*
 osg::Matrixd::translate(m_center);

This manipulator has two parameters - heading and elevation.
Heading is the angle from the x-axis in the x-y plane and
elevation is the angle from the x-y plane (pi/2 would give
you the z-axis). 

If I want the x-axis to be up rather than the z-axis, I add
an additional rotation:

 return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0,
m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0,
0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0,
1.0)*
  osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0)*
// NEW!
 osg::Matrixd::translate(m_center);

Am I tinkering with the right stuff here? (I've also made
the appropriate change to my getInverseMatrix() method.)
  

Yes, that looks fine.
Tim

   
It's feeling ok, but I do need to make more changes to the
manipulators code that handles pans.

Cory

  

On 10/15/2010 5:03 PM, Cory Riddell wrote: 


  
 I have been using the
  SphericalManipulator and it works really well for my
  application.
  
  One thing I would like to do is change which direction
  is up. The default is Z == up. Sometimes I want X to
  be up. If I understand the code, I need to make fairly
  extensive modifications to the existing manipulator.
  Before I start down that road, I just wanted to ask if
  that sounds right. I'm hoping I'm not missing some
  place where I obviously just need to apply some
  transformation matrix.
  
  I actually want my entire scene to go sideways, not
  just orbit up and down on my screen rather than right
  and left. For example, if I were modeling a pencil
  (coaxial the z axis), I sometimes want it standing on
  end, and sometimes lying on its side on my screen.
  
  I think I'm asking a question that has been asked
  before:
  
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html
  
  Cory
  
  

  
  
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


  
  
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
  

Re: [osg-users] changing the up direction of the SphericalManiuplator

2010-10-18 Thread Cory Riddell


  
  
I've been plowing through this and I can almost get what I need, I
just don't entirely understand a couple of things.

Is it safe to think of the view matrix as the camera position and
orientation? By doing so, I think I understand
SphericalManipulator::getMatrix() method. It returns:

 return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0,
m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
 osg::Matrixd::translate(m_center);

This manipulator has two parameters - heading and elevation. Heading
is the angle from the x-axis in the x-y plane and elevation is the
angle from the x-y plane (pi/2 would give you the z-axis). 

If I want the x-axis to be up rather than the z-axis, I add an
additional rotation:

 return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0,
m_distance))*
 osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
 osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
  osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0)* // NEW!
 osg::Matrixd::translate(m_center);

Am I tinkering with the right stuff here? (I've also made the
appropriate change to my getInverseMatrix() method.)

It's feeling ok, but I do need to make more changes to the
manipulators code that handles pans.

Cory

On 10/15/2010 5:03 PM, Cory Riddell wrote:

  
  I have been using the SphericalManipulator and it works really
  well for my application.
  
  One thing I would like to do is change which direction is up. The
  default is Z == up. Sometimes I want X to be up. If I understand
  the code, I need to make fairly extensive modifications to the
  existing manipulator. Before I start down that road, I just wanted
  to ask if that sounds right. I'm hoping I'm not missing some place
  where I obviously just need to apply some transformation matrix.
  
  I actually want my entire scene to go sideways, not just orbit up
  and down on my screen rather than right and left. For example, if
  I were modeling a pencil (coaxial the z axis), I sometimes want it
  standing on end, and sometimes lying on its side on my screen.
  
  I think I'm asking a question that has been asked before:
  
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html
  
  Cory
  
  
  

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


  

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org