3D RAD HOME PAGE




How to import your 3d models into 3D Rad.
How to enable collision detection and physics for them,
without typing a single line of code!

Index:

   ADDING CUSTOM ARTWORK TO THE SKINMESH LIBRARY
   REPLACING THE DEFAULT ARTWORK WITH YOUR OWN
   NORMAL MAPPING / BUMP MAPPING
   ENVIRONMENT MAPPING
   LIGHT/SHADOW MAPS, TEXTURE MIXING
   MODELING GUIDELINES
   BONE-BASED ANIMATION
   FRAME-BASED ANIMATION
   MODELING VOLUMETRIC SHADOWS
   SHADOW MODELING REMARKS
   SHADOW MODELING GUIDELINES
   MODELING RIGID BODIES (PHYSICS)
   USING SKINMESH OBJECTS AS ASPECT FOR A RIGIDBODY OBJECT
   POLYGONAL RIGID-BODIES
   RIGID-BODY MODELING REMARKS
   DYNAMIC POLYGONAL RIGID BODIES (MOVABLE PLATFORMS ETC)
   COLLISION DETECTION BETWEEN POLYGONAL RIGID BODIES
   FREQUENTLY ASKED QUESTIONS


ADDING CUSTOM ARTWORK TO THE SKINMESH LIBRARY

Launch 3D Rad, press [Ctrl]+[N] to start a new empty project.

Select

Object -> Install Custom SkinMesh

to create a new aspect for the SkinMesh object.



Type a name for the new visual (for example 'TestModel')
and click the Save button.



Confirm the information dialog and then add an instance of the SkinMesh object to the empty project by selecting Object -> Add and double-clicking the SkinMesh icon.



The default aspect for the SkinMesh is a yellow fish.



You can select the new 'TestModel' aspect instead, in the property dialog for the SkinMesh object (press Enter).



Click the Change button and select TestModel.
Then click OK to close the property dialog.



The new aspect uses default artwork (a purple fish).

You can replace the purple fish with a custom made 3d model by replacing the default DirectX� (.x) files in the

C:\3D Rad\3DRad_res\objects\SkinMesh\data\TestModel\

folder with your own files.

Finding a way to export 3d models from your modeler to DirectX� (.x) file format is therefore a critical step.

If your modeler cannot natively export to .x file format, you may still be able to use it with 3D Rad by finding a plug-in for it or by exporting to a file format that can be converted to .x file format with additional 3d tools.

Information on how to export to DirectX (.x) file format is available for the following modelers: 3D Studio Max, Maya, Lightwave, GMax, Blender, FragMOTION, L3DT, T.ED, Google SketchUp.


REPLACING THE DEFAULT ARTWORK WITH YOUR OWN

Minimize the 3D Rad window and open your favorite 3d modeler.

For the purpose of this tutorial, create a simple model with at least one texture. Texture image format can be .bmp, .jpg, .dds, .png or .tga.

Make sure all polygons are texture mapped. The model can include a skeleton and bone-based animation (rigging), but it is recommended that you try first with static geometry, in order to test your export procedure.

TIP: when testing exporting of animated models, try first with a very simple skeleton structure created in the modeler itself. Leave exporting complex animations created by others and/or with other tools or special plug-ins for when you have determined what works for simpler models.

1. Export the test model to the C:\3D Rad\3DRad_res\objects\SkinMesh\data\TestModel\

Make sure the file name is '000_mesh.x', so that it replaces the existing .x file in the folder.



Note that you must also copy, to the same folder, all texture files that are associated with the mesh's .x file. In the example the texture is 'TestModelTexture.bmp'.

Important: any textures in sub-folders or stored elsewhere are ignored, even if their full path is provided in the .x file.

TIP: point your modeler to the destination folder since the beginning of your modeling session. Name your model '000_mesh'. Save textures, work files and temporary assets there. Having all files related to the new model in the right folder already and with proper names will make a lot of things easier. In the picture above you can see the .lwo work file generated by Lightwave 3D, the 3d modeler used for this example. Extra files like this will not cause any problem as 3D Rad will only use the .x files and their textures.

