3D Model

Parent element name: hill
Element name: 3dmodel or model

WARNING

You can name element 3dmodel in DSJ4 versions from 1.7.0, model only from 1.8.0.

TIP

Attributes related to skeletal modeling are usually not needed.

TIP

refx, refy and refz attributes values should be set to near the center of the object.

TIP

refbone applies for skeletal modeling.

AttributeTypeDefault valueDescription
idString3D Model Identification
refxFloat0.0Default reference of X coordinate for lighting
refyFloat0.0Default reference of Y coordinate for lighting
refzFloat0.0Default reference of Z coordinate for lighting
refboneStringIdentification of the default reference bone for lighting

Batch

Parent element name: 3dmodel
Element name: batch

TIP

Flexible Vertex Format (FVF) defines which data each vertex will contain when the batch is sent to a rendering pipeline. For further reference go here.

In most cases, it's enough to set fvf attribute value equal to 322.
322 = D3DFVF_XYZ + D3DFVF_DIFFUSE + D3DFVF_TEX1 + D3DFVF_TEXCOORDSIZE2(0)

For statically lit objects you don't define D3DFVF_NORMAL as the vertices will be pre-lit.

WARNING

Currently, the 3dmodel does not support multitexturing.

TIP

The lower the attribute order value is, the faster batch will render.

TIP

If you have two surfaces that are overlapping each other, specify the zbias attribute, so this surface will appear "above" the second surface.

TIP

alphatest attribute works in the following way:

  • if the value is set to 0, rendering batch is disabled
  • if the value is in the range from 1 to 255, rendering batch is enabled when alpha >= alphatest
  • if the value is in the range from 256 to 511, rendering batch is enabled when alpha < alphatest - 256

TIP

Blending mode works in the following way:

  • when the value is set to 0, blend mode is normal
  • when the value is set to 1, blend mode is set to addition
  • when the value is set to 2, blend mode is set to substraction

TIP

Set staticlighting attribute value to true for static non-moving objects for the best performance.

TIP

b1, b2, b3, b4 and refbone attributes apply for skeletal modeling.

AttributeTypeDefault valueDescription
idStringBatch Identification
fvf+Integer0Flexible Vertex Format
texture1TextureBatch texture
materialMaterialBatch material
order+Integer0Rendering order
zbiasFloat0Z-index
alphatest+Integer0Toggles rendering based on alpha
blendingBooleanFalseToggles alpha blending
cullingBooleanTrueToggles face culling (CCW), should be enabled whenever possible for the best performance
blendmodeInteger0Blending mode
zwriteBooleanTrueToggles writing Z-values to Z-buffer
staticligthingBooleanFalseToggles precalculate lighting
mipmaplodbiasFloat0.0Select sharper/softer mipmap level
refxFloat0.0Reference of X-point for lighting
refyFloat0.0Reference of Y-point for lighting
refzFloat0.0Reference of Z-point for lighting
b1StringIdentification of the first bone
b2StringIdentification of the second bone
b3StringIdentification of the third bone
b4StringIdentification of the fourth bone
refboneStringReference of bone
typeStringnormal, blend, glassTexture type

Vertex

Parent element name: batch
Element name: vertex

TIP

Leave nx, ny and nz values to 0 to calculate normals automatically.

TIP

b1, b2, b3, b4 attributes apply for skeletal modeling.

AttributeTypeDefault valueDescription
xFloat0.0Position relative to the X-axis
yFloat0.0Position relative to the Y-axis
zFloat0.0Position relative to the Z-axis
diffuseColorDiffuse color for texture
u1FloatTexture u coordinate
v1FloatTexture v coordinate
nxFloat0.0Normal vector relative to the X-axis
nyFloat0.0Normal vector relative to the Y-axis
nzFloat0.0Normal vector relative to the Z-axis
psizeFloat0.0Point size when rendering points
b1StringIdentification of the first bone
b2StringIdentification of the second bone
b3StringIdentification of the third bone
b4StringIdentification of the fourth bone
w1Float0.0Weight of the first bone
w2Float0.0Weight of the second bone
w3Float0.0Weight of the third bone
rhwFloat0.0Reciprocal of homegenous w

Face

Parent element name: batch
Element name: face

