Hello,
I am having an issue where if I build identical objects and give them a rigidbody, then only the first one added is visible. I have built a test case to show.
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
/**
*
-
@author root
*/
public class Test extends SimpleApplication {
public Material deMat;
public BulletAppState phy;
public Test() {
AppSettings as = new AppSettings(false);
as.setUseInput(true);
as.setVSync(true);
as.setTitle(“Phy Test”);
as.setFrameRate(128);
as.setRenderer(AppSettings.LWJGL_OPENGL1);
as.setAudioRenderer(AppSettings.LWJGL_OPENAL);
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode mode = device.getDisplayMode();
as.setBitsPerPixel(mode.getBitDepth());setSettings(as); setShowSettings(false); start();
}
public synchronized Node buildGround0() {
Box b = new Box(2.75f, 0.5f, 2.75f);
Geometry groundC = new Geometry(“ground0”, b);
Material m = deMat.clone();
m.setColor(“Color”, ColorRGBA.Blue);
groundC.setMaterial(m);
Node ground0 = new Node();
ground0.attachChild(groundC);
return ground0;
}@Override
public void simpleInitApp() {
//Build View Port
viewPort.setBackgroundColor(new ColorRGBA(.0f, .0f, 0.4f, 1f));
//Build Lighting
AmbientLight ambient = new AmbientLight();
ambient.setColor(new ColorRGBA(.1f, .1f, .5f, 0.5f));//Light Blue
rootNode.addLight(ambient);
DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);
//Load Master material
deMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
//Build Phy Space
phy = new BulletAppState();
stateManager.attach(phy);
//Build cells
int x = 0;
while (x < 5) {
Node cell = new Node();
Spatial s = buildGround0();
RigidBodyControl rbc = new RigidBodyControl(0.0f);
s.addControl(rbc);
cell.attachChild(s);
rootNode.attachChild(cell);
cell.setLocalTranslation(getCellLocation(x, 0));
phy.getPhysicsSpace().addAll(cell);
x++;
}
}public Vector3f getCellLocation(int x, int y) {
float nx = x * 5;
float nz = y * 5;
System.out.println(“Building Vector3f for cell (” + x + ", " + y + " at " + nx + ", 0.0, " + nz + “)”);
return new Vector3f(nx, 0.0f, nz);
}public static void main(String[] args) {
new Test();
}
}[/java]