WHAT IS
3D RAD?
CLICK HERE
TO FIND OUT!


PHYSICS-CAPABLE OBJECTS
FROM YOUR 3D MODELS



This tutorial is about making custom RigidBody objects from your own 3d models made by using any 3d modeling application which can export to DirectX (.x) file format or a format that can be converted to it by using additional 3d tools.

1. To add a new, custom object to the RigidBody library, in Windows desktop, select Start -> My Computer, browse to the

C:\Program Files\3D Rad\3DRad_res\objects\RigidBody\data

folder on your computer and create a new sub-folder inside it. Give it a name of your choice.

2. Your own collision-detection 3d models (.spg, or .ply/pol, see below) must be copied into this new folder. Their filename must be, either rigidBody_.spg or rigidBody_.ply/pol.

If you use .ply/pol files instead of .spg, collision detection will be based on a polygonal model instead of a group of spheres.

If your ply/pol-based body is dynamic (see RigidBody help file for details) and you want accurate physics, you must also add a 'rigidBody_mass.x' file, which is a 3d model made of closed hulls, describing mass distribution.

However, keep in mind that collisions between two ply/pol-based objects are not supported and are ignored.

Finally note that Virtual Editor scaling is not supported for the RigidBody object.

3. You will also need a placeholder mesh to visualize the RigidBody object in the editor.

You can simply copy the default boulder mesh files from the Boulder folder (rigidBody_mesh.x, rigidBody.jpg, rigidBody_shadow.x), or you can make your own.

The name of the file for the .x mesh must be 'rigidBody_mesh.x'.

Note that you must also copy to the same folder all texture files that are associated with the mesh's .x file.

If you want to also make the volumetric shadow model, make sure that its file name is 'rigidBody_shadow.x'.

IMPORTANT! If you have provided .spg or .ply files for your custom rigid-body object, make sure the Use bounding sphere as body option is NOT checked. See RigidBody help file for details.


MODELING GUIDELINES

In a 3D Rad project, rigid-bodies are the invisible solid structure of all 3d objects supporting physics.

Collision detection and dynamics simulation are determined by this invisible geometry, which is based on custom 3d models you can make by using your favorite 3d modeling application.

MODELING STATIC BODIES

Any polygonal 3d model in DirectX® (.x) file format can be converted, by using the 3Impact Converter utility, to a special format (ply/pol extension) which supports collision detection.

In a 3D Rad project, ply/pol files can be used to implement accurate collision detection and response for your own static geometry like terrains, buildings, racetracks and so on.


When making static geometry to convert, make sure that the model:
  • is made of triangles only (triangulate).
  • has no texture.
  • does not include very big triangles (see remarks below).


  • NOTE: make sure that DirectX® templates and material data are actually exported to the destination .x file.

    NOTE: there is no need for the collision model to match all details of the visible geometry. Because collision detection is slow to process, you can, for instance, only include the geometry that will be actually colliding with dynamic objects.

    To proceed with the conversion, run the 3Impact Converter by double-clicking the icon on your desktop
  • select 'Generate polyhedron-based body...' (F1)
  • browse to the folder containing the .x file you want to convert and double-click it
  • browse to the destination folder and click OK


  • Before starting the conversion, the program may request you to specify a conversion resolution, in meters. In order to speed up collision detection computation, the physics engine will process the model after breaking it into sectors approximately the size of the specified resolution.

    For best results, the resolution value should be about the size of an average triangle in the source 3d model.

    Bigger values tend to reduce the size of ply/pol files and slow down processing.

    Smaller values tend to increase conversion time and size of ply/pol files. They also tend to make processing faster, unless the size of the ply/pol files is too big for the system.

    NOTE: the converter will not ask you for a resolution if it is specified in the .x file name. A name with resolution must be in the form 'name_R.x', where R is a value specifying a 'resolution' in meters. Examples of valid names with resolution are 'castle_5.x', 'racetrack_7.23.x'.

    REMARKS

    1. Make sure the collision detection model does not include big triangles. Triangle side length should never be greater than 10-20 meters. Due to finite CPU math, collision detection for big triangles may be inexact, causing unstable simulation. A typical problem caused by big triangles are 'jittering' objects when they are supposed to rest on the ground instead.

  • Make also sure that the collision detection model is exported to .x without any hierarchy. Some 3d tools can export geometry as a hierarchy of meshes. Some of the meshes in the hierarchy can be null and this may cause collision detection problems.


  • 2. Dynamic objects (see below) will successfully collide with all triangles in the static, collision model geometry, however they will not properly collide with triangle edges, if they are not shared with another triangle.

    For example, consider the following case: one-triangle static object colliding with a ball.


    The collision will not be detected properly if the sphere hits the edge of the triangle. The problem depicted above can be fixed by modeling the triangular static body as follows instead:


    3. Ply/pol files may require huge amount of memory. The amount of memory used by a collision model is more or less proportional to the volume of the bounding box enclosing its geometry.

    Using one single collision model for a wide scenery isn't recommended.

    You should always try to split up the source model of a very big scenery into a number of smaller models, each saved as a different .x file, converted to distinct .ply files and added to your 3D Rad project as distinct objects.

    MODELING DYNAMIC BODIES

    Collision detection for non-static objects (like a RigidBody when its mass is non-zero) requires collision models based on spheres.

    1. For example, to make the collision-model for an object like the following:




    2. Make a new model made of just spheres,


    by using the original model as a reference.




    3. Save the sphere-group model as an .x file, named for example, 'mymodel_.x'. It can be the name of the original model followed by '_' (underscore).

    NOTE: using spheres that are smaller than 1 centimeter is not recommended. Very small spheres may not be properly detected by the conversion utility (3Impact Converter, .spg creation option). Use no more than 30/40 vertices to model very small spheres, to increase the chances for a successful detection.

    4. From the original model, make a third model. It will be used by the engine as a reference to compute mass data for the new dynamic body. In order to properly compute dynamics behavior, the engine must know how the mass is distributed in the body.


    Make sure that the model:
  • is made of triangles only (triangulate).
  • has no texture.
  • is made of perfectly closed hulls.
  • does not include very big triangles.
  • does not have more than 65536 faces.


  • 5. Save the mass model as an .x file, named for example 'mymodel__.x'. It must be the name of the previous sphere-group model ending with '__' (two underscores).

    6. Run the 3Impact Converter by double-clicking the icon on your desktop
  • select 'Generate sphere-group-based body...' (F2)
  • browse to the folder containing the sphere-group _.x file you want to convert and double-click it. Make sure you do not click the __.x (mass-model) instead!
  • browse to the destination folder and click OK to generate the .spg file


  • REMARKS

  • There is no need for the collision detection model to match all details of the visible mesh model. A rule of thumb is to use bigger spheres to form a rough shape and then add smaller spheres to fill corners and small details that are likely to collide with other objects and the scenery.
  • There is no need for the mass distribution model to match the shape of the visible mesh model either. Actually, you may often want to model it as a different geometry. Keep in mind that 3D Rad will use the mass model as a reference to determine how the mass is distributed in the body. For example, the mass model for a plane can be like



    As a matter of fact, the mass of the fuselage is bigger than the mass of the wings. Where the mass model provides a bigger volume, 3D Rad will assign a denser mass to the body.


  • Remember, the mass model has nothing to do with collision detection. It is the collision detection model (sphere-group) that determines where a body is solid and where it is not. The mass model, instead, only determines what parts of the body weight more and what parts are light.