AttributeTypeDefault valueDescription
v1StringIdentification of the first vertex
v2StringIdentification of the second vertex
v3StringIdentification of the third vertex

Seam

Parent element name: 3dmodel
Element name: seam

TIP

Add seams between vertices in different batches to smoothen the surface when using automatic vertex normals calculation.

AttributeTypeDefault valueDescription
b1StringIdentification of the source batch
v1StringIdentification of the source vertex
b2StringIdentification of the target batch
v2StringIdentification of the target vertex

Transformation

Parent element name: hill
Element name: transformation

WARNING

Matrix and rotate, scale, translate elements exlcude each other. You can have either transformation element with matrix only, or with rotate, scale and tranaslate elements.

AttributeTypeDescription
idStringIdentification of transformation

Matrix

TIP

Refer to this article for explanation on matrix representation.

AttributeType
m11Float
m22Float
m21Float
m33Float
m44Float

Rotate

AttributeTypeAllowed valuesDescription
axisStringx, y, zReference to built-in game axis
angle+IntegerRotation angle of target model

Scale

AttributeTypeDescription
x+IntegerScale of target model relative to the X-axis
y+IntegerScale of target model relative to the Y-axis
z+IntegerScale of target model relative to the Z-axis

Translate

AttributeTypeDescription
x+IntegerTranslation of target model relative to the X-axis
y+IntegerTranslation of target model relative to the Y-axis
z+IntegerTranslation of target model relative to the Z-axis

3D Model Instance

Parent element name: hill
Element name: 3dmodel-instance or model-instance

WARNING

You can name element 3dmodel in DSJ4 versions from 1.7.0, model only from 1.8.0.

AttributeTypeDefault valueDescription
idStringIdentification of the 3d model to instantiate
xFloatPosition relative to the X-axis
yFloatPosition relative to the Y-axis
zFloatPosition relative to the Z-axis
refxStringA reference to the X-axis, which 3dmodel is based on
refyStringA reference to the Y-axis, which 3dmodel is based on
refzStringA reference to the Z-axis, which 3dmodel is based on
transformationStringA reference to transformation element

Code snippets

<hill version="DSJ4-1.10.0">
    <!-- Rest of code omitted for clearance -->
   <model id="vdf134-roof">
      <batch id="roof" texture1="Textures\concrete5.png" material="Materials\material1.xml" fvf="322" order="0">
         <vertex id="1" x="-3" y="0" z="-3" u1="-3" v1="-3" diffuse="0xff747681"/>
         <vertex id="2" x="-3" y="0" z="3" u1="-3" v1="3" diffuse="0xff747681"/>
         <vertex id="3" x="0" y="2.5" z="0" u1="0" v1="0" diffuse="0xff747681"/>
         
         <vertex id="4" x="3" y="0" z="3" u1="3" v1="3" diffuse="0xff747681"/>
         <vertex id="5" x="3" y="0" z="-3" u1="3" v1="-3" diffuse="0xff747681"/>
         <vertex id="6" x="0" y="2.5" z="0" u1="0" v1="0" diffuse="0xff747681"/>

         <vertex id="7" x="-3" y="0" z="3" u1="-3" v1="3" diffuse="0xff747681"/>
         <vertex id="8" x="3" y="0" z="3" u1="3" v1="3" diffuse="0xff747681"/>
         <vertex id="9" x="0" y="2.5" z="0" u1="0" v1="0" diffuse="0xff747681"/>

         <vertex id="10" x="3" y="0" z="-3" u1="3" v1="-3" diffuse="0xff747681"/>
         <vertex id="11" x="-3" y="0" z="-3" u1="-3" v1="-3" diffuse="0xff747681"/>
         <vertex id="12" x="0" y="2.5" z="0" u1="0" v1="0" diffuse="0xff747681"/>
         
         <face v1="1" v2="2" v3="3"/>
         <face v1="4" v2="5" v3="6"/>
         <face v1="7" v2="8" v3="9"/>
         <face v1="10" v2="11" v3="12"/>
      </batch>
   </model>
   <model-instance id="vdf134-roof" refx="inrun0" refy="inrun-top" x="3.525" y="2.85" z="1.175"/>
</hill>

By Jussi Koskela