Hello,
I have got a wrapper class which encapsules a JME instance. For example MySpatial wraps a JME Spatial. If I perform picking, I only get JME geometry data back, no reference from the JME geometry to my wrapper class. The solution of course is to add a reference of my wrapper class to a JME Spatial (Spatial, SceneNode, Geometry everything that extends it). My first approach was to write a PickControl which I added to the controllers. This worked very fine of course, but controlers should be controlers and not containers for references. Then I recognized the setUserData method and thought “wow”, I can put everything there. The guys from JME are really clever After I put my reference to userData and started my program I realized, that a
java.lang.IllegalArgumentException: Unsupported type:
has been thrown. Opening source code → look for setUserData and suddenly my changed to :(. Only primitves are allowed. Is there a better solution than adding a “dirty” PickControl to hold reference to my wrapper class?
Thanks.
Regards,
Equi
Hi, you can put anything to userdata as long as implements Saveable:
Code:
/**
*
Savable
is an interface for objects that can be serialized
* using jME's serialization system.
* @author Dany
*/
public interface Savable {
void write(JmeExporter ex) throws IOException;
void read(JmeImporter im) throws IOException;
}
2 Likes
Thanks. I didn’t see this.