2. Go back to 3D Rad and press [R] to refresh the artwork for the SkinMesh object, reloading the modified files. After a short delay, you should see your model in place of the default purple fish.



If your can't see the model, try zooming in/out (mouse wheel), to see if it is much bigger/smaller than expected, or if it is displaced.

If the model is wrongly scaled, go back to the modeler and check that the unit is set to meters (if applicable) and that the size of your model is reasonable. If your modeler doesn't support absolute units or it alters the model size while exporting, try simply scaling your model and exporting it again. Trial & error will help determine a scaling ratio to use for all future models (you can use the SkinMesh's aspect named 'Andro' as a reference; the character is 2 meters tall).

If the model is displaced in 3D Rad space, make sure that, in your modeler's space, it is at the world center (world axes origin), when you export it.

If, in 3D Rad, the model is not rendered at all, or an error message appears, your modeler is likely generating an .x file with invalid or unsupported information in it. Try reviewing your export parameters (if applicable) or please seek help at the community forum, where other users may suggest the right export procedure for your modeler.

3. In the picture above, circled in red, you can see a visual artifact caused by the volumetric shadow still being from the default purple fish.

The shadow caster is an additional 3d model. In the folder it is listed as '000_shadow.x'. Please see below for information on how to model this component of your custom SkinMesh objects.

If you don't want your model to cast a shadow, simply remove the '000_shadow.x' file from the folder


NORMAL MAPPING / BUMP MAPPING

If your artwork requires a normal-map, you must include it as an image file named '000_nm.ext' where '.ext' can be one of the following: .bmp, .jpg, .dds, .png, .tga.

To enable normal mapping for the SkinMesh, open the property dialog for it and select a 'bumpy' shader.


ENVIRONMENT MAPPING

If you want your new visual aspect to support reflection effects, you can provide a cube-map file named '000_em.dds' as well. A default cube-map is created in the folder for you.

To enable reflections for the SkinMesh, open the property dialog for it and select a non-default shader. Then check the 'Enable environment map' option.

NOTE: the resolution of the cube-map determines the quality of the reflected image, including when dynamic reflections are enabled.


LIGHT/SHADOW MAPS, TEXTURE MIXING

To add additional texture detail to your model or achieve texture-mixing-based effects, you can put an additional .x mesh and its textures into the data folder. The file name for the additional mesh must be '000_tmix.x'.

NOTE: make sure the Depth Sorting option for the SkinMesh object is checked.

Note that bone-based animation is not supported for the '000_tmix.x' model so, because texture mixing is only possible when the geometries of '_mesh.x' and '_tmix.x' models match perfectly, this feature should only be used for frame-based animations (see below) or static models.

TIP: texture mixing can also be achieved by creating two identical SkinMesh objects, placed at the exact same position in the space. The second SkinMesh using a different texture (for example a 'shadow-map' or 'light-map') and 'transparent' rendering settings.


MODELING GUIDELINES

