Tag Info

Hot answers tagged

14

Solving this problem requires adjusting position and possibly velocity. Rigid body physics engines have a solver that march objects forward in time using Newton's laws of motion while also solving non-penetration constraints and friction. These engines can compute the right combination of linear and angular motion to create plausible trajectories. If you ...


11

While I recommend against rolling your own physics engine for anything other than the experience of doing it (just realize you probably should throw it away when you're done -- it's really hard to get all the edgecases and numeric limit/stability issues sorted out, and your time may be much better used by contributing to an existing engine), here are a few ...


10

How to start an Architecture/Design Task: With pen and paper. Get yourself a large sheet of paper and start drawing out the components and items that will exist within your engine. What properties each entity will need so that you can model the physical interaction. You'll need to figure out what entities your code will have to deal with, which entity has ...


9

Here is how I learned to write a physics engine, its all free and highly recommendable: David Baraff's papers particulary An Introduction to Physically Based Modeling Brian Vincent Mirtich's Thesis Impulse-based Dynamic Simulation of Rigid Body Systems Kacic/Bullock "A practical dynamics system" SIGRAPH 2003, EDIT: Link added. Those papers were ...


9

No. Collision detection is not always O(N^2). For instance, say we have a 100x100 space with objects with size 10x10. We could divide this space in cells of 10x10 with a grid. Each object can be in up to 4 grid cells (it could fit right in a block or be "between" cells). We could keep a list of objects in each cell. We only need to check for collisions in ...


8

You don't need a physics engine for this because the calculations required are extremely simple! All you have to do is to apply some gravity to your player's vertical velocity, and he will automatically follow an arc when jumping. For a detailed explanation of how it works, including a demo that runs in the browser, read the following answer: ...


8

Spatial division is always O(N^2) in worst case and that is what complexity in informatics is about. However there are algorithms that work in linear time O(N). All of them are based on some kind of sweep line. Basically you need to have your objects sorted by one coordinate. Let's say X. If you perform the sort every time before collision detection, the ...


6

This question is pretty much 'what is a game engine'. Game engines are whatever software is needed to make a game, and there is no accepted checklist of what needs to be in such an engine for it to qualify. That said, any simulation-style game will essentially do three things: acquire input, perform simulation, and present output. For input you need to ...


6

Here is another such tutorial, which might help you: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Basic_Bones_System It's very thorough, and I even used it once to produce an animation engine. The theory is very good and it should be easily understood for you to use it in AS3.


6

