SharedNode and Collision w/ Geometry

Hi,

I've another Problem :smiley:

I tried to use SharedNode, but now i got a problem with the Collisions.

If i use for example a BoundingSphere everythink works just fine, but if i try to use the Geometry (hasCollision(Spatial,true)) for Collision-Detection it only works for a few models, but for most of the models it doesn't work.

I can just walk thru the objects.



I hope you understand what i mean :smiley:



Dennis

Yep, i call updateModelBound().



@Core-Dump:

I don' really know what u mean, but to complete my Code:

Node finalRes = new Node("MoveObj");
         Node rotateObj = new Node("Rotate");
         Quaternion rotObj = new Quaternion();
         rotObj.fromAngleAxis(rotation*FastMath.DEG_TO_RAD, new Vector3f(0,1,0));
         rotateObj.setLocalRotation(rotObj);
         
         Node modelNode = Model.loadModel(getClass().getClassLoader().getResource(model),new Vector3f(0,0,0),scale);
         
         rotateObj.attachChild(modelNode);
         
         
         finalRes.setLocalTranslation(pos1);
         finalRes.attachChild(rotateObj);



Thats how i add the model to my Root-Node (finalRes gets attached to Rootnode)
That's everthing i do with the models and as is said, i added the following after the the translation and scale in the method loadModel():

test.setModelBound(new BoundingBox());
         test.updateModelBound();



So, thats about it :D

But it still won't work...

Nobody an Idea?

Or how can i make the BoundingVolume more detailed?

Because right now, if i use a BoundingBox, sometimes its not really close to the actual object.



I just tried to add to all my Objects an BoundingBox intead of an BoundingSphere. With BoundingSphere everythink worked just fine, but if i use BoundingBox it just crashes without any Exception.

It just shuts down.

What am i doing wrong?

Could you post a small example which shows off the problem easily?

Because right now, if i use a BoundingBox, sometimes its not really close to the actual object.

This sounds strange, with a small example its much easier to tell if its a problem in jme or in your code.

hm…it's kinda weird.

I spend the last couple of hour trying to figure out whats wrong, but it still won't work.

The problem is, that it seems randomly the BoundingBox of an Objekt is stretching to infinity in one direction.



So maybe you can find a mistake.



First of all i have a class ModelCache (Singleton) with the method getModel():

public Node getModel(URL name) {
      if(nodes.containsKey(name)) {
         return (Node)nodes.get(name);
      }
      try{
         Node test = (Node) BinaryImporter.getInstance().load(name);
         nodes.put(name, test);
      }catch(IOException e) {
         System.out.println("Fuck");
         System.exit(0);
      }
      return (Node)nodes.get(name);
   }



Then i have a class Model with the Method loadModel:

public static Node loadModel(URL model,Vector3f pos,float scale,float angle) {
      SharedNode test = new SharedNode("Test",ModelCache.getInstance().getModel(model));
         
      test.setLocalScale(scale);
      test.setLocalTranslation(pos);
         

         
      Quaternion rotate = new Quaternion();
      rotate.fromAngleAxis(angle*FastMath.DEG_TO_RAD, new Vector3f(1,0,0));
      test.setLocalRotation(rotate);
      
      return test;
   }



And when i load the model into the game, i just call the loadModel(...)-Method, rotate and translate the node and then add it to the Node object, which is attached to the Root-Node.

So when should i add the BoundingBox or am i doing something else wrong?

maybe you need to update or create a new bounding box after scaling the shared node.

Hi,

I added & updated the bounding in the method loadModel() after i set the Translation and Scale, but evertime i load the game, the boundingboxes are different.

Here is a Screenshot so you can see my problem:



As u can see the boundingboxes are going wildly around everywhere. For example the Boundingbox of the plant is stretching veeeery far and when i load it again, it fits perfectly :?



Or do u know, why the Collision-Detection with triangles won’t work?

you could also check if the translation etc of the template model don't get modified, maybe you do something funny with it.

do you call updateModelBound

i did a few tests and couldn't reproduce a problem with bounding boxes.

i noticed tho, that the location of my 'template' geometry has been modified, but it may be completely unrelated to your problem :slight_smile:



You need to try to break the problem down and reproduce it in a small test case.

I tested all little bit around, and the weird thing is, that everything works fine if i just use for example 10 objects.



For example with 47 Objects everything is just fine, but if i add one more object, all the boundingboxes start stretching again.



So maybe you should add some more objects to reproduce it.



But thanks for your effort;)

Still not convinced that the way you are using boundingBoxes is right - mainly due to not being able to see the code where the boundingVolumes are placed.



Also noted you use shared meshes, exactly what are you setting the boundingVolume on - the loaded model in a cache as a ? node, or the shared mesh wrapping the model.







Also do you call updateModelBound on the parent after attaching the model along with updateGeometricState.

Wow…now it's getting really confusing :?



I tried to create a small example, but everythink worked fine.

So i tried to find out what the problem is and i found out, that as soon as i change the camera, the boundingboxes are going wild.

Buf if i don't change the camera, everythink is just fine.



But i want the camera to follow the playerNode.



Right now i just copied the DebugGameState and changed a few things, so i got the following input handler:

input = new FirstPersonHandler(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), 15.0f, 0.5f);



But since i want the Camera to follow a Node, i tried to use ChaseCamera and put instead the following:

input = new ChaseCamera(DisplaySystem.getDisplaySystem().getRenderer().getCamera(),playerNode);



But again, the Boundingboxes are going wild -.-

So what am i doing wrong again?

Dennis


Edit:
So...now it kinda works. I don't really know what i did wrong, but know it works.
But jME really made me remember of my physics-course in School, when we talked about Photons and stuff.
Because when displayed the bounds everything was as it was supposed to be, but when i turned them off, everything went wrong again^^