Hi there,
I stumbled on two Problems while coding an Applet based on JPCT:
When I try to reuse a mesh by assigning it to an Object3D a nullPointerException is thrown.
Object3D retVal = new Object3D(0);
retVal.setMesh(((Object3D)usedModels.get(name)).getMesh());
The Error is:
java.lang.NullPointerException
at com.threed.jpct.Object3D.setMesh(Unknown Source)
at org.twofivesixbit.felix.mintec.RessourcePool.getModel(RessourcePool.java:140)
at org.twofivesixbit.felix.mintec.SceneFromXMLBuilder.addModel(SceneFromXMLBuilder.java:81)
at org.twofivesixbit.felix.mintec.SceneFromXMLBuilder.startElement(SceneFromXMLBuilder.java:40)
at qdxml.QDParser.parse(QDParser.java:195)
at org.twofivesixbit.felix.mintec.SceneFromXMLBuilder.buildOnReader(SceneFromXMLBuilder.java:190)
at org.twofivesixbit.felix.mintec.Mintec3DScene.buildFromXML(Mintec3DScene.java:61)
at org.twofivesixbit.felix.mintec.Mintec3DScene.<init>(Mintec3DScene.java:43)
at org.twofivesixbit.felix.mintec.InteractiveMintec3DScene.<init>(InteractiveMintec3DScene.java:12)
at org.twofivesixbit.felix.mintec.Mintec3DEngineApplet.init(Mintec3DEngineApplet.java:21)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)
However as a workaround I currently use this:
Object3D retVal = ((Object3D)usedModels.get(name)).cloneObject();
So I am pretty sure, that the Object from the HashTable "usedModels" is correct. I would rather do it in the former way, because doing it like this I have to reset translation and additional color and do waste time copying those attributes.
The second Issue is a minor one:
It would be nice if there was a way to retrieve the additional color from an Object3D. (I would like to set a "team-color" which shall be replaced by red, when an object is selected and reapplied when another object is selected). Otherwise I would have to code a subclass of Object3D, which seems rather inelegant.
Finally I'd like to thank you for your great work! Programming with jPCT is really comfortable.
Felix