alignment of an object3D

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

Previous topic - Next topic

Melssj5

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

EgonOlsen

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'.

Melssj5

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

EgonOlsen

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.

Melssj5

Hi, I tested the code you gave me, but it didnt run. I have a not serializable exception.

Here is the stack trace:





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

Melssj5

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

EgonOlsen

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?

Melssj5

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

EgonOlsen

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?

obj.rotateY((float) Math.PI);
obj.rotateMesh();
obj.setRotationMatrix(new Matrix());

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.
Nada por ahora

EgonOlsen

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?

Melssj5

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

Melssj5

Quote from: EgonOlsen
Quote from: "Melssj5"

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

EgonOlsen

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.

Melssj5

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