Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  A shape's Perfect-fit Bounding Box?  (Read 2209 times)
0 Members and 1 Guest are viewing this topic.
Offline DAT64X

Senior Newbie




Java games rock!


« Posted 2003-11-16 22:13:23 »

Hi,

I was wondering how to get the bounding box for a model that fits that model perfectly.  It seems like everytime I do BoundingBox bbox = new BoundingBox(theModel.getBounds()), I get the same bounding box no matter what, which has lower point (-1,-1,-1) and upper point (1,1,1).  The bounding box always seems to be this size no matter how big or small the actual model is.  Is there a way to get the bounding box that fits the model perfectly?

The reason I ask this question is because I want to load some models into my scengraph, and I want to compute that model's width, length, and height.  I thought I could get it from the model's boundingbox, but as I mentioned previously, the bounding box never scales according to its model.

Thanks,
DAT
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #1 - Posted 2003-11-17 06:13:22 »

Hm strange ..... I did checks against BBoxes myself and they seemed to be correct.....

But I never constructed a new one from a models getBounds().
Maybe try to check wether the models getBounds() already delivers a BoundingBox, cast, and examine that? (thats the way I worked with it.)

Ah, and I dunno wether the model has to be live for the bounds getting calculated correctly!!

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Ifadolai

Junior Devvie




Java forever!!


« Reply #2 - Posted 2003-11-17 12:26:36 »

When you call getBounds() you always get a BoundingSphere if the bounds is autocomputed.

Is the properties of this sphere also the same each time?

Nikolai V. Christensen, Computer Engineer,
Simulation and Training department
IFAD, Forskerparken 10A, DK-5230 Odense M
Denmark, EU
Phone: +45 63 15 71 31  Fax: +45 65 93 29 99
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #3 - Posted 2003-11-17 12:58:53 »

Sure thats true?

I think I got an BoundingBox already, not a BoundingSphere. IIRC I used it with models loaded from 3DS with Starfires loader.


HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline DAT64X

Senior Newbie




Java games rock!


« Reply #4 - Posted 2003-11-18 01:42:55 »

So Herkules, how did you get your 3ds models' bounding box?  If I can do it without a boundingsphere in between or getBounds(), that's fine.  I just want to know how to get the bounding box for the sakes of computing the dimensions of my model.

Also, I load up my model as follows:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
class ModelWrapper extends BranchGroup {
....

ModelLoader loader = new ModelLoader();
Scene scene = null;
try { scene = loader.load(filename);
        }
...

}


The ModelWrapper branchgroup is the child of a transformgroup, and that transformgroup is the child of another branchgroup.

Which group should I be computing my bounding box off of?  Or perhaps I compute it based off of scene?



Thanks.
Offline DAT64X

Senior Newbie




Java games rock!


« Reply #5 - Posted 2003-11-18 04:13:31 »

"When you call getBounds() you always get a BoundingSphere if the bounds is autocomputed.

Is the properties of this sphere also the same each time? "


Well, as I mentioned in the post above this one, there maybe be a problem of me calling getBounds() on the wrong object.

I'm using Portfolio Loader to load dxf files, and I provided the code snippet for my code loader in the previous post.

What should I be calling getBounds on?
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #6 - Posted 2003-11-18 05:00:05 »

Hm, if in doubt, get the bounds from everything you can get hold of. Check for bounds type (instanceof BoundingBox?).

If the bounds are wrong, maybe the loader is fooling you? getAutoComputeBounds() is true?

Sorry that I cannot help better - just can say the NORMALLY the results of getBounds() makes sense.


HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline DAT64X

Senior Newbie




Java games rock!


« Reply #7 - Posted 2003-11-18 07:28:54 »

So should autoComputeBounds be true or false?  Ifodalai said earlier that "When you call getBounds() you always get a BoundingSphere if the bounds is autocomputed", but I'm not sure if that's what I want.
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #8 - Posted 2003-11-18 07:58:31 »

getBounds() always should deliver a bounds. Not necessarily a BoundingSphere, can be BoundingBox.
autocomputebounds lets Java3D compute the bounds by aggregating them up the scenegraph whenever a change in a subgraph occurs.

So e.g. if the loader assembles the model from smallerparts that have bounds, Java3D will automatically compute the bounds for the higherlevel nodes.

Sometimes this is desirable, sometimes not. A loader might be a candidate to set the bounds itself and let autocompute off. But if it doesn't.....

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Ifadolai

Junior Devvie




Java forever!!


« Reply #9 - Posted 2003-11-19 10:11:40 »

Quote
Sure thats true?

I think I got an BoundingBox already, not a BoundingSphere. IIRC I used it with models loaded from 3DS with Starfires loader.



Yes I am sure. I believe they do that because it is faster to check for intersections with spheres than boxes or polytypes, when doing viewFrustumCulling.

It could be the loader disabled autocomputing and then has sat the bounds to a box.

Nikolai V. Christensen, Computer Engineer,
Simulation and Training department
IFAD, Forskerparken 10A, DK-5230 Odense M
Denmark, EU
Phone: +45 63 15 71 31  Fax: +45 65 93 29 99
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #10 - Posted 2003-11-19 10:53:08 »

Quote


I believe they do that because it is faster to check for intersections with spheres than boxes or polytypes, when doing viewFrustumCulling.

It could be the loader disabled autocomputing and then has sat the bounds to a box.


Yes ok - this makes sense and does not contradict the facts I observed.

So autocomputed bounds always are BoundingSpheres.

The more I think the loader is fooling DAT64X.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Ifadolai

Junior Devvie




Java forever!!


« Reply #11 - Posted 2003-11-19 11:01:57 »

Quote
Is there a way to get the bounding box that fits the model perfectly?


Yes, some time ago a guy wrote a routine to do just that.

I think his name was Fabrizio Nunnari (http://digilander.libero.it/fnunnari), but I cant search the Java3D archives that feature seems not to work.

I remember a complete source solution to your problem was posted some years ago on the mailing list.

Nikolai V. Christensen, Computer Engineer,
Simulation and Training department
IFAD, Forskerparken 10A, DK-5230 Odense M
Denmark, EU
Phone: +45 63 15 71 31  Fax: +45 65 93 29 99
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (58 views)
2014-11-13 12:34:49

digdugdiggy (37 views)
2014-11-12 21:11:50

digdugdiggy (30 views)
2014-11-12 21:10:15

digdugdiggy (26 views)
2014-11-12 21:09:33

kovacsa (48 views)
2014-11-07 19:57:14

TehJavaDev (51 views)
2014-11-03 22:04:50

BurntPizza (51 views)
2014-11-03 18:54:52

moogie (66 views)
2014-11-03 06:22:04

CopyableCougar4 (65 views)
2014-11-01 23:36:41

DarkCart (151 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!