Hello @sgold,
I am probably doing something wrong, but I think I found a bug in Minie.
If I have a spatial (with a RidgedBodyControl) attached to a parent node, and the node has a rotation on it, the collision mesh on the ridged body control will not be rotated with the spatial. But translation on the parent node does work, just not rotation.
I have built a test example:
public class PhysicsTest extends SimpleApplication {
private boolean cursor = false;
private BulletAppState physics;
@Override
public void simpleInitApp() {
Node world = new Node("world");
//Load lighting
JmeLightingState lightingState = new JmeLightingState();
stateManager.attach(lightingState);
//Physics
physics = new BulletAppState();
physics.setDebugEnabled(true);
//Enable multi-threading
physics.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(physics);
//Import Avocado
Node rotateMe = new Node();
Spatial building = assetManager.loadModel("Models/kitbash3d/KB3D_Highways-Native_seperate_tex/KB3D_HGW_Highway45Turn_A_grp.j3o");
rotateMe.attachChild(building);
rotateMe.setLocalRotation(new Quaternion(Quaternion.ZERO));
rotateMe.setLocalTranslation(0f, 5f, 0f);
RigidBodyControl control = new RigidBodyControl(CollisionShapeFactory.createMeshShape(building), 1);
control.setKinematic(true);
world.attachChild(rotateMe);
rootNode.attachChild(world);
building.addControl(control);
physics.getPhysicsSpace().add(control);
cam.setLocation(new Vector3f(0, 200f, 600f));
cam.setFrustumFar(5000f);
flyCam.setMoveSpeed(100f);
ActionListener tab = (name, isPressed, tpf) -> {
if (!isPressed) {
cursor = !cursor;
flyCam.setEnabled(cursor);
}
};
inputManager.addMapping("tab", new KeyTrigger(KeyInput.KEY_TAB));
inputManager.addListener(tab, "tab");
}
public static void main(String[] args) {
PhysicsTest main = new PhysicsTest();
main.start();
}
}
My tests have PBR lighting in a separate app state here:
JmeLightingState
public class JmeLightingState extends BaseAppState {
private DirectionalLight dl;
private SimpleApplication app;
private FilterPostProcessor fpp;
private EnvironmentCamera envCam;
private LightProbe probe;
private Node lightingNode;
private short renderSteps = 0;
private int probeRadius = 5000;
private boolean probing = true;
@Override
protected void initialize(Application a) {
app = (SimpleApplication) a;
app.getViewPort().setBackgroundColor(ColorRGBA.White);
lightingNode = (Node) app.getRootNode().getChild("world"); //For iso-test
lightingNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(1.3f));
lightingNode.addLight(al);
dl = new DirectionalLight();
Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);
dl.setDirection(lightDir);
lightingNode.addLight(dl);
dl.setColor(ColorRGBA.White);
final int SHADOWMAP_SIZE=4096;
/*
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(app.getAssetManager(), SHADOWMAP_SIZE, 4);
dlsr.setLight(dl);
dlsr.setLambda(0.55f);
dlsr.setShadowIntensity(0.8f);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
//dlsr.displayDebug();
app.getViewPort().addProcessor(dlsr);
*/
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
dlsf.setLight(dl);
dlsf.setLambda(1f);
dlsf.setShadowIntensity(0.4f);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setEnabled(true);
LightScatteringFilter godRays = new LightScatteringFilter(lightDir.multLocal(-3000));
godRays.setNbSamples(50);
godRays.setBlurStart(-0.037999995f);
godRays.setBlurWidth(0.8170011f);
godRays.setLightDensity(0.36198944f);
//LightScatteringUI ui = new LightScatteringUI(app.getInputManager(), godRays);
//Filter
fpp = new FilterPostProcessor(app.getAssetManager());
fpp.addFilter(new FXAAFilter());
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(4.0f)));
fpp.addFilter(dlsf);
fpp.addFilter(godRays);
fpp.addFilter(new SSAOFilter(5.1f, 1.2f, 0.2f, 0.1f));
app.getViewPort().addProcessor(fpp);
Spatial sky = SkyFactory.createSky(app.getAssetManager(), "Textures/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
app.getRootNode().attachChild(sky);
//Env Cam
envCam = new EnvironmentCamera(256, new Vector3f(0, 3f, 0));
app.getStateManager().attach(envCam);
//LightsDebugState debugState = new LightsDebugState();
//app.getStateManager().attach(debugState);
//MaterialDebugAppState debug = new MaterialDebugAppState();
//debug.registerBinding("Common/MatDefs/Light/PBRLighting.frag", app.getRootNode());
//debug.registerBinding("Common/ShaderLib/PBR.glsllib", app.getRootNode());
//getStateManager().attach(debug);
}
@Override
protected void cleanup(Application a) {
app.getRootNode().removeLight(dl);
app.getViewPort().removeProcessor(fpp);
app.getStateManager().detach(envCam);
}
@Override
public void update(float tpf) {
if (probing) {
renderSteps++;
if (renderSteps == 2) { //Give the scene a frame to update
//System.out.println("Starting PBR Probe");
lightingNode.removeFromParent();
probe = LightProbeFactory.makeProbe(app.getStateManager().getState(EnvironmentCamera.class), app.getRootNode(), new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
//System.out.println("PBR Probe results in");
}
});
((SphereProbeArea) probe.getArea()).setRadius(probeRadius);
app.getRootNode().addLight(probe);
} else if (renderSteps > 10) {
app.getRootNode().attachChild(lightingNode);
probing = false;
renderSteps = 0;
//System.out.println("PBR Probe Done");
}
}
}
public void reprobe() {
probing = true;
}
public int getProbeRadius() {
return probeRadius;
}
public void setProbeRadius(int probeRadius) {
this.probeRadius = probeRadius;
}
@Override
protected void onEnable() {
dl.setEnabled(true);
envCam.setEnabled(true);
reprobe();
app.getViewPort().addProcessor(fpp);
}
@Override
protected void onDisable() {
dl.setEnabled(false);
envCam.setEnabled(false);
app.getViewPort().removeProcessor(fpp);
if (probe != null) {
app.getRootNode().removeLight(probe);
}
}
}
Here I have applied both a translation and rotation to the parent node, but the collision mesh only respected the translation, not the rotation.
EDIT: I am using Minie 4.0.0
Any help is greatly appreciated.
Thank you,
Trevor