View Rotation Transfom Problem

Hi im a newbie to Xith3D and im having a little trouble getting the view position to rotate properly.
I modified the mouseInteraction demo to change the view transform parameters like so, with rotX and rotY
being the mouse coords.

view.getTransform().lookAt( new Vector3f( rotX, rotY, 3), // location of eye
new Vector3f( 0, 0, 0), // center of view
new Vector3f( 0, 1, 0)); // vector pointing up

It is working but strangley, and im sure my lack of knowlege of graphis bascis has a lot to do with
why i don’t know why. The view rotates fine for a few degrees and then the rotation begins to
slow down exponetially and also push away from cube the more i drag.

If someone could enlighten me as to why, or if im going about rotating the view the wrong way (as there is nothing about it in
either the Xith getting started guide or any of the Java3D Docs)

P.S. any pointers to good arcticles or tutorials would be most appretiated.

thanks

Don’t know what exactly you want to do, but in the example rotX and rotY are rotation values of the cube around the x-axis and the y-axis and not mouse coordinates. Using your code the view will only change, when the left mouse button is released (after dragging the cube).

Sorry i was a little vauge on what i want to do.

Basically i want to simply rotate the view around the cube.

The code i am using is rotating with the mouse, it’s just the distance does not stay constant, it increases the more i rotate away from the starting point and vice versa, even though the distance parameter is set to a constant.

I’ve had the same sort of problem with trying to translate. I don’t think you can do what you want as the lookAt() method will take co-ordinate positions for the view & will have nothing to do with rotations, but saying that I get the same problem you described & I want to rotate as well as translate.

Handy if you could put the view into a transform node & then do the tranlations/rotations on this :), but I suppose this isn’t possible :frowning:

I want be able to move around using a first person perspective (rotate in Y & translate in Z).

Any suggestions as to the general way to accomplish this in xith will be gratefully recieved. :slight_smile: For example what needs to be called in the render loop to move the view to make it dynamic rather than static as it is in the tutorials using lookAt().

Further to above I had a look at an old Java 3D tutorial as I thought it might help as not much on xith is currently about & it seems you can add a view to a transform node & I’ve done so in xith (but I’m still far away from accomplishing my task). Is this the right way to go about navigating in the first person?

Would you need to keep passing the location of the 2 transform nodes holding rotations & translations of the view to lookAt()? But then again lookAt() only holds co.ordinates & not rotations.

Just thinking out loud :-/

You can use something like the following, where t3D is the TransformGroup your character is attached to:


view.getTransform(viewT3D);
t3D.mul(viewT3D);
view.setTransform(t3D);

The initial state of viewT3D describes the distance to your character. You should change the view directly after you have changed the position or orientation of your first person character.

Ok thanks. :slight_smile:

I’ve just looked up mul() in my Java3D docs & this will multiply matrices presumally to get the correct distance as you you say between the figure & your following camera view.

If you just wanted to fly around from the view/camera perspective would you just ignore the first two lines and keep applying the position of your transform groups(which hold the view) in view.setTransform(transformgroupMatrixValue)? No need to use lookAt() to set or update anything?

Is it that easy? ???

Got the basis.

This was very useful - http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1070332396 for anyone attempting the same thing.