Author Topic: alignment of an object3D  (Read 19587 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« on: March 20, 2006, 10:39:34 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #1 on: March 20, 2006, 11:26:48 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #2 on: March 21, 2006, 06:00:12 pm »
ok, but what about the camera? the camera has not a get or set RotationMatrix method.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #3 on: March 21, 2006, 06:04:58 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #4 on: May 15, 2006, 05:04:59 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #5 on: May 15, 2006, 08:00:32 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #6 on: June 07, 2006, 08:01:20 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #7 on: June 07, 2006, 08:12:07 am »
Align the camera with an object:
Code: [Select]
camera.setBack(obj.getWorldTransformation().invert3x3());

Align the camera with an  arbitrary axis:
Code: [Select]
camera.setBack(axis.getRotationMatrix().invert3x3());

Hope this helps.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #8 on: June 08, 2006, 08:11:02 am »
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

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #9 on: June 08, 2006, 08:13:20 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #10 on: June 08, 2006, 05:12:40 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #11 on: June 08, 2006, 09:02:12 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #12 on: June 09, 2006, 12:06:34 am »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #13 on: June 09, 2006, 12:45:40 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #14 on: June 09, 2006, 05:57:27 pm »
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.