Hi Robert,

I know, i'm using transposed matrix, if it could have been this...
I've made several tests, that issued to two behavior of the trackball.
I hope that will help you to help me... :-)

First test using the following code :

_viewer = *new* MySimpleViewer;

........

_viewer->setSceneData(_root);
_viewer->setCameraManipulator(*new* osgGA::TrackballManipulator);

...........

static int firstFrame=0;

*if* (!firstFrame){
_viewer->init();


firstFrame++;}


_viewer->frameAdvance();
_viewer->frameEventTraversal();
_viewer->getSceneView()-> setProjectionMatrixAsOrtho (-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); // the projection matrix

_viewer->frameUpdateTraversal();

_viewer->frameCullTraversal();
_viewer->frameDrawTraversal();

With this code the loaded model react to the trackball properly : when I rotate it, it rotates around himself.


Second test using the same code with, in addition, a setting of the modelview matrix to the identity :

viewer = *new* MySimpleViewer;

........

_viewer->setSceneData(_root);
_viewer->setCameraManipulator(*new* osgGA::TrackballManipulator);

...........

static int firstFrame=0;

*if* (!firstFrame){
_viewer->init();
_viewer->getCameraManipulator()->setByMatrix(osg::Matrixd::identity() ); // the modelview matrix


firstFrame++;}


_viewer->frameAdvance();
_viewer->frameEventTraversal();
_viewer->getSceneView()-> setProjectionMatrixAsOrtho (-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); // the projection matrix

_viewer->frameUpdateTraversal();

_viewer->frameCullTraversal();
_viewer->frameDrawTraversal();

With this code the loaded model do not react properly to the trackball : when I rotate it, it rotate around a "virtual sphere (the trackball ?)" and not around himself as expected (and as it rotated without the setting of the modelview matrix with the first piece of code). Why ? I set a modelview matrix to the identity... Does the setting of the modelview matrix as I set it in my code affect the behavior of the trackball?

This could help me to understand how works exactly the trackball manipulator and may help me to resolve my problem.

Thank you.

Fred.




Robert Osfield wrote:
Hi Fredric,

Could it be that the OSG's being row major rather than column major is
the problem?  Try transposing your matrix values before passing to the
OSG.  OpenGL docs and spec are set out in column major, although the
memory is laid in row major...

Robert.

On 12/12/06, Frédéric SPEISSER <[EMAIL PROTECTED]> wrote:
Robert Osfield wrote:
> Hi Federic,
>
> On 12/12/06, Frédéric SPEISSER <[EMAIL PROTECTED]> wrote:
>> Hi Robert,
>> First of all, thank for your response.
>>
>>
>> I use a matrix described as : m11 m12 m13 m14  which is a perspective
>> matrix, it's true,
>>                                                 m21 m22 m23 m24
>>                                                 m31 m32 m33 m34
>> 0 0 0 1
>> but it is not described with the openGL usual variables (left ,right,
>> bottom, top, near, far).
>> Indeed, does manipulator (especially trackball) behave properly when the >> projection matrix is set through a matrix directly (like above , and not
>> set through
>>
>> "setProjectionMatrixAsOrtho" or "setProjectionMatrixAsFrustum" ?
>>
>> And when I set the projection like this, is it normal that in rotation >> manipulation the object does not rotate properly (the camera around the >> object actually since we're using a camera manipulator) ? Am I making
>> an incorrect use of the TrackBall ?
>
> OK I'm still lost.  The OSG will support you setting your own
> projection matrix without the nedd to use setProjectionMatrixAsOthro
> or setProjectionMatrixAsFrustum.  However, the projection matrix
> should just contain the projection, it shouldn't contain parts of the
> view matrix, i.e. rotation etc.  Is that you are accumulating a bit of
> what should be a view matrix into the projection matrix?
>
> Robert.
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
Ok, excuse me if I'm not very clear.
I'm not accumulating (I hope not, I will make further tests) view and
projection matrix in one matrix since I'm breaking up the "projection"
matrix I use into two matrix :
One, in correspondence to the intrinsic parameters of the camera : a
projection matrix described as follow :
u  0  u0  0
0  v  v0  0
0  0  1   0
0  0  0   1

that I set through
_viewer->getSceneView()->setProjectionMatrix(intrinsicMat);  _viewer is
an instance of osgViewer::SimpleViewer.

The other, in correspondence to the extrinsic parameters of the camera :
a modelview matrix described as follow :
r11  r12  r13  tx
r21  r22  r23  ty
r31  r32  r33  tz
0     0      0      1

that I set through
_viewer->getCameraManipulator()->setByMatrix(extrinsicMat);  _viewer is
an instance of osgViewer::SimpleViewer.

I keep testing...
Thank you,
Fred.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to