Hello, I’m hoping that somebody here may be able to shed some light on a problem with loading an exported model from the JME SDK.
With a single model, everything looks correct:
However when there’s more then one of the same same j3o and j3m only one is displayed correctly and that changes when the camera moves
Here’s the code, I don’t know if there’s something I’ve missed out, or inadvertently shared some data between the objects?
[java]
public class LoadWallTestOnlyModel extends SimpleApplication
{
private enum ResourceLocation
{
Model( “/assets/Models/WallPlaceholder/wall.j3o” ),
Material( “/assets/Models/WallPlaceholder/wall.j3m” );
/**
* The location of the Mesh file inside the deployment JAR file (not null).
*/
private final String url;
ResourceLocation( final String relativeFile )
{
// Make sure the file can be found - otherwise are problems!
if (getClass().getResource( relativeFile ) == null)
{
throw new IllegalArgumentException( "File at the location was null - not allowed!" + relativeFile );
}
this.url = relativeFile;
}
}
/**
* Rotation of one degree around the yAxis.
*/
final static Quaternion ONE_DEGREE_ROTATION = new Quaternion().fromAngleAxis( FastMath.DEG_TO_RAD, Vector3f.UNIT_Y );
public static void main( String[] args )
{
LoadWallTestOnlyModel app = new LoadWallTestOnlyModel();
app.start();
}
@Override
public void simpleInitApp()
{
// Lighting
DirectionalLight dl = new DirectionalLight();
dl.setDirection( new Vector3f( 1f, -0.6f, 0f ).normalizeLocal() );
dl.setColor( new ColorRGBA( 0.9f, 0.9f, 0.9f, 1.0f ) );
rootNode.addLight( dl );
// This update is needed to avoid assert problems due to lighting update
rootNode.updateGeometricState();
// create the geometry and attach it
final Node first = load( 0f );
rootNode.attachChild( first );
final Node second = load( -4f );
rootNode.attachChild( second );
final Node third = load( 4f );
rootNode.attachChild( third );
flyCam.setMoveSpeed( 10f );
cam.setLocation( new Vector3f( -10, 2, 0f ) );
cam.lookAt( Vector3f.ZERO, Vector3f.UNIT_Y );
}
private Node load( final float z )
{
Spatial loadedModel = getAssetManager().loadModel( ResourceLocation.Model.url );
assert loadedModel instanceof Node : "Expecting a Node object from modelFile: " + ResourceLocation.Model.url;
final Node model = (Node) loadedModel;
// Load the Material
final MaterialKey key = new MaterialKey( ResourceLocation.Material.url );
final Material material = getAssetManager().loadAsset( key );
loadedModel.setMaterial( material );
model.move( 0f, 0f, z );
return model;
}
}
[/java]
Any pointers about how to get all the copies rendering correctly would be appreciated