Code:
public ThrownGrenade(SimpleApplication app, Weapon weapon, Vector3f direction, Spatial mesh) {
super(app, weapon, direction, mesh);
this.length = super.getLength();
this.speed = super.getSpeed();
this.direction = super.getDirection();
System.out.println("mesh local translation:" + mesh.getLocalTranslation());
System.out.println("mesh parent:" + mesh.getParent());
System.out.println("parent local translation:" + mesh.getParent().getLocalTranslation());
System.out.println("parent world translation:" + mesh.getParent().getWorldTranslation());
Vector3f pos=new Vector3f(1, 1, 1);
pos= mesh.getWorldTranslation();
System.out.println("Pos: "+pos);
this.mesh = (Node)assetManager.loadModel(WeaponData.weaponMeshPath[weapon.getWeaponId()]);
//this.mesh.setLocalTranslation(worldPos);
//this.mesh.setLocalRotation(worldRot);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", assetManager.loadTexture(WeaponData.weaponMeshTexPath[weapon.getWeaponId()]));
this.mesh.setMaterial(mat);
rootNode.attachChild(this.mesh);
BulletAppState bas = app.getStateManager().getState(BulletAppState.class);
CylinderCollisionShape shape = new CylinderCollisionShape(new Vector3f(1, 2, 1).mult(.25f), 1);
rigidBody = new RigidBodyControl(shape, WeaponData.mass[weapon.getWeaponId()]);
this.mesh.addControl(rigidBody);
bas.getPhysicsSpace().add(rigidBody);
rigidBody.setCcdSweptSphereRadius(.01f);
rigidBody.setCcdMotionThreshold(.0001f);
rigidBody.setLinearVelocity(this.direction.mult(25));
}
Output:
mesh local translation:(0.0, 0.0, -0.0)
mesh parent:Root Node (Node)
parent local translation:(0.0, 0.0, 0.0)
parent world translation:(0.0, 0.0, 0.0)
All runs basically the same, no errors occur.