Author Topic: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet  (Read 9608 times)

Offline SelimAbidin

  • byte
  • *
  • Posts: 2
    • View Profile
Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
« on: December 29, 2015, 11:15:51 am »
Hello

I have been developing an application and had a bug or normal behavior?


Scenario :

I use object pooling pattern in my application, so there are around 10 prepared Object3D instance in my ArrayList.

According to data i have from server, I remove all objects from world and add some objects from my ArrayList to world.  Everything works fine but time to time, i have this error.


E/AndroidRuntime: FATAL EXCEPTION: GLThread 122452
                                                                   Process: anka.ysa.com.test, PID: 28259
                                                                   java.lang.NullPointerException: Attempt to read from field 'boolean com.threed.jpct.Object3D.oneTextureSet' on a null object reference
                                                                       at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2355)
                                                                       at com.threed.jpct.World.draw(World.java:1419)
                                                                       at com.threed.jpct.World.draw(World.java:1102)
                                                                       at anka.ysa.com.test.TestRenderer.onDrawFrame(TestRenderer.java:48)
                                                                       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1561)
                                                                       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)


Sample Code :
Code: [Select]
ArrayList<Object3D> objects = new ArrayList<>();
    Object3D modelObject = null;
    public void addAndRemoveObjects()
    {
        while (objects.size() > 0)
        {
            scene.removeObject(objects.remove(0));
        }

        if (modelObject == null)modelObject = Primitives.getCube(10);

        for (int i = 0; i < 5; i++)
        {
           Object3D obj = new Object3D(modelObject);
           obj.translate(0,0,50);
           scene.addObject(obj);
           objects.add(obj);
        }
    }


Sample Application can be found at https://github.com/SelimAbidin/JPCTBugTest

Thanks for everything
Y.Selim Abidin





Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
« Reply #1 on: December 29, 2015, 01:34:12 pm »

Offline SelimAbidin

  • byte
  • *
  • Posts: 2
    • View Profile
Re: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
« Reply #2 on: December 30, 2015, 01:31:32 pm »
Thanks for the answer and it reminded me RTFM  :-X