TUTORIAL: Improving the physics model by using multiple submodels - by Nameless Voice
Nameless_Voice on 23/9/2004 at 01:07
I just wrote this simple tutorial on how to slightly improve Thief's physics on long, awkard objects (such as shovels), by using multiple submodels.
You can find a colour-coded HTML version (
http://www.wearytaffer.com/NV/Tutorials/PhysModels.htm) here.
Improving the physics model by using multiple submodels
This tutorial modifies the archetypes, and therefore needs a custom gamesys.
In this tutorial, I will explain how to improve the physical models of some of the more complex items in Thief.
For this example, I will concentrate on the standard Shovel (-479) object.
As you have probably noticed, if you pick up a shovel, and then drop it again, most of its model falls through the floor, until it reaches the approximate centre, where it rotates around to lie on its side.
This is because the shovel object has one small physical model at its centroid. To see it, go to the console (shift+;) and type show_phys_models - you will see a small blue circle at the shovel's centre.
Thief only supports four shapes for physical models. They are:
Sphere: a simple sphere-shaped physical model.
Sphere Hat: Very similar to Sphere, but it seems to be slightly square around the edges. You can stand on these without sliding off.
OBB: A cube-shaped physical model, which can be stretched to any size. Although objects can collide with them, they do not collide with other objects when thrown/dropped, making them only useful for static objects, such as tables.
None: No physics model. You're usually better off not adding any Physics properties to the object or its archetype in the first place. Using this physics model can easily cause Thief 1 / Gold to crash.
In order to improve our shovel's physics, first find the Shovel (-479) archetype, and then change its Physics->Model->Type property. Set the # Submodels to 2. This gives the object a second physics sphere.
Now, go to the Physics->Model->Dimensions property, and set it up as follows:
Radius 1 0.20
Radius 2 0.20
Offset 1 X 0.00 Y 0.00 Z 0.00
Offset 2 X 0.20 Y 0.00 Z -2.20
Point vs Terrain False
Points vs Not Special False
By doing so, you have changes the size of both the spheres that make up the physical model, and offset the second one by -2.20 units vertically, so that it is near the blade at the bottom of the shovel.
For the shovel, an X offset of 0.20 makes things work much better, as the shovel model is not quite straight.
The shovel still lands oddly, though, so add the Physics->Model->Attributes property and remove -X and +X from the Rest Axes. That will stop the shovel from coming to rest on its X axis, and therefore force it to land properly.
Go into game mode and try it out!
You can add more submodels if you wish, but since you can only control the size and offset of the first two, its anyone's guess exactly what size DromEd will choose to give any subsequent ones.
As you can see, the use of additional submodels greatly increases the realism of certain objects, even if it can take a bit of experimentation to get all the properties right.
Make note, however, that the player can drop items in such a way as to have their lower phyiscal model appear inside a solid, which causes it to be ignored, and the object to drop to the higher sphere.
Sluggs on 23/9/2004 at 01:19
Sound's interesting. I'll try it out later as i'm watching a DVD right now.
Shadowspawn on 23/9/2004 at 02:09
Thanks, :thumb:
I was going to be studying this later in my mission. This will save me quite a bit of time.
azrarhn on 23/9/2004 at 13:34
Great, very handy to know. :thumb:
Dark Arrow on 23/9/2004 at 17:27
I wonder, if we could control the other physical spheres with custom scripts? Some AI's have more than two spheres, but those things are hardcoded.
You should also know that sometimes the second sphere is ignored untill the first one collides with something.
Bumbleson on 26/9/2004 at 06:56
Quote Posted by Nameless_Voice
Make note, however, that the player can drop items in such a way as to have their lower phyiscal model appear inside a solid, which causes it to be ignored, and the object to drop to the higher sphere.
That's something to be also considered when placing objects in Dromed. On many objects the physical (sphere) model is bigger than the poly model. If an object is placed too close to a terrain wall in Dromed, so that the spheres already intersect with the wall, the phys model will be ignored in the game ("walk-through-a-barrel" effect) until the object is moved away from the wall or picked up and dropped again.
LarryG on 1/7/2009 at 17:38
This is great stuff! Thanks, NV.
nicked on 9/11/2016 at 08:16
Bit of necromancy, but I'm struggling to get this to work with any permanence.
I have a book, the model for which is vertical as if it's stood on a shelf, 1 unit high. By default, when you drop it, it sits unnaturally on it's end.
I followed this tutorial, and got it set up so it has 2 submodels with a sphere type, radius 0.2, offset 1 = z 0.3, offset 2 = z -0.3. I set the rest axes to only +Y and -Y. Set Controls to None.
So far, so good - if the object is just placed in the world, it falls to the floor, and rotates to lie on its widest face. You can see both phys models - all hunky dory. However, if I pick up the book, and drop it, the phys model has reverted to one big one, and it just sits on its end again. Even stranger, every time I go into game mode, it re-adds Rotation to the list of Controls.
nicked on 9/11/2016 at 08:22
Aaaand as soon as I posted, I solved it.
Turns out, if you pick it up, it reverts to the physics settings of the archetype. I had only made the changes on the concrete object. As soon as I set all the physics stuff on the archetype, it worked beautifully.