My Questions & Issues with JME3

Can anyone tell me what would cause this exception.  



It looks like the code is checking Spatial.refreshFlags = 0 , but im not sure how to force this to be zero.



java.lang.IllegalStateException: Scene graph must be updated before checking collision

       at com.jme3.scene.Geometry.collideWith(Geometry.java:184)

       at com.jme3.scene.Node.collideWith(Node.java:496)

       at jme3test.collision.SphereMotionAllowedListener.checkMotionAllowed(SphereMotionAllowedListener.java:131)

       at com.jme3.input.FirstPersonCamera.moveCamera(FirstPersonCamera.java:130)

       at com.jme3.input.FirstPersonCamera.onBinding(FirstPersonCamera.java:170)



[UPDATE]

I took out my emitter and now it doesnt throw the exception but the camera doesnt move either.

Call updateGeometricState() on the rootNode, right before you call collideWith().

If you run TestPhysicsCharacter

Does your ball (H,K,U,J) move?  Mine just hangs in space

I still havent gotten the keys working, but im trying something else…



Is there a way to see the collision spatial?  My Code is extending SimpleBulletApplication



PhysicsNode physicsBox=new PhysicsNode(model,new BoxCollisionShape(new Vector3f(1,2,1)),2);



I want to see the BoxCollisionShape
normen said:

gbluntzer said:

I still havent gotten the keys working, but im trying something else...

Is there a way to see the collision spatial?  My Code is extending SimpleBulletApplication

I want to see the BoxCollisionShape

No, not yet


But isn't there a PhysicsDebugger for jBullet-jME2? I think it could be ported quite easyjet ;)

The physics debugger is quite closely bound to jbullet and I want to be able to move the physics to native bullet without hassles in jme3. I have to look at the debugger implementation and see if it can be transferred to native easily before I decide how it will be integrated.

gbluntzer said:

I still havent gotten the keys working, but im trying something else...

Is there a way to see the collision spatial?  My Code is extending SimpleBulletApplication

I want to see the BoxCollisionShape

No, not yet

If Im using a PhysicsNode is there a way to move the spatial inside it around.



My Model has it origin at its neck and I want to translate it up so that the "feet" touch the bottom of my BoxCollisionShape instead of just the head in a box its doing now.



any Ideas other then fixing my model?

Sure, just edit the localtranslation of the child. That value will be kept. Only the parent PhysicsNode is updated by the physics.

New Question 2 parter:



1 KeyInput Question: Is there an example of how to use something like isPressed() or isReleased()



I would like to have my model move around while the button is pressed but want to trigger a event when its released



Im using


public class Main extends SimpleBulletApplication implements BindingListener
...
public void onBinding(String binding, float value) {
        if (binding.equals("Lefts")) {
            walkDirection.addLocal(new Vector3f(-0.1f, 0, 0));
...



2 how do you remove force from a PhysicsNode:
I tried


private PhysicsNode physicsBox2;
...
else if (binding.equals("Space")) {  //TODO change this to isRelease()?
            physicsBox2.setLocalTranslation(new Vector3f(3, 4, 0));
            physicsBox2.clearForces(); //Doesn't Seem to do anything .... Comments say not thread safe call physics thread
        }



Thanks for any help

Can’t help you with either question, sorry, I’m a jME noob  :stuck_out_tongue: BUT…



keep watching this thread if you don’t get an answer to question 1, as it’s a very similar question  :slight_smile:

gbluntzer said:


private PhysicsNode physicsBox2;
...
else if (binding.equals("Space")) {  //TODO change this to isRelease()?
            physicsBox2.setLocalTranslation(new Vector3f(3, 4, 0));
            physicsBox2.clearForces(); //Doesn't Seem to do anything .... Comments say not thread safe call physics thread
        }




I'm pretty much sure, that you can not set Translation etc on a PhysicsNode, except if you have made it Kinematic before.

physicsBox2.setKinematic(true);


Kinematic means, that it automatically computes the velocities etc, from the previous translation and the current one.

Also, remember clearForces() only clears the forces, NOT the Velocities. (Use setLinearVelocity(Vector3f.ZERO) or setAngularVelocity(Vector3f.ZERO)) instead.

Yes you can set the localTranslation of a physicsnode, how else are you supposed to move it? :wink:

The problem with the forces is that when you call setLocalTranslation its not immeditely applied to the physicsNode. That happens when updatePhysicsState() is called. So when you call setlocal and then directly clear forces there are no forces yet that could be cleared. So actually queueing the call in the physics queue might help. The not thread safe stuff only comes into play when you do multithreaded physics, and for most stuff only when you use detached physics.

normen said:

Yes you can set the localTranslation of a physicsnode, how else are you supposed to move it? ;)
The problem with the forces is that when you call setLocalTranslation its not immeditely applied to the physicsNode. That happens when updatePhysicsState() is called. So when you call setlocal and then directly clear forces there are no forces yet that could be cleared. So actually queueing the call in the physics queue might help. The not thread safe stuff only comes into play when you do multithreaded physics, and for most stuff only when you use detached physics.


o.O you can?.. I'm pretty sure, that you couldn't move a DynamicPhysicsNode in jme-physics, w/o forces... ;)
So.. I didn't understood kinematic rightly?

Uhm, this is jme3 jbullet physics, got nothing to do with jmePhysics2. Kinematic nodes dont have physics working on them (they just hang in the air) and when you move them their inertia is computed by the speed you move it with. So you can use a kinematic node to have an elevator or something. They will push around other physics objects but not be pushed by them.

normen said:

Uhm, this is jme3 jbullet physics, got nothing to do with jmePhysics2. Kinematic nodes dont have physics working on them (they just hang in the air) and when you move them their inertia is computed by the speed you move it with. So you can use a kinematic node to have an elevator or something. They will push around other physics objects but not be pushed by them.


Yes, I know they're independent :D But I thought maybe.. some basics were the same^^.. haha.. thought wrongly :)

Now I fully understand Kinematic Nodes :) At least I hope so..