Troubles setting a JMECanvas

Hello there!



I’m trying to embed a JMECanvas into a JPanel, but I’m getting some problems. Basically, I have a SimpleCanvasImpl class that executes the next code when setting up. The result is a Box shown in the canvas. The problem is when attaching models (3ds) to the SimpleCanvasImpl, which textures are not shown. Moreover, it takes the texture of the box (I guess I’m not getting a nice combination of lightstates and textures)



@Override

public void simpleSetup() {



// Normal Scene setup stuff…



Quaternion rotQuat = new Quaternion();

Vector3f axis = new Vector3f(1, 1, 0.5f);

axis.normalizeLocal();



Vector3f max = new Vector3f(5, 5, 5);

Vector3f min = new Vector3f(-5, -5, -5);



Box box = new Box(“Box”, min, max);

box.setModelBound(new BoundingBox());

box.updateModelBound();

box.setLocalTranslation(new Vector3f(0, 0, -10));

box.setRenderQueueMode(Renderer.QUEUE_SKIP);

rootNode.attachChild(box);



box.setRandomColors();



TextureState ts = renderer.createTextureState();



ts.setEnabled(true);

ts.setTexture(TextureManager.loadTexture(

JMESwingTest.class.getClassLoader().getResource(

“jmetest/data/images/Monkey.jpg”), Texture.MM_LINEAR,

Texture.FM_LINEAR));



box.setRenderState(ts);



// ---- LIGHTS

/** Set up a basic, default light. */

// light = new PointLight( );

DirectionalLight light = new DirectionalLight();

SpotLight light2 = new SpotLight();



light2.setAmbient( new ColorRGBA( 1.0f, 0.0f, 0.0f, 1.0f ) );

light2.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );

light2.setAttenuate(true);

light2.setSpecular(new ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f));

light2.setAngle(30);

light2.setLocation(new Vector3f(100, 100, 100));

light2.setEnabled(true);



light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f));

light.setShadowCaster(true);



light.setDirection(new Vector3f(0, 0, -1).normalize());

light.setEnabled(true);



DirectionalLight light3 = new DirectionalLight();

light3.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f));

light3.setDirection(new Vector3f(1, 0, 1).normalize());

light3.setEnabled(true);

LightState lightState = renderer.createLightState();

lightState.setEnabled(true);

lightState.setGlobalAmbient(new ColorRGBA(1, 1, 1, 1));

lightState.attach(light2);

lightState.attach(light);

rootNode.setRenderState(lightState);



ControlTDRenderer.init(rootNode);

controller = ControlTDRenderer.getController();

}

Here’s a screenshot. As you can see, the model (a ninja) takes the texture of the box





Any help much appreciated!!!

Most likely you need to add a call to updateRenderStates().

It runs! Thank you very much from <eAdventure3d> development team (jtorrente and me!). You made our lives easier!



:smiley: