I noticed this the other day:
r5337
jme3:
- remove warning when adding PhysicsNodes as children to other PhysicsNodes as
this is actually o.k. now.
I put together a simple test: two (2) PhysicsNodes consiting of Sphere and SphereCollisionShape types. A torque is to the parent calculated the angular acceleration. It was pretty obvious the mass and moment of inertias of the child were not "effective". My question is: is the intended behaviour?
(sorry for the superfluous lines of code… this is a test block I use)
import com.jme3.app.SimpleBulletApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.collision.CollisionEvent;
import com.jme3.bullet.collision.CollisionListener;
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.nodes.PhysicsNode;
import com.jme3.input.KeyInput;
import com.jme3.input.binding.BindingListener;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;
import com.jme3.texture.Texture;
public class TestBox_1 extends SimpleBulletApplication implements BindingListener, CollisionListener
{
PhysicsNode player, npn, xpn;
Quaternion tempQ1;
Vector3f tempV1, tempV2;
boolean test = true;
float totalTime = 0.f;
public static void main(String[] args)
{
TestBox_1 app = new TestBox_1();
app.start();
}
private void build()
{
Vector3f v3F = new Vector3f(0, 0, 0);
Vector3f v4F = new Vector3f(0, 0, 0);
PointLight pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setPosition(v3F);
getPhysicsSpace().setAccuracy(1.f/2000.f);
pl.setRadius(100f);
rootNode.addLight(pl);
getPhysicsSpace().setGravity(Vector3f.ZERO);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
TextureKey key = new TextureKey("Interface/Logo/Monkey.jpg", true);
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
mat.setTexture("m_ColorMap", tex);
this.getCamera().setLocation(new Vector3f(0.f,0.f,25f));
Sphere s1 = new Sphere(10,10,.5f);
Geometry g1 = new Geometry("S1",s1);
g1.setMaterial(mat);
player = new PhysicsNode(g1,new SphereCollisionShape(.5f), 1.f);
v3F.set(0.f , 0.f, .0f);
player.setLocalTranslation(v3F);
player.setDamping(0f, 0f);
player.setSleepingThresholds(0, 0);
player.updateGeometricState();
player.updateModelBound();
rootNode.attachChild(player);
getPhysicsSpace().addQueued(player);
Sphere s2 = new Sphere(10,10,.5f);
Geometry g2 = new Geometry("S2",s2);
g2.setMaterial(mat);
npn = new PhysicsNode(g2,new SphereCollisionShape(.5f), 1.f);
npn.setName("TEST");
npn.setDamping(.0f, .0f);
v4F.set(2.0f, 0.0f, 0.f);
npn.setLocalTranslation(v4F);
//npn.pNode.setLocalRotation(m5F);
npn.setSleepingThresholds(0, 0);
npn.updateGeometricState();
npn.updateModelBound();
//npn.attachChild(cameraNode);
rootNode.attachChild(npn);
rootNode.updateGeometricState();
getPhysicsSpace().addQueued(npn);
player.attachChild(npn);
player.updateGeometricState();
}
@Override
public void simpleUpdate(float tpf)
{
totalTime += tpf;
if(test)
{
//player.setAngularVelocity(Vector3f.UNIT_Z.mult(1.f));
player.applyContinuousTorque(true, Vector3f.UNIT_Z.mult(1.f));
System.out.println(player.getAngularVelocity());
System.out.println(totalTime);
}
}
private void setupKeys()
{
inputManager.registerKeyBinding("ENTER", KeyInput.KEY_RETURN);
inputManager.registerMouseButtonBinding("ENTER", 0);
inputManager.addBindingListener(this);
}
@Override
public void onBinding(String binding, float value)
{
if (binding.equals("ENTER"))
{
player.setLinearVelocity(Vector3f.ZERO);
player.setAngularVelocity(Vector3f.ZERO);
npn.setLinearVelocity(Vector3f.ZERO);
npn.setAngularVelocity(Vector3f.ZERO);
System.out.println("STOPPED");
if(test)
{
test = false;
}
else
{
test = true;
}
}
}
@Override
public void simpleInitApp()
{
setupKeys();
build();
getPhysicsSpace().addCollisionListener(this);
tempQ1 = new Quaternion();
}