Good physics engines: Use algorithms and data structures with good theoretical ("big-O") properties. Use specific memory allocators and data layouts for improved cache efficiency. Use microoptimized code, that not just has good big-O runtime but is also known to generate efficient code on real compilers / machines (e.g. SIMD and specialized instructions ...


6

The keywords you're looking for are "support points" and "manifold". Erin Catto has written an excellent 2D physics engine. He regularly presents at GDC. You should be able to find some of his slides where he explains collision manifolds. The first version of his physics engine only supported box shapes to simply calculating the support points. Which is ...


6

Here's the basic steps you'll need to folow: First create a world object (i.e. btDiscreteDynamicsWorld) to drive your physics simulation. You should already have a class such as GameObject that perhaps stores a model along with its bounding box and position/orientation in the world. Replace the position/orientation information with an instance of a physics ...


5

How do you get curves in Box2D? In the unreleased version of Box2D, there are two new shape types, b2LoopShape and b2EdgeShape, which let you build curves out of a sequence of line segments. In the released version, you can use multiple small boxes set at angles to get a similar effect, but bodies have a tendency to do unstable and unexpected things near ...


5

There's no such thing as best physics engine. It heavily depends on what you need. Take Box2D as an Example: It is a fully featured 2D Physics Engine, originally developed in C++ and ported to ActionScript. It is great for realistic 2D physics simulation, including gravity, forces, friction, continuous collision detection and much more. An Engine like Box2D ...


5

Is it really efficient to load all your objects in the physical or collision world just to test them for intersection? Yes it is efficient... for the programmer. There are lots of physics engines around and it's far easier to just use one - than to strip one down, or implement raycasting yourself. Talking about code (in fairly rough terms): You've got ...


5

You should be able have you character go up slopes without a 3rd party tool. You can attach the character controller(download it off the asset store, its free) and then you can change the angle that the character is allowed to move over (I have my player able to climb up to a 50' angle, be sure the re-angle the character though). The 2D Toolkit is ...


5

Use the same time steps every time. My physics engine is set to use 33 ms time steps, and I can produce the exact same simulations that way (assuming I use the same machine.) If I use different time steps, even 1 ms more, the game will slowly diverge. You can do this with this basic loop: void update( long timeMS ) { _accumulatedTime += timeMS; ...


5

Nowadays, more game engines adopts a component design (e.g. Unity, Unreal). In this kind of design, a GameObject is composed of a list of components. In your situation, there can be a MeshComponent and a PhysicalComponent, both attaching to a single game object. For simplicity, you can put a world transform variable to the GameObject. During update phrase, ...


4

I'd look into a physics engine like Box2D or Nape. These engines come with several different joints you can use to animate lots of different stuff. Here's an example of the different joints/constraints possible. On the Box2D (for Flash) homepage you'll also find a Ragdoll example which probably comes really close to what you're trying to achieve. Maybe you ...


4

Here's how you might do it: Approximating movement Every physics object needs these vectors: Position: Where the object is. Speed: How its position is changing. Acceleration: How its speed is changing. So, intuitively, you need to do this sort of thing every frame to every physics object a: a.speed += a.acceleration a.position += a.speed ...


4

Probably the most comprehensive tutorial style resource: http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/ See also these related articles from the same blog: http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/ ...


4

Maik is right, Baraff's papers are an excellent start, but don't forget Chris Heckers write-up on rigid body dynamics: http://chrishecker.com/Rigid_Body_Dynamics ! Also his advice on "[..] you will throw your engine away" is entirely true. But you will learn a lot! Regarding the CUDA/OpenCL part of your question: If you know CUDA then switching to OpenCL ...


4

I started out with Baraff too but it's a bit dated by now. What you need is iterative solvers and the best paper imo on that is Erin Catto's Iterative Dyanmics. You have all you need in there to implement your physics engine. You can dig a bit into Erleben's PhD thesis if you need more details (like joints and more math stuff), but that's pretty much it. I ...


4

As you already suggested, you have to take the mass of the objects into account to calculate the change of velocity caused by the impulse. Namely, divide the impulse by the mass for each object. You can find this and much more information in this paper "Impulse-based Dynamic Simulation of Rigid Body Systems" from Brian Vincent Mirtich. Page 60 shows it in ...


4

Bullet Physics is the choice I'd go with if you absolutely require opensource. It's pretty much THE choice in your situation. If not, physx and havoc both have non-commercial licenses. Here is a more complete list http://www.gamedev.net/topic/475753-list-of-physics-engines-and-reference-material-updated-7-march-2011/


4

Generally physics engines are split into two major parts: Collision detection and collision resolution. The solver is just responsible for the second part. After your collision detection part determines which pairs of objects collide, and where, the solver is responsible for creating the correct physical response. "Iterative solver" just means that the ...


4

I would start by looking at libgdx. There are three main advantages for you as I see it: It comes with Box2d integrated It comes with a 2D scene graph (in case you've never used a scene graph, this can greatly simplify setting up 2D levels and sprites, handling input, etc) It runs on the desktop and Android. In Eclipse, it's just a matter of selecting a ...


4

In case you are having troubles with small numerical values, I suggest that you simply scale everything down. You might even not use "real" measurment units, but just some "generic" units that only make sense inside the engine. The first option, scaling down, would require that you use millimeters or centimeters as a base measurement unit. Your cube's ...


4

This looks very similar to a problem I once had when making my own physics hack, although I can't really see from your code if this is the case here. My problem was that when an object collided at a slow speed my collision handling didn't move it enough away from the collision (so it didn't solve interpenetration). That mean that a second collision would be ...



Only top voted, non community-wiki answers of a minimum length are eligible