Adding an object to a terrain
From Rigs Of Rods
Line 5: | Line 5: | ||
== Step 1: Creating an Ogre mesh and texture == | == Step 1: Creating an Ogre mesh and texture == | ||
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] | 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) | 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. | 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: | A basic material file looks like: | ||
<pre> | <pre> | ||
Line 24: | Line 27: | ||
</pre> | </pre> | ||
The generated .mesh must be exported saying it will use the "your_material" material. | 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. | For more help on this part, go at [http://www.ogre3d.org/] and check their wiki and forums. | ||
Line 31: | Line 35: | ||
To make the mesh usable, you must create a .odef text file, also in the data/objects. | 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 main role of the odef it to declare the collision volumes. | ||
+ | |||
The simplest odef file is : | The simplest odef file is : | ||
<pre> | <pre> | ||
Line 40: | Line 46: | ||
The first line is the filename of the .mesh, the second is the x,y,z scale factor to apply to the object. | 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. | The file ends with "end". Collision boxes are optional. | ||
+ | |||
To add collision volumes, just add lines after the scale factor. | To add collision volumes, just add lines after the scale factor. | ||
+ | |||
A collision volume is a box. You can optionnaly rotate the box. | A collision volume is a box. You can optionnaly rotate the box. | ||
+ | |||
The syntax of a collision line is: | The syntax of a collision line is: | ||
+ | |||
minX, maxX, minY, maxY, minZ, maxZ [, rotX, rotY, rotZ] | 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). | 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). | ||
Line 62: | Line 74: | ||
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. | 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'''. | Just add '''the name of the odef file without the .odef extension'''. | ||
+ | |||
for example | for example | ||
<pre> | <pre> | ||
Line 80: | Line 94: | ||
To position an object (declared in the editor.cfg list) in the terrain, start RoR, and select the terrain editor 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. | 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. | 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. | 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. | 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. | You can continue and place several different objects at different places. | ||
Revision as of 21:43, 22 April 2006
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.
Contents |
Step 1: Creating an Ogre mesh and texture
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: [1]
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:
material your_material { technique { pass { texture_unit { texture your_texture.png } } } }
The generated .mesh must be exported saying it will use the "your_material" material.
For more help on this part, go at [2] 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
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).
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
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!
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".