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

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #15 on: June 11, 2006, 04:42:43 am »
The problem with that is the rotation is not the expected one. The movements are done on the object, and then the camera is aligned to the object. For example if I rotateY 90 degres and after try to rotateZ it wont because it will rotate on another axis (X on this situation). I mean it seems that the set of Axis of the rotation matrix are facing absolute directions. I mean, the X axis always will be the same X axis even if the object3D have rotated and should have another relative set of axis. I would like to provide you a test case but I am afraid that it have still many bugs to fix before being runnable 100% times, oftenly got some exceptions when adding more than one craft at a time.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #16 on: June 12, 2006, 05:56:52 pm »
Quote from: "Melssj5"
I mean it seems that the set of Axis of the rotation matrix are facing absolute directions. I mean, the X axis always will be the same X axis even if the object3D have rotated...
Yes, that's exactly the way it's supposed to be. If you don't want that, you can always use the rotateAxis()-method with the axis' returned by get?Axis() from Object3D. That will give you the rotation around the relative ?-axis and there is no difference between that angles you have to apply to those axis' compared to the ones applied to the absolute axis'.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #17 on: June 13, 2006, 07:27:14 am »
Yeah, I guess it may work, the problem was that I must modify the client - server. I didnt wanted to translate the angles that the object moved and didnt wanted to keep them on a client manipulable place for avoiding cheats. in anyway I guess I must translate a 3 float spaces array with the x, y, and z rotated angle and the 3 relative axis to make the server to rotate the camera over the 3 axis, but. I am afarid that it will increase the bandwidth usage. and the server processing charge that I noticed is high when doing tests.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #18 on: June 13, 2006, 08:13:49 am »
Transfering the rotation matrix should be sufficient, as already contains the rotations and the implicit axis'. I'm not really sure, what your client is sending to the server and vice versa, but keep in mind that transfering the angles only (yaw, pitch, roll) to specify an object's orientation in space isn't sufficient, because is has no "history" of the order of the rotations, which a rotation matrix has.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #19 on: June 15, 2006, 05:41:26 am »
Hi, I tested the code you gave me, but it didnt run. I have a not serializable exception.

Here is the stack trace:

Code: [Select]




java.io.NotSerializableException: com.threed.jpct.GLRenderer
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
        at java.util.Hashtable.writeObject(Hashtable.java:812)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
        at Flier_Match.FMCliente.TCPManejo.enviar(TCPManejo.java:50)
        at Flier_Match.FMCliente.RenderThread.eventosMenu(RenderThread.java:365)
        at Flier_Match.FMCliente.RenderThread.hacerMovimientos(RenderThread.java:203)
        at Flier_Match.FMCliente.RenderThread.ejecutarComandos(RenderThread.java:197)
        at Flier_Match.FMCliente.RenderThread.run(RenderThread.java:167)

Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #20 on: June 15, 2006, 05:51:33 am »
In fact the jpct v11 wprks fine, but Its an older, for example the changes you made for my model 3d program, didnt worked with Flier Match, and neither did the one you send me by mail
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #21 on: June 15, 2006, 08:55:19 am »
Damn...i'm pretty sure that i had found the problem...i'll have a look later. What about the alignment problem? Does it work the way you wanted it now?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #22 on: June 16, 2006, 03:53:55 am »
Well, about the alignment I must say: YES and NO. Actually the camera is aligned mostly like I expected, but the camera is watching to the rear part of the craft, I mean is looking to the oposite direction, I tried to fix it rotating it 90 degrees at the beginning of the program, but it didnt work, also tried to move the object3D but nothing, is like is being alignes to the original position in anyway. I guess that is not a huge problem and will be able to fix it by myself. Thanks a lot.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #23 on: June 16, 2006, 08:03:03 am »
Quote from: "Melssj5"
but the camera is watching to the rear part of the craft, I mean is looking to the oposite direction,
Sure? Maybe it looks like that to you, because i switched the meaning of A and Z!? If not, then why not just rotate the craft's mesh at initialization by 180 degrees around Y?

Code: [Select]
obj.rotateY((float) Math.PI);
obj.rotateMesh();
obj.setRotationMatrix(new Matrix());

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #24 on: June 16, 2006, 02:30:38 pm »
I actually did obj.rotateY (Math.PI) but nothing seems to happen, I have a clue on why this is happenig but will fix it tomorrow at night.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #25 on: June 16, 2006, 03:13:41 pm »
Quote from: "Melssj5"
I actually did obj.rotateY (Math.PI) but nothing seems to happen, I have a clue on why this is happenig but will fix it tomorrow at night.
That's because it doesn't change the relative relation between the craft and the camera, i.e. the viewer. The camera aligns itself on the positive z-axis of the craft. If this is pointing to the rear, rotating the craft doesn't help, because it also rotates the z-axis with it. You have to rotate the craft relative to the axis, which is what the code should do. But i'm having problems to understand how you came to this conclusion!? I mean, there is no craft visible at all, is it? So how do you determine that you are looking to the rear?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #26 on: June 17, 2006, 04:19:58 am »
Of course there is a problem, because I am making a multiplayer game, and what happens with the aligned camera also happens with other players crafts (every client have a list of them) and cameras (own of each player) So, it seems to be ok but when is a craft in front you dont see it, only when is behind.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #27 on: June 17, 2006, 08:48:42 am »
Quote from: EgonOlsen
Quote from: "Melssj5"


Code: [Select]
obj.rotateY((float) Math.PI);
obj.rotateMesh();
obj.setRotationMatrix(new Matrix());


Well, nothing happens? I guess its a magical Issue or something. I out the code when the game is begging but nothing!!!!, what can I do?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
alignment of an object3D
« Reply #28 on: June 17, 2006, 11:25:22 am »
The code should rotate the mesh of the craft...if there is one, but there isn't, hence my question. That's what i currently don't understand about this problem. There is no visible sign of looking to the rear or to the front. I really don't understand how "rear" is defined in your game. I mean it's all a question of definition. I may load a level upside down and define down as up and vice versa. Fact is: In jPCT, front means "along the positive z-Axis" and that's what you get ATM. If you have a model that's different, rotate it's mesh (that's what this code is supposed to do). Everything else is just a question of the coordinate system you are acutally thinking in.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
alignment of an object3D
« Reply #29 on: June 18, 2006, 01:18:12 am »
Well, if you run just one client. it has no sense of rotating the mesh because is removed in anyway, but when they are 2 clients,(2 crafts on the World) and they are front to front, then you cant see none of them. but if they are back to back you see both. The camera is directed to the oposite Z craft axis.

About the definitions, well, front is the front of the craft (where the camera should be watching) and the rear is the rear of the craft (where the turbines are). So, the camera is watching from the center of the craft to the the rear part, thats the oposite Z axis.

Every client chose a craft from a list and when beggining the game the selected craft is sent to the sever to add it to a list of all the current players, this list os passed to all the clients on each iteration, so each client can see others crafts (this crafts are not being rotated but the code you game me is like not having written the code for rotating it)
Nada por ahora