Bounding loaded models

Edit: part of this is incorrect as I realized later, also read the following posts


I loaded a model following the tutorial HelloModelLoading. Model is huge, and after I scale it I set bounding sphere and update model bounds. Problem is that bounding sphere stays huge, doesn’t scale. In the tutorial author is doing the same thing so I do not know what to do to make bounds normal.

and btw., model loads at (0,0,0), it’s a ball, but it’s center isn’t the centar of the ball. How do I set that center of ball model is reference for translations? I hope you understand what I mean. Example, if move the ball model to (0,0,0) I want center of the ball to be at (0,0,0).

my code:

    private void loadFootball() {
        URL model = this.getClass().getClassLoader().getResource("viktorije/data/football.3ds");
        FormatConverter converter = new MaxToJme();
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        try {
            converter.convert(model.openStream(), bo);
            Node football = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(bo.toByteArray()));
            football.setModelBound(new BoundingSphere());
        } catch(IOException e) {
            System.out.println("Error loading football model, exiting.");

not sure about the bounds problem, but to center ball I would center it in modeling program before exporting to jme.

thank you mud2005 for your anwser, it helped

now what about those bounds? I mean, it's in tutorial… So more direct and abstract question:

How to you set the bounds the be the right size on loaded model?

I’ve found out that bounds on the ball are correct, but bounds of whole scene, whole terrain change to bounding sphere even though bounding box would be much better, like it was before loading ball. The ball is very small and it would definitly fit into the previous box bounds.

I see that there is no interest in this, so I won’t go into it further, I’ll just post 2 screenshots so you can clearly see “the problem”:

I don't know the function to fit the BoundingSphere better (updateModelBounds?updateGeometricState?). But since your model isn't the right size yet, it's probably easier to load the 3ds, scale and export to a jme model first. If you don't want to go back to 3ds to position the model you can do that as well before you export to jme. Or load up monkeyworld3d after you exported and position it there. I assume the BoundingSphere will fit when you load the jme as it has no knowledge of the previous big size.


When using bounding box on the ball, scene bounds stay the same (bounding box). But who in their right mind would use bounding box instead of bounding sphere for a ball? :slight_smile:

I understand your curiosity…  because that maybe means that is how jME works, if there is a sphere in the world then world bounds changes to sphere… would be strange if it is true


I've figured out the problem, boundinig sphere for ball fits perfectly, it doesn't stays big as I said in first post. The bounds of all scene is the one that changes to big bounding sphere. Read my previous post again.

Just curious, but what happens if you set the bounding of the ball to a BoundingBox as well ?

I am not absolutely sure but could it be that you also call updateWorldBound somewhere in the code ?

That would explain the behaviour.

As i see it updateWorldBound will merge the bounds of all objects in a scene. It takes the first child of a scene it can find and uses its boundingvolume. If that first child happens to be a sphere then i guess you will have one big sphere later as well.

See in your screenshot it seems that there is only one boundingvolume in the end. So that would be my guess.

Yes, that is it then! Thank you.

I do not call updateWorldBound() myself but I'm pretty sure SimpleGame calls updateGeometricState() after simpleInit(), which calls updateWorldBound(). In javaDoc there isn't anything written about taking the first child and modeling Node bounding volume on it, tutorials don't mention it also so I couldn't know that.

I've learned something today :slight_smile: … pick wisely your first child for a Node :slight_smile: