|
|
(5 intermediate revisions by the same user not shown) |
Line 5: |
Line 5: |
| == Introduction == | | == Introduction == |
|
| |
|
| This article deals with details in regarding of breakable objects in the physics simulation. | | This article deals with details in regarding of breaking single objects apart in the physics simulation. |
|
| |
|
| == Destroying Objects ==
| | For breaking the connection between bound objects, please see the article about [[breakable bonds]]. |
|
| |
|
| 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.
| | == How to Destroy Objects == |
|
| |
|
| Currently, this is done by setting the following [[:Category:spawnargs|spawnargs]] on one entity:
| | 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. |
|
| |
|
| "broken" "models/darkmod/junk/wbottle01_broken.lwo"
| | Currently, there are two ways to denote that an entity should be destroyed/broken upon ''death'': |
| "health" "20"
| |
|
| |
|
| The [[Spawnarg:health]] sets the amount of damage that needs to be done to the object until it breaks, and the
| | === Setting [[health]] === |
| [[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.
| | By setting the following [[:Category:spawnargs|spawnargs]] on one entity: |
|
| |
|
| Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons or movers that ''damage'' entities.
| | "health" "20" |
| | |
| {{important|headline=TODO|text=
| |
| * 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.
| |
| * Damage needs to be calculated from the impulse, not from a fixed set of "damage" values.}}
| |
|
| |
|
| == Breaking Bonds (Unbinding) ==
| | the entity will be destroyed when the health drops to 0. |
|
| |
|
| [[Image:Bind entities.png|right]] | | The [[health]] sets the amount of damage that needs to be done to the object until it breaks. |
|
| |
|
| It is possible to bind entities together via the [[spawnarg]] ''bind''.
| | 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. |
|
| |
|
| The bound entity is called "slave" (or bindslave), while the entity it is bound to is usually called "master (or "bindmaster").
| | Another drawback is that forces do not translate into damage except in some specially coded exceptions, like hits from weapons or movers that ''damage'' entities. |
|
| |
|
| 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.
| | === Setting [[max_stress]] or [[max_torque]] === |
|
| |
|
| When the force acting on one of the bind-members becomes to strong, the bind should break up. | | When the forces acting on a moveable entity exceed these values, the entity breaks: |
|
| |
|
| {{important|headline=TODO|text=This is currently never the case.}}
| | "max_stress" "50 50 200" |
| | "max_torque" "10 10 100" |
|
| |
|
| === Forces acting on bound entities === | | == What happens when an entity dies? == |
|
| |
|
| To simplify the explanations, we consider here only 2D-forces. The third dimension can then be easily added by using an impulse 3D vector.
| | Depending on which spawnarg is set, different things happen when an entity is broken: |
|
| |
|
| [[Image:Bind_strength_forces_a.png|right|300px]] | | === [[broken]] === |
|
| |
|
| '''Note:''' Any 2D vector (f.i. a force) can be represented by 2 (related) vectors (forces) acting along the X and Y-axis.
| | Setting: |
|
| |
|
| In the following scenario, a bar (slave) is bound to a plate (master). The force F (blue) is here show as two forces F<sub>X</sub> and F<sub>Y</sub>, acting on this slave. Depending on the strength of the attachment and the force, the two objects would then become unbound.
| | "broken" "models/darkmod/junk/wbottle01_broken.lwo" |
| | |
| {{clear}}
| |
| | |
| === Attachment Strength ===
| |
| | |
| [[Image:Attachment strength.png|right|320px]]
| |
| | |
| 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:
| |
| | |
| # 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.
| |
| # 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.
| |
| | |
| | |
| [[Image:Free standing object stability.png|right|320px]]
| |
| | |
| 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:
| |
| | |
| Notes:
| |
| | |
| * 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.
| |
| * Only the force acting along the X axis is considered. Any force along the Y axis would make the bind either stronger or weaker, depending on it's direction (up or downwards in this drawing).
| |
| * A higher F translates thus 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}}
| |
| | |
| [[Image:Bind force and gravity.png|320px|right]]
| |
| | |
| Since the gravity always acts in the same direction, the bind strength becomes dependend on the orientation of the two objects as shown on the right. If the binding force F<sub>B</sub> is smaller than G, the lower object would simply fall off.
| |
| | |
| {{clear}}
| |
| | |
| [[Image:Contact face.png|320px|right]]
| |
| | |
| The force that binds two objects does not only depend on the mass (due to gravity), but on the size of the contact face, and on the strength of the contact (consider glue vs. nails). We simulate this by setting different <code>bind_force</code> arguments for each joint:
| |
|
| |
|
| {{clear}}
| | The [[broken]] sets the model that will replace the default model after the destruction. The entity itself will stay around, but it cannot be damaged any further. |
|
| |
|
| === Torque === | | === def_flinder, flinder_offset, flinder_probability and flinder_count === |
|
| |
|
| Forces acting on a joint also create torsion. If the torsion is bigger than a certain amount, the bind should also break up. This simulates shearing off the bound entity.
| | Setting: |
|
| |
|
| [[Image:Compression force.png|200px|right]]
| | "def_flinder" "models/darkmod/junk/wbottle01_broken.lwo" |
| | "flinder_offset" "0 0 -5" |
| | "def_flinder1" "models/darkmod/junk/glass_shard.lwo" |
| | "flinder_count1" "6" |
|
| |
|
| === Compression ===
| | will result in the bottle spawn one broken lower half bottle, and 6 glass shards. The original entity will be removed from the world automatically. |
|
| |
|
| When the force acting on the joint lies actually in the direction of the binding force, the bond would not break up, as the acting force will just reinforce the joint. However, in reality there is a limit on how much force the connection can carry, and this is more or less related to the strength of the component carrying the load. In the image to the right, the compression force is acting on the part between the ground and the upper part.
| | ''flinder_offset'', ''flinder_probability'' and ''flinder_count'' are optional. |
|
| |
|
| {{clear}}
| | == Todo == |
|
| |
|
| {{important|headline=TODO|text= | | {{important|headline=TODO|text= |
| * Define a maximum force that the part can carry, before it gets destroyed.}} | | * 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. |
| === Pivotpoints/Joints ===
| | * Damage needs to be calculated from the impulse, not from a fixed set of "damage" values.}} |
| | |
| [[Image:Pivot_point_automatic.png|320px|right]]
| |
| | |
| The ''bind_force'' applies at a certain point, the pivot point. Here is an example showing different situations and the different pivot points:
| |
| | |
| In these cases it would be possible to automatically calculate the position of the pivot point, namely if the bind slave and the bind master have one common contact face.
| |
| | |
| {{clear}}
| |
| | |
| | |
| [[Image:Pivot_point_manual.png|400px|right]]
| |
| | |
| However, in the following cases there is either no contact face (the entities are not touching each other) or
| |
| more than one contact face. This means the pivot point would have to be set manually:
| |
| | |
| {{clear}}
| |
| | |
| === Multiple joints ===
| |
| | |
| It is not enough to have one possible bind/joint per object, as the following graphic shows:
| |
| | |
| [[Image:Pivot_point_counts.png|center]]
| |
| | |
| {{clear}}
| |
| | |
| In the first case on the left, there are four objects and four joints, such that each object can be bound to exactly on other object.
| |
| | |
| But by adding one more object, we need now more joints than we have objects, making it nec. that at least one object has more than one bind-partner.
| |
| | |
| === Relaying forces ===
| |
| | |
| Forces/impulses acting on one object need to relayed to each bind partner, through the pivot points. At this point the force needs to be dampened (to simulate stiff joints and friction).
| |
| | |
| {{important|headline=TODO|text=
| |
| Currently, the impulse is always relayed to the '''single''' bind master.
| |
| }}
| |
| | |
| The incoming forces/impulses need also be relayed '''back''' from the bind master to the bind slave.
| |
| | |
| {{important|headline=TODO|text=
| |
| Currently, the impulse is only relayed in one direction.
| |
| }}
| |
| | |
| === Sumary ===
| |
| | |
| To evaluate whether two bound objects should separate, we need to consider the following forces:
| |
| | |
| * G - Depends on the mass of the slave
| |
| * F<sub>A</sub> - the acting force on the slave
| |
| * F<sub>B</sub> - the force that binds the two objects together
| |
| | |
| To define the bind strength in all three dimensions, it must be a vector. This allows us to enforce a stronger bind in one direction than in the others.
| |
| | |
| We then simple add together G and F<sub>A</sub> and check that each component of F<sub>A</sub> is smaller than the respective component of F<sub>B</sub>. If any component is bigger, we consider the bound to be broken and unbind the objects:
| |
| | |
| * Unbind if G + F<sub>A</sub> < F<sub>B</sub>
| |
|
| |
|
| == See also == | | == See also == |
|
| |
|
| | * [[Breakable bonds]] |
| * http://en.wikipedia.org/wiki/Lever | | * http://en.wikipedia.org/wiki/Lever |
| * http://en.wikipedia.org/wiki/moment_%28physics%29 | | * http://en.wikipedia.org/wiki/moment_%28physics%29 |
|
| |
|
| {{physics}} | | {{physics}} |
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 breaking single objects apart in the physics simulation.
For breaking the connection between bound objects, please see the article about breakable bonds.
How to Destroy 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.
Currently, there are two ways to denote that an entity should be destroyed/broken upon death:
By setting the following spawnargs on one entity:
"health" "20"
the entity will be destroyed when the health drops to 0.
The health sets the amount of damage that needs to be done to the object until it breaks.
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 or movers that damage entities.
When the forces acting on a moveable entity exceed these values, the entity breaks:
"max_stress" "50 50 200"
"max_torque" "10 10 100"
What happens when an entity dies?
Depending on which spawnarg is set, different things happen when an entity is broken:
Setting:
"broken" "models/darkmod/junk/wbottle01_broken.lwo"
The broken sets the model that will replace the default model after the destruction. The entity itself will stay around, but it cannot be damaged any further.
def_flinder, flinder_offset, flinder_probability and flinder_count
Setting:
"def_flinder" "models/darkmod/junk/wbottle01_broken.lwo"
"flinder_offset" "0 0 -5"
"def_flinder1" "models/darkmod/junk/glass_shard.lwo"
"flinder_count1" "6"
will result in the bottle spawn one broken lower half bottle, and 6 glass shards. The original entity will be removed from the world automatically.
flinder_offset, flinder_probability and flinder_count are optional.
Todo
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.
- Damage needs to be calculated from the impulse, not from a fixed set of "damage" values.
See also