Hi,
have created some shared meshs and put them into a node. SharedNodes are created from the original node and added to the scene.
The shared mesh's lose their local translation. Is this intentional ?? or should you be able to add a sharedmesh to a sharednode
Quick example as follows
package jmetest.renderer;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.SharedMesh;
import com.jme.scene.SharedNode;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Dome;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
/**
* <code>TestDome</code>
*
* @author Peter Andersson
* @version $Id:
*/
public class TestDome extends SimpleGame {
private Dome dome;
private Quaternion rotQuat = new Quaternion();
private float angle = 0;
private Vector3f axis = new Vector3f(0, 1, 0);
public static void main(String[] args) {
TestDome app = new TestDome();
app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
/**
* Rotates the dome
*/
protected void simpleUpdate() {
if (tpf < 1) {
angle = angle + (tpf * 1);
if (angle > 360) {
angle = 0;
}
}
rotQuat.fromAngleAxis(angle, axis);
dome.setLocalRotation(rotQuat);
}
/*
* (non-Javadoc)
*
* @see com.jme.app.SimpleGame#initGame()
*/
protected void simpleInitGame() {
Node mainNode = new Node("main");
dome = new Dome("My Dome", null, 20, 20, 20);
dome.setModelBound(new BoundingBox());
dome.updateModelBound();
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.loadTexture(
TestBoxColor.class.getClassLoader().getResource(
"jmetest/data/images/Monkey.jpg"),
Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR));
Box rod = new Box("rod", new Vector3f(-10,20,0),new Vector3f(10,21,1));
dome.setRenderState(ts);
SharedMesh s1 = new SharedMesh("s1",rod);
s1.setLocalTranslation(new Vector3f(-10,0,0));
SharedMesh s2 = new SharedMesh("s2",rod);
s2.setLocalTranslation(new Vector3f(10,0,0));
mainNode.attachChild(dome);
mainNode.attachChild(s1);
mainNode.attachChild(s2);
SharedNode n1 = new SharedNode("sn1", mainNode);
SharedNode n2 = new SharedNode("sn1", mainNode);
Quaternion q = n2.getLocalRotation();
q.fromAngles(new float[]{FastMath.DEG_TO_RAD*180,0.0f,0.0f});
rootNode.attachChild(mainNode);
rootNode.attachChild(n2);
}
}