Null pointer exception when rendering

Started by Melssj5, March 18, 2006, 12:57:06 PM

Previous topic - Next topic

Melssj5

I got this exception when rendering, is strage, the problem is that I am using several worlds, one for chossing a craft, one for a trailer one for the menu and one for the game.

The switchs of worlds works good except when entering to the game.

The World of the game is received from the networks using an object with an int, a world and a String as fields, from this object I receive the World to render, but I got his:



Exception in thread "Thread-2" java.lang.NullPointerException
       at com.threed.jpct.Object3D.transformVertices(Unknown Source)
       at com.threed.jpct.World.renderScene(Unknown Source)
       at Flier_Match.FMCliente.RenderThread.mostrarImagen(RenderThread.java:391)
       at Flier_Match.FMCliente.RenderThread.run(RenderThread.java:156)


Neither the World nor the FrameBuffer are null, I already tested that, the Object is being transmited well, because I tested the int and the string that came along with the world, I dont know what can it be?

When receiving the world I tested it by getting the objects using getObjectByName ("whatever") and comparing them with null to see if the World was empty, but no. it had all the objects3D byt appears that exception.
Nada por ahora

EgonOlsen


Melssj5




Exception in thread "Thread-2" java.lang.NullPointerException
       at com.threed.jpct.Object3D.transformVertices(Object3D.java:6341)
       at com.threed.jpct.World.renderScene(World.java:1623)
       at Flier_Match.FMCliente.RenderThread.mostrarImagen(RenderThread.java:393)
       at Flier_Match.FMCliente.RenderThread.run(RenderThread.java:156)

Nada por ahora

EgonOlsen

Yes...stupid me. I had commented out the readObject()-method in Vectors which restored some non-serialized objects. Here's a fixed jar: http://www.jpct.net/download/beta/jpct_111pre2.jar

Melssj5

ok, thanks, I was breaking my mind trying to find the error in my code.
Nada por ahora

Melssj5

ok, that works, but I still have problems there.

The World transmited by the network now can be rendered well, but I think that somethings wrong with the inner objects3D. My server moves the inner objects3D and return the whole world, the on cliente machine, the camera is aligned and positioned as the object3d gotten by its name, but it just dont move on the render.

on the server side I put a System.out.println (ownCraft.getTranslation ());

when moving to check.

on the client when doing the same it just dont work, it always appear the same position values. I mean on the transmited world the objects doesnt move.
??????????
Nada por ahora

EgonOlsen

I'm not sure what you mean exactly. I assume you think that moving the object on the server will somehow move it on the client too!? If so, that won't happen. The world on the server and the one on the client are totally independent from each other. You have to transmit the server objects' positions to the client by yourself, it can't happen automagically.

Melssj5

:(  :(  :(

Well, yes, I am moving the objects on the server, and the new world are being transmited each time to the client, on the client machine I do something like this:

Client:

World actual;

//after receiving the world from the Server
actual=Answer.getWorld ();

//I do this for each iteration on the Loop, that means that for each loop the rendered world would be the received from the server.
Nada por ahora

EgonOlsen

You are transmitting the world and all of its objects each cycle??? I don't think that this is a good idea...it's a performance killer like no other. But anyway...
An object's translation is part of the object which is part of the world. If you recieve a new world each cycle, you'll recieve new objects (i.e. copies of the ones on the server) each cycle and these objects should have the translations they have on the server. If they don't, your serialization/deserialization is most likely flawed.
However, I strongly suggest to modify your current approach. Hold one world on the server and one on the client and only transfer updates between them (i.e. positional/orientation information for objects etc). Transfering the whole world (which is virtually "everything" in jPCT) will "kill" you sooner or later.

Melssj5

Yes I was thinking that too, but I may lose some features then, in anyway I cant make this stuff work, the inner objects just dont upgrade, I will better transmit a list of positions and directions.
Nada por ahora