When making your own 3d models, keep in mind that:

  • the world center in your modeler will be the natural center of the object when the 3d model is imported to 3D Rad space. The center is used as a default reference for various editing functions in 3D Rad. Make sure it is conveniently placed.


  • the side of your models which you consider as the front should face towards world's +Z axis, when the object is not rotated, in 3D Rad space. In your 3d modeler, make sure that your models are oriented to match this guideline. Failing to do so may generate a lot of confusion! Note that some modelers don't use the same coordinate system as 3D Rad, so, for instance, 3D Rad's +Z world axis is +Y world axis in 3D Studio Max�.



  • Also make sure that the model:

  • only uses texture images in .bmp, .dds, .dib, .jpg, .png or .tga format. Note that certain old video-cards only support texture images that are power-of-two sized. For example 256x256, 512x256, 128x1024, etc.


  • does not include isolated vertices, degenerated faces, etc.


  • does not include very big triangles. Triangle side length should never be greater than 10-20 meters, in order to ensure proper computation and rendering.


  • NOTE: make sure that DirectX� templates, texture mapping, material and vertex normal data are actually exported to the destination .x file.

    NOTE: make sure that the .x file and all its texture image files are in the same folder. 3D Rad will ignore textures that are stored outside the .x file folder.


    BONE-BASED ANIMATION

    Some 3d modeling tools allow you to save bone-based animations in the .x file.

    Because 3D Rad can play this kind of animation well and fast, this is the preferred method you should use for your animated 3d models.

    3D Rad can also play .x files that include multiple bone-based animation sets for the same model, and smoothly switch among them run-time.

    For an example of this please load and launch the SkinMeshDemo.3dr project (in 3D Rad, select File -> Open).

    If your 3d modeling tool cannot export multiple animation sets to an unique .x file you can save the same model to different .x files, one file for each animation set, but make sure the geometry is exactly the same for all!

    You can then combine them to an unique .x file by using the free MView utility (Animation -> Add Animation menu function), or Fragmotion (free), or manually, by opening the .x file with a text editor and copying/pasting the AnimationSet blocks from all files to one of them.

    The AnimationSet blocks must be copied one after the other in the .x file and each block must have an unique name.

    Note that you will have to generate your .x files in ASCII format in order to manually edit them.

    TIP: when exporting animated models, keep in mind that 3D Rad only supports 'matrix-based' animations. Make sure this option is checked if your modeler or exporter plugin supports it.

    TIP: if your animated models play in DirectX file viewers like MView (see above) but not in 3D Rad, try opening them in MView and saving them back. This usually fixes the problem.


    FRAME-BASED ANIMATION

    Another way to achieve 3d animation in 3D Rad is by making a sequence of 3d models. They can be rendered one after the other and perform the animation.

    This is a powerful technique, especially because each model (each animation frame) can have its own geometry, textures, normal map and even shadow caster!

    All you have to do to use this technique is save your sequence of .x files (and related textures) to the custom folder for the new visual aspect by making sure the file names are numbered as a continuous sequence (with '000_mesh.x' being the first frame, '001_mesh.x' the second and so on).

    For a demonstration of this technique please load and launch the SkinMeshFrameAnimationDemo.3dr project (in 3D Rad, select File -> Open). You can also examine the files in the

    C:\3D Rad\3DRad_res\objects\SkinMesh\data\Capsule

    folder for an example.


    MODELING VOLUMETRIC SHADOWS


    A 3d model can be used as a shadow caster (the '000_shadow.x' file, see above) for a custom SkinMesh visual, as long as it is made of just closed hulls.

    Models that aren't perfect closed hulls will produce rendering artifacts, if used as shadow geometry.

    A 3d model, made of just triangles, is a closed hull if:

  • it completely encloses a portion of space.
  • all triangle-edges are shared by two triangles.



  • For example, the second mesh in the picture above is NOT a closed hull because it breaks both the rules. It doesn't completely encloses a portion of space and three edges aren't shared by two triangles.


    Note that despite the 'hole', the torus on the left, in the picture above, IS a closed hull, because it completely encloses the space inside the 'looping-pipe'. While the torus on the right is not a closed hull due to the missing triangles.


    The open box on the left, above, is a closed hull. As a matter of fact, the dimension (thickness) of the box sides is not null, and the narrow space inside them is completely enclosed. Also, all edges are shared by two triangles.

    Instead, the box on the right is not a closed hull because the sides are flat. And there are four edges that aren't shared by two triangles.


    Another confusing case is depicted above. The box completely encloses a portion of space, but there are six edges that aren't shared by two triangles. The vertical edge on the left and the one in the middle of the picture are degenerate triangles really. The long edge is shared by 3 triangles, so the second condition for a closed-hull is not met.


    SHADOW MODELING REMARKS

  • For static meshes, there is no need for the shadow caster model to match all details of the visible mesh model.

    For example, if it is a subset of the visible mesh, this will reduce the number of shadow-polygons to render.

    However, because the shadow is usually cast onto the corresponding visible mesh too (self-shadow-casting), exactly matching the geometries will ensure a consistent effect in most cases.

    Alternatively, you can prevent shadows (including self-shadows) to affect a SkinMesh by checking the 'No shadow' option on the SkinMesh object's property dialog


  • For bone-animated meshes, because the shadow model doesn't support bone-animation, it should have a 'neutral shape', like for example a sphere, to make the difference less noticeable.

    Alternatively, by using the technique demonstrated in SkinMeshBoneDemo.3dr project, shadow-caster-only SkinMesh objects can be attached to individual bones of the animated character to produce a composite, convincing animated shadow. In 3D Rad, press [Ctrl]+[O] to see a list of available demo projects.


  • Surfaces, for shadow caster models, should never precisely match (overlap). Matching surfaces, like for example the sides of two cubes precisely put one upon the other, will cause rendering artifacts. You can usually work this problem around by separating or intersecting a little bit the two geometries.


  • Objects receiving shadows should cast shadows themselves. Consider the following case:



    When a caster mesh is provided for both the ball and the wall (left), the visual effect is always proper. But when a caster isn't provided for the wall (right), chances are that the ball shadow is also cast on the dark side of a the wall. It also isn't properly cast onto the ground either.


  • Volumetric shadows can affect frame-rate on slower systems. You should only model a shadow caster for objects and scenery features that actually cast a shadow.

    In most cases, you can use shadow mapping in place of volumetric shadows.



  • SHADOW MODELING GUIDELINES

    When making your 3d shadows, make sure that the model:

  • is made of perfectly closed hulls.


  • does not include very big triangles. Triangle side length should never be greater than 10-20 meters, in order to ensure proper computation.


  • doesn't includes joined (exactly-overlapping) surfaces. Matching surfaces, like for example the sides of two cubes precisely put one upon the other, will cause rendering artifacts. You can usually work this problem around by separating or intersecting a little bit the two geometries.


  • has no texture (this is not mandatory, but can reduce file size).



  • MODELING RIGID BODIES (PHYSICS)


    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.

    In 3D Rad, press [Ctrl]+[N] to start a new empty project.

    Select

    Object -> Install Custom RigidBody (box/sphere-group)

    to create a new shape for the RigidBody object.



    Name the new shape 'TestModel', click the Save button and confirm the information dialog. Then add an instance of the RigidBody object to the empty project by selecting Object -> Add and double-clicking the RigidBody icon.



    The default aspect for the RigidBody is a low-poly boulder.

    To select the new 'TestModel' aspect instead, in the property dialog for the RigidBody object, click the Change button and select TestModel. Then click OK to close the property dialog.



    The new aspect uses default artwork (a group of 3 spheres).

    To test this new RigidBody, add another RigidBody object to the project an select Platform100m as its shape (Change button on its property dialog). Then add a G-Force object and link your new RigidBody to the platform RigidBody and to the G-Force by checking off these items in the list (left of screen) while the new RigidBody is selected (red in the list).

    You should get something like the following:



    Press the [space-bar] to launch the simulation and test collision detection and physics for the new RigidBody shape.

    By replacing the default DirectX� (.x) files in the

    C:\3D Rad\3DRad_res\objects\RigidBody\data\TestModel\

    folder with your own files, you can customize the shape (and physics properties!) for the new RigidBody.



    IMPORTANT! For the next steps you will need to know how to successfully export your 3d models as DirectX� (.x) files. Please see above for details.

    1. In your modeler, create a group of 2 or 3 spheres of different sizes. The globes can intersect (overlap) or be far apart, but they must not be stretched or deformed in any way. Each sphere should be made of no more than 30/40 vertices (about 50/60 triangles).

    Add 2 or 3 boxes as well, making sure that they are made of 8 vertices and 12 triangles in total. The boxes can intersect with spheres and other boxes and can be rotated in any way, but it is important that the edges are all perfectly perpendicular (90 degrees) at the corners. Deformed boxes will not be recognized by 3D Rad.

    Make sure all surfaces in the model are color-only (no texture or special settings) and that no extra information, like bones, animation or hierarchy, is part of the model.

    Export your model to the

    C:\3D Rad\3DRad_res\objects\RigidBody\data\TestModel\

    folder

    Make sure the file name is 'rigidBody_.x', so that it replaces the existing .x file in the folder.

    2. Go back to 3D Rad and press [R] to refresh the artwork for the RigidBody object (make sure it is the selected element).

    Note that the visible shape of the RigidBody doesn't change, but its behavior on collision does, according to the shape of the box/sphere-group model you have just made and exported.

    The 'rigidBody_.x' model is the invisible geometry that 3D Rad uses for collision detection.

    3. The visible aspect is an additional 3d model (.x file). In the folder it is listed as 'rigidBody_mesh.x'. For the default model, the geometry is identical to the invisible geometry. This provides a consistent visual reference.

    However, the 'rigidBody_mesh.x' model can be anything. It can be texture mapped (one single texture) and it can cast a shadow ('rigidBody_shadow.x' file).

    The 3 pictures below show an example of box/sphere-group based RigidBody with non-box/sphere-group based aspect. The rigidBody_.x geometry (invisible in 3D Rad), its rigidBody_mesh.x file (visible part) and the two models compared.






    TIP: the collision detection model (box/sphere-group, rigidBody_.x file) doesn't have to match all details of the visible mesh model. To avoid hitting performance, you should use as few boxes/spheres as possible. You should not aim to 'fill' the mesh with boxes/spheres. The goal is only placing boxes/spheres where you need collision detection (for your specific model, in your specific project). In general, boxes/spheres that are larger or smaller than the visible features are perfectly acceptable, and the difference is unnoticeable in the finished simulation.

    4. In order to perform physics, 3D Rad needs additional geometry which describes how the mass is distributed within the RigidBody shape. This is automatically created by default ('rigidBody__.x' file, note the double underscore character).

    You can make your own mass model for the RigidBody by keeping in mind the following guidelines:
  • the geometry can be any shape (polygonal), but it must be made of closed hulls (see above)
  • avoid very big and very small triangles
  • try to minimize the polygon count. Usually a simple shape like a box, a cylinder or a sphere will work just fine, regardless of the visible model's shape


  • The mass distribution model doesn't have to match the shape of the visible mesh model. Actually, you may often want to model it as a different geometry (hence the need to have a different .x file for it).

    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 (box/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.


    USING SKINMESH OBJECTS AS ASPECT FOR A RIGIDBODY OBJECT

    Because the RigidBody object doesn't support advanced rendering, the 'rigidBody_mesh.x' is usually modeled as simple reference geometry. For the production version of the game, one or more SkinMesh objects, attached to the RigidBody as shown in the introductory tutorial, are typically used instead.


    POLYGONAL RIGID-BODIES

    For RigidBody objects that do not move (terrain, buildings, roads etc), the collision detection geometry can be based on polygonal 3d models, instead of box/sphere-groups.

    In 3D Rad, you should still have the test project with a platform and your new RigidBody rebounding on it. If not, create a similar project and then select

    Object -> Install Custom RigidBody (polygons)

    to add a new polygonal shape to the RigidBody object library.



    Give a name to the new shape and, when the operation is complete, double-click the platform RigidBody in the Object List (left of screen), click the Change button and select the aspect you have just created.

    After closing the dialog you should see something like the following:



    The default aspect for a new polygonal RigidBody is a simple bridge. Reposition the object if necessary, then press [space-bar] to verify that collisions work as expected.

    By replacing the default DirectX� (.x) files in the new RigidBody data folder with your own files, you can customize the shape of the new geometry.



    1. In your modeler, create a mesh resembling a terrain, or a building, or any other static structure you would like to test.

    For your first test, make a simple model by using polygons that have an average size (sides) between 0.2 and 30 meters. Avoid heavily stretched polygons.

    Make sure all surfaces in the model are color-only (no texture or special settings) and that no extra information, like bones or animation, is part of the model.

    Export your model to the new geometry's data folder two times, as 'rigidBody_.x' and as 'rigidBody_mesh.x', in order to replace the existing .x files in the folder.

    Keep in mind that, similarly to what we have discussed above, about box/sphere-group based geometry, 'rigidBody_mesh.x' can be a texture mapped mesh, with additional details that you aren't interested in checking for collisions.

    As for the shadow caster, you can either model features of your static mesh as closed hulls and export the geometry as 'rigidBody_shadow.x' (to overwrite the default), or you can simply delete the 'rigidBody_shadow.x' file.

    2. To view and test your artwork, go back to 3D Rad and press [R] to refresh the static RigidBody object (make sure it is the selected element).


    RIGID-BODY MODELING REMARKS

    1. Make sure the collision detection model does not include small polygons (average side less than 0.2 meters), heavily stretched polygons (one side's length less than 5% of polygons's perimeter) or big polygons (average side length greater than 50 meters). Due to finite CPU math, collision detection for these kind of polygons may be inexact, causing unstable simulation.

    A typical problem caused by big polygons are 'jittering' objects that are supposed to rest on the ground instead.

    A typical problem caused by small/stretched polygons is poor frame-rate.

    2. Avoid overlapping surfaces (especially if they face opposite directions!) and thin volumes (like thin walls).

    These structure may cause collision detection to fail, letting fast objects pass through them.

    The most robust surface is a one-sided surface.

    If you need to make walls or ceilings, make sure their thickness is adequate to the speed of the objects colliding with them.

    3. Box/sphere-group-based RigidBody objects 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:





    FREQUENTLY ASKED QUESTIONS


    Q. I have modeled a large terrain by using a specialized application. How do I import it to 3D Rad?

    A. In 3D Rad, you can implement terrains as visible meshes (SkinMesh objects) and invisible collision detection geometry (RigidBody objects) combined, as you do for any other 3d object supporting collision detection. Therefore you need to find a way to export the terrain model to .x file format, as discussed in the tutorial above. If the terrain is very large, you should consider splitting it to smaller modules or sectors. This will allow you, in the production version of your game, to achieve optimal frame-rates by dynamically hiding/disabling the sectors that are out of view.

    Q. If RigidBody+SkinMesh is the recommeded technique to implement custom terrains, then what is the Terrain object for? Can I modify it?

    A. The Terrain is a pre-made object you can use to quickly setup a nice enviroment for your tests and prototypes. It wasn't designed to be customizable.

    Q. A SkinMesh object can only use one render mode at a time. My custom model is a knight with dull skin and shiny armor. If I use a reflective shader the armor looks good, but the skin gets reflective as well, which is wrong.

    A. Please keep in mind that the SkinMesh object is simply a component, a single visual module. Typically, you use multiple Skinmesh objects to compose a game element, like a character. To achieve maximum performance, you should design your models so that they can be imported by using as few SkinMesh objects as possible, but, when the mesh must have multiple surface characteristics, there is no overhead in using multiple SkinMeshes, compared to other products that do the splitting while rendering, switching shader on-the-fly.

    Q. I know SkinMesh objects can be 'attached to' and carried about by other objects, but can I attach a SkinMesh (e'g' a sword) to an animated character's bone (e.g. the arm's bone)?

    A. Yes, please see the SkinMeshBoneDemo.3dr project for a demonstration. In 3D Rad, press [Ctrl]+[O] to see a list of available demo projects.

    Q. I want my bone-animated character to walk by using the pre-defined animation sequence I created, but I also want to interactively control one or more of her bones while she walks, for example to turn her head based on user input. Is this possible?

    A. Yes it is. Please see the SkinMeshBoneControlDemo.3dr project for a demonstration.

    Q. I want monsters and props in the scene to respond realistically to collisions with my bone-animated character's limbs and/or objects linked to them, like a swinging sword.

    A. 3D Rad allows you to attach RigidBody objects to individual bones of your animated characters. These RigidBodies will then interact (collide) with any other rigid-body based object in the scene. For an example, please see the SkinMeshBoneRigidBodyDemo.3dr project for an example.