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


MAKING A SKINMESH OBJECT
FROM YOUR 3D MODELS

The SkinMesh object includes a library of visual aspects that can be accessed by clicking the Change button on the property dialog for a SkinMesh object in your project.

If you can use a 3d modeling software, you can add your own 3d models to this library.

This tutorial is about making custom visual aspects for the SkinMesh object 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.

Once you have your 3d artwork in the form of one single .x file with all its textures, you can add it to the SkinMesh library of visual aspects as follows:

1. In Windows desktop, select Start -> My Computer, browse to the

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

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



2. Your own 3d models and textures must now be copied into this new folder and properly renamed, in order to become a new visual aspect in the SkinMesh library.



Your 3D model must be in DirectX® (.x) file format and the file name must be '000_mesh.x'.

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 they are 'walkingMonsterArmour.dds' and 'walkingMonsterSkin.dds'.

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

3. If you add a volumetric shadow model (see below), make sure that its file name is '000_shadow.x'.

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

5. If you want your new visual aspect to support reflection, you must also provide a cube-map file named '000_em.dds'. You can simply copy this file from one of the default sub-folders (SkinMesh 'data' folder) if you don't want to make one yourself.

6. 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 that bone-based animation is not supported for the '000_tmix.x' model so, because perfect 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 or static models.

7. Browse to the

C:\Program Files\3D Rad\3DRad_res\objects\SkinMesh\data\index

folder and clone one of the existing .jpg files there (select a file, press [Ctrl]+[C] and then [Ctrl]+[V]. Give the new file the same name as the new folder created previously (see above).



This new .jpg file is the icon for the new item that will be displayed in the SkinMesh library selector. You can edit the image file by using a 2d paint program, if you like.

8. When all the files have been copied and renamed properly, your new custom object should be available among all others in the SkinMesh object library.


MODELING GUIDELINES

As said, all your custom 3d geometry must be exported to DirectX® (.x) file format in order to be used in a 3D Rad project.

In this article we assume you know how to use your 3d modeler to make your own 3d texture mapped, bone-animated models and how to export them to DirectX® (.x) file format.

Tips about exporting 3d models to DirectX® (.x) file format are available for 3D Studio Max®, Lightwave®.

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:
  • is made of triangles only. Any quad or superior polygon must be split to triangles. Most modelers provide a 'triangulate' function.
  • has a texture map assigned to all triangles (non-textured faces are not supported). Texture images should be power-of-two sized. For example 256x256, 512x256, 128x1024, etc. Image format must be .bmp, .dds, .dib, .jpg, .png or .tga.
  • 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.
  • does not have more than 65536 faces.


  • 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 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 exacly the same for all!

    You can then combine them to an unique .x file by either using the free MView utility (by Microsoft) 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.


    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 saving 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 project (in 3D Rad, select File -> Open). You can also examine the files in the

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

    folder for an example.


    MODELING VOLUMETRIC SHADOWS


    Any 3d model can be used as a shadow caster in 3D Rad, 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 half-shared by 3 triangles, so the second condition for a closed-hull is not met.

    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.


  • 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.


  • 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.


  • Guidelines

    When making your 3d shadows, make sure that the model:
  • is made of triangles only (triangulate).
  • 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).


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