Author Topic: Null pointer exception when rendering  (Read 8941 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« on: March 18, 2006, 12:57:06 pm »
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:

Code: [Select]


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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Null pointer exception when rendering
« Reply #1 on: March 18, 2006, 01:08:39 pm »
Please try this debug-build to see which line causes the problem: http://www.jpct.net/download/beta/jpct_debug.jar

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« Reply #2 on: March 19, 2006, 12:43:15 am »
Code: [Select]



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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Null pointer exception when rendering
« Reply #3 on: March 19, 2006, 01:30:23 pm »
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

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« Reply #4 on: March 19, 2006, 11:20:32 pm »
ok, thanks, I was breaking my mind trying to find the error in my code.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« Reply #5 on: March 20, 2006, 06:09:55 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Null pointer exception when rendering
« Reply #6 on: March 20, 2006, 06:36:25 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« Reply #7 on: March 20, 2006, 06:39:27 pm »
:(  :(  :(

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Null pointer exception when rendering
« Reply #8 on: March 20, 2006, 06:53:18 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Null pointer exception when rendering
« Reply #9 on: March 20, 2006, 06:58:27 pm »
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