Adding an object to a terrain

From Rigs Of Rods

(Difference between revisions)
(Step 1: Creating an Ogre mesh and texture)
 
Line 4: Line 4:
* If you want to add an existing game object, start from step 3 or 4 if the object is already in the edition list.
* If you want to add an existing game object, start from step 3 or 4 if the object is already in the edition list.
-
== Step 1: Creating an Ogre mesh and texture ==
+
comment4,
-
If you want to model your own object, use your favorite modeler (3D Studio, Blender, AC3D, ...) to model it, and install the adequate Ogre exporter plugin: [http://www.ogre3d.org/wiki/index.php/Exporters]
+
-
 
+
-
Export you object in the .mesh Ogre format. (it's a binary format)
+
-
 
+
-
For the definition of the texture material, you must also generate a .material file (it's a text file). Some plugins make the .material file, others not.
+
-
 
+
-
A basic material file looks like:
+
-
<pre>
+
-
material your_material
+
-
{
+
-
technique
+
-
{
+
-
pass
+
-
{
+
-
texture_unit
+
-
{
+
-
texture your_texture.png
+
-
}
+
-
}
+
-
}
+
-
}
+
-
</pre>
+
-
The generated .mesh must be exported saying it will use the "your_material" material.
+
-
 
+
-
For more help on this part, go at [http://www.ogre3d.org/] and check their wiki and forums.
+
-
 
+
-
Once you are done, put the .mesh and .material in the data/objects directory of RoR.
+
== Step 2: Creating an odef object file ==
== Step 2: Creating an odef object file ==

Current revision as of 18:50, 3 March 2009

This tutorial in in two part:

  • If you want to model a new object from scratch, start from the beginning.
  • If you want to add an existing game object, start from step 3 or 4 if the object is already in the edition list.

comment4,

Contents

[edit] Step 2: Creating an odef object file

To make the mesh usable, you must create a .odef text file, also in the data/objects.

The main role of the odef it to declare the collision volumes.

The simplest odef file is :

your_object.mesh
1.0, 1.0, 1.0
end

The first line is the filename of the .mesh, the second is the x,y,z scale factor to apply to the object.

The file ends with "end". Collision boxes are optional.

To add collision volumes, just add lines after the scale factor.

A collision volume is a box. You can optionnaly rotate the box.

The syntax of a collision line is:

minX, maxX, minY, maxY, minZ, maxZ [, rotX, rotY, rotZ]

with minX<maxX, minY<maxY, minZ<maxZ defining the collision planes of the box, relative to the center of the mesh (as definined in your modeler).

Example:

road.mesh
1, 1, 1
0, 10, -5, 0, -3, 3
0, 10, -5, -0.5, -4.5, 4.5
0, 10, -0.7635, -0.2365, -4.4572, -2.8761, -18.4349, 0, 0
0, 10, -0.7635, -0.2365, 2.8761, 4.4572, 18.4349, 0, 0
end

This is the collision boxes of a block of road. The first two lines are simple boxes, the other two are rotated boxes (to do the sloped sides of the road).

[edit] Step 3: Adding the object to the edition list

In order to be able to position an .odef object in the game with the truck, you must add it to the list of objects the truck will use. This list is the "editor.cfg" file in the RoR directory.

Just add the name of the odef file without the .odef extension.

for example

;objects that are selectable with the editor truck
your_object
sign-leftturn
sign-rightturn
sign-bump
sign-crossing
sign-descent
sign-fall
sign-rocks
sign-warning

[edit] Step 4: Positionning the objects with the terrain editing truck

To position an object (declared in the editor.cfg list) in the terrain, start RoR, and select the terrain editor truck.

Enter the truck, and press V to cycle thru the objects in the list. The object will be at the end of the crane of the truck.

Move the crane to position the object where you like it.

Press the Ins, Del, Home, End keys to rotate the object as you like.

When everything is set, press the space bar. This will create the new object.

You can continue and place several different objects at different places.

Do not press B or you won't be able to add new objects!

[edit] Step 5: Making the changes permanent

The objects you just created are not permanent. To make them permanent, open the "editor_out.txt" file in the RoR directory, copy the content of this file and paste it in the proper .terrn file, before the last line that contains "end".

Personal tools