Sign in to follow this  

Accurately model a system of cubes? (is this extremely hard or just hard?)

This topic is 4396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I haven't really read up on the software aspect of physical modeling, but I do know my physics and have plenty of numerical methods references. I was hoping mostly for direction (good books, advice, etc.) since this is a pretty ambitious project. Here's what I'm interested in doing: I want to physically model a world made of cubes of various sizes/densities. Then I want to do stuff to that world and watch as it unfolds. For example, I could build up a skyscraper from a bunch of cubes and throw a meteor (might as well make that another cube for genericity) right into the center of it and see how it collapses. So a cube would have dimensions and mass, and presumably some form of coupling to its neighbors (how much force is required to tear it off from a neighbouring cube). Now, I don't really mind if it's not realistic to do this in real time, because the final goal will be to just generate the frames (locations/orientations of said cubes) at the software's leisure into a format that can be prettified and rendered later (say a POV-Ray animation or somesuch). Since this is a pretty big topic, I'll try to narrow down my questions: 1 - Based on some of your experiences with physics, how hard does this project sound? Sometimes, it feels like it may be relatively simple, and other times, it feels like it would be extremely complex. But I have a feeling that if I can model ONE cube, modeling the interaction of hundreds in a system is not a very huge step up, assuming speed is not the most important factor. 2 - What are good books about this topic? 3 - ....any general advice from the more experience physical modelers out there? Thanks!

Share this post


Link to post
Share on other sites
That's very interesting.

I'm not too experienced with physical modeling or anything, but I would say the best way to do it would be to make a cube class. Make a function or method to generate a building of dimentions (L, W, H, CUBESIZE, CUBEDENSITY). That method then generates a bunch of cubes, of cubesize and cubedensity, that could construct that building. You would have to modify that a bit to make your buildings hollow, but that isn't very hard at all. Also, if you wanted to have multiple densities in the same structure, that would be different too.

Sorry if this doesn't help at all. I tried.

Share this post


Link to post
Share on other sites
Have you heard of blender?
Blender.org
This is a 3D modeling program that has built in physics engine and raytracing rendering engine. If you just want to watch things be destroyed this could work for you that is if you want to take the time to learn it.

If you want to make your own, something I have been thinking about doing, I don't have much to help you with there. I would start by working on the collision detection between the cubes and how they apply forces to your cubes.

Share this post


Link to post
Share on other sites
These are just a few ideas about how you might break a project like this down:

1. Collision detection

Limiting the objects to boxes will make this manageable, but there's still a fair amount to it. I would think the most straightforward algorithm to implement for this would the SAT (separating axis theorem). One decision you'll have to make is whether the boxes will be moving fast enough that a continuous test is required. In either case, you'll need information for moving the boxes so that they are just touching (penetration distance and direction, or first time of contact), as well as contact points and normals. I have code for this which is sort of scattered about, but if it would be helpful I could share some of it. oliii also may have demo code for 3d box collision detection with contact information. You could also check out some of Dave Eberly's docs on OBB intersection, or google for 'separating axis theorem'. Although straightforward in principle, the full algorithm, including contact points, is fairly non-trivial and will be a project unto itself, more or less. You'll of course want to thoroughly test the collision detection (using debug graphics) before trying to integrate it into a simulation.

2. Basic physics

If you know physics, this will just be a matter of application. The Baraff and Hecker papers both give clear explanations of setting up a basic rigid body simulator controlled by impulses and forces. For testing I'd start with a simple unconstrained box in space that you can push around by, say, clicking on it with the mouse to apply forces or impulses.

3. Basic collision response

The next step might be to implement and test the 3d impulse equation (which can be found in both the Baraff and Hecker papers), and test it by creating a 'room' of planes for the box to bounce off of. Here you'll probably only want to consider single contact points, so the box will not necessarily behave correctly if it collides with a plane edge- or face-on.

4. Resting contact/multiple contacts/stacking

This is the hard part, IMO. Here unfortunately my practical experience comes to an end, as I haven't spent much time on this problem. Plenty of others have though, and I would refer you to Mr. Rowl's posts and demos, John Schultz's work, some demos by b34r (can't remember his exact handle...), the Bullet coldet and physics library, and other similar references. The basic problem of stacked boxes has been addressed in many physics libraries and demos, so if the purpose is just to see it in action, using a third-party library would probably be easiest. If the aim is to learn, though, you'll obviously want to write your own.

All in all, not a trivial problem to solve, with the stacking part being the real kicker. But it has been done, and there are plenty of demos and code libraries that can be used as reference.

(Disclaimer: I'm not a physics expert, so anything I have to say on the subject should be taken with the proverbial grain of salt.)

Share this post


Link to post
Share on other sites
Thanks for all the insight! I don't just want to watch stuff go down, but want to learn about this stuff too, but I will check out blender just to see what it has to offer hehe.

Share this post


Link to post
Share on other sites
Remember, The hearth of Blender Physics is ODE (Open Dynamics Engine).
So if you want to collide a meteor at high velocity, you will find some drawbacks.
ODE hasn't been designed for high velocity collisions.
For example, if your escenary is a mesh, you will find out that objects can pass throught this mesh. Currently this problem hasn't been solved on ODE.
I think that Novodex can do this approach instead.

Share this post


Link to post
Share on other sites

This topic is 4396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this