alignment of an object3D

Started by Melssj5, March 20, 2006, 10:39:34 PM

Previous topic - Next topic

Melssj5

how to get and set the alignment of an object3D?. Well for my game I decided to transmit the position and direction of some objects3D istead of the entire World, but I have noticed that the object3D class has no methods to do it, I mean, I can get the position easyly and the axis x, y and z, but how can align an object3D to that values if an object3D can be only aligned to a camera.
Nada por ahora

EgonOlsen

Just transfer the rotation matrix of the Object3D on the server (or even simpler: the dump obtained by Matrix.getDump()) and set the client's object rotation matrix to that (Matrix.setDump()). That should do the trick.

Melssj5

ok, but what about the camera? the camera has not a get or set RotationMatrix method.
Nada por ahora

EgonOlsen

It has, the naming is just different, because it's inherited from BufferedMatrix. What is set- and getRotationMatrix() for an Object3D is set- and getBack() for the Camera.

Melssj5

Hi, I still have problems with that.!!!

OK, i got the rotarion Matrix from the Object3D, tranfer it, and use it on the setBack () metho of the camera, but it dont work.

1) When it should to to the right the camera go to left and viceversa. also up-down.

2) it seems that the axis of the matrix are not changing. The methos rotateX () always rotates respect to the same absolute axis not to the object3d relative.

I have been stuck on this for many weeks, but was shy to ask again. what can I do.???
Nada por ahora

EgonOlsen

Invert the matrix before applying it to the camera.
About the axis-thing: Yes, that's the way it's supposed to be. If you need the actual axis of the object, you may get this axis from the object and use the rotateAxis(...)-method instead.

Melssj5

Hi, how can I do it, sorry for asking here a way to do it, but nowadays I have nothing of time for researching this thing. Well, in fact I can obtain the current axis of the object by the getters methods, but how can I align a camera to them. I tried to rotate the camera on x, y and z axis, but the x, y and z axis obtained from the object 3d are relatives and no the proyections over the abosulte axis. How can I do it. Please help.
Nada por ahora

EgonOlsen

Align the camera with an object: camera.setBack(obj.getWorldTransformation().invert3x3());

Align the camera with an  arbitrary axis: camera.setBack(axis.getRotationMatrix().invert3x3());

Hope this helps.

Melssj5

No, it didnt worked, is the same problem that when beginning, it still is rotating respect to the absolute world axis. and not to the relative object3d axis.
Nada por ahora

Melssj5

I guess I should add a camera for each client for the server calcs and tranfer it to each client. But this will increase the bandwidth usage. Any other solution. I want to emulate "descent" gameplay.
Nada por ahora

EgonOlsen

Quote from: "Melssj5"it still is rotating respect to the absolute world axis. and not to the relative object3d axis.
Of course it is, because that's what it's supposed to do, regardless of alignment/orientation. If you want a different behaviour, you have to use the rotateAxis()-methods, but i'm not sure how this is related to your problem, because i obviously don't understand it correctly.

Melssj5

Well, the problem is that I need to move an object3d. The movement is suposed to be similar to the game descent. in which you can go ahead and back. you can rotate on any axis, to go up, down, left, right, or even to the z axis. So.... The craft can be on any direction and rotated on any axis. so I need to align a camera to that craft. I need a behavior similar to he one obtained with the setBack (Matrix) but the problems is that the rotation is done respect with the absolute world axis and not to the realtive craft axis.
Nada por ahora

EgonOlsen

Ok, but you can obtain the craft's axis with one of the get?Axis()-methods in Object3D and rotate either the camera or the craft around that axis.

Melssj5

Yeah, I also tried that but the problem is the angle to rotate on that axis, because I would need to have the actual angle proyection from the camera to that relative axis in order to calc the difference angle. I was thinking on getting the x, y and z axis of the object3D, proyect them into the X, Y, and Z absoulte axis and then do a rotate over the 3 absoulte axis. What do you think?
Nada por ahora

EgonOlsen

After reading this multiple times, i have to admit...i don't get it... :?: The camera is located inside of the object? The object should perform the same rotations as the camera does? Then why doesn't it work to set the object's rotation matrix to the inverted camera one? And why should the angles with which the camera's rotates be different from the ones used on the object? I don't seem to get the actual problem here.