Breakable objects: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
first stub
Tels (talk | contribs)
add bind force diagram
Line 69: Line 69:
Let's first consider the scenario of a free-standing body. The force F that is needed to topple a body is defined as shown on the right:
Let's first consider the scenario of a free-standing body. The force F that is needed to topple a body is defined as shown on the right:


We assume here objects of equally-distributed mass, e.g. the density is the same for the entire object. This is the default in Doom3, anyway. If really necessary, we could always simulate an object with unequally distributed density by binding two different objects together.
We assume here objects of equally-distributed mass, e.g. the density of ''each of the parts'' is the same for the entire part. This is the default in Doom3, anyway. If really necessary, we could always simulate a part with unequally distributed density by binding two different objects together.


A higher F translates here into a more stable object. We can consider two bound objects by simple assuming that there is an additional force F<sub>B</sub> that binds the two objects together:
A higher F translates here into a more stable object.  
 
[[Image:Attachment force.png|320px|right]]
 
We can consider two bound objects by simple assuming that there is an additional force F<sub>B</sub> that binds the two objects together. The stronger this force becomes, the higher F needs to be to "topple" the object over, e.g. break the bond.


{{clear}}
{{clear}}

Revision as of 15:22, 28 January 2008

Things to remember:

This article represents work-in-progress and does not necessarily reflect the current working state of the code!

Introduction

This article deals with details in regarding of breakable objects in the physics simulation.

Destroying Objects

When the force acting on one entity becomes very strong, it should be destroyed. This can happen while the entity is still bound to another entity, or after they have become unbound. These cases are already working for some objects, like wine bottles.

Currently, this is done by setting the following spawnargs on one entity:

       "broken"                        "models/darkmod/junk/wbottle01_broken.lwo"
       "health"                        "20"

The Spawnarg:health sets the amount of damage that needs to be done to the object until it breaks, and the Spawnarg:broken sets the model that will replace the default model after the destruction.

Drawbacks of this method are that health can drop by small forces acting on the entity. After the health has dropped considerable, a small force can then suddenly break the object. For instance, damaging a wine bottle by 9 points 2 times would leave the bottle with only 2 points health, and thus suddenly a damage of 2 points can destroy the bottle.

Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons.

TODO

  • Except wine bottles, no object breaks when a sufficient force acts on it.
  • Strong forces do not nec. damage entities. For instance dropping a crate on a bottle does not break the bottle.

Unbinding

It is possible to bind entities together via the spawnarg bind.

The bound entity is called "slave" (or bindslave), while the entity it is bound to is usually called "master (or "bindmaster").

Binding means that the relative position of the slave to the master will stay the same. Forces that act on either the slave or the master are relayed to the other entity, making them act as if they were one unit.

When the force acting on one of the bind-members becomes to strong, the bind should break up.

TODO

This is currently never the case.

Forces acting on bound entities

To simplify the explanations, we consider here only 2D-forces. The third dimension can then be easily added by using an impulse 3D vector.

Note: Any 2D vector (f.i. a force) can be represented by 2 (related) vectors (forces) acting along the X and Y-axis.

In the following scenario, a bar (slave) is bound to a plate (master). The force F (blue) is here show as two forces FX and FY, acting on this slave. Depending on the strength of the attachment and the force, the two objects would then become unbound.

Attachment Strength

In reality, the attachment can be of variable strength, depending on how exactly the objects are attached to each other. This can be glue of varying strengths, or one ore more nails etc.

There are two extreme cases:

  1. The first case is no attachment at all, this means the bar is just standing on the plate. This scenario is already implemented in the normal physics engine.
  2. The other extreme is an unlimited strength of the attachment, this is currently the default case for objects that are bound to each other. In this scenary, the two objects never become seperated.


Let's first consider the scenario of a free-standing body. The force F that is needed to topple a body is defined as shown on the right:

We assume here objects of equally-distributed mass, e.g. the density of each of the parts is the same for the entire part. This is the default in Doom3, anyway. If really necessary, we could always simulate a part with unequally distributed density by binding two different objects together.

A higher F translates here into a more stable object.

We can consider two bound objects by simple assuming that there is an additional force FB that binds the two objects together. The stronger this force becomes, the higher F needs to be to "topple" the object over, e.g. break the bond.

See also