Material File

From Rigs of Rods Wiki Archive
Jump to: navigation, search

The .material files in RoR are for referencing the trucks to a .png/.jpg/.dds texture file (Note that you are highly encouraged to use DDS image files to save video memory. See Making DDS textures). For this tutorial we'll use the Agora L as an example. Just remember all trucks, cars, airplanes, and boats use the same basic code for the .material file.

Most Ogre exporter for SketchUp, Blender or 3DS, generate material files automatically. Please note that .material files are powerful as you can see on Ogre Material manuals OgreWiki material manual

OK, first let's look at one of the first lines in the agoral.truck file:

18000.0, 1000.0, tracks/agora

The tracks/agora is what we're concerned about. When RoR/Ogre reads that line of code, it looks through the .material files for that same line. It finds tracks/agora in agora.material. That code is as follows:

material tracks/agora
{
	technique
	{
		pass
		{
			scene_blend alpha_blend
			alpha_rejection greater 128 
			texture_unit
			{
				texture bus2.png
			}
		}

Now we look there and see that below tracks/agora, a .png file is listed, bus2.png to be specific. That's what actually gets loaded onto the bus. If you select agoral.truck and agora.material and make copies of those and rename them appropriately, we can start making the new bus. Let's say the name of your new .png file is newbus.png, the .truck is newbus.truck and the material file is newbus.material. Now open up newbus.material and look for bus2.png. Change that to newbus.png (Or whatever your file is named). Now go up a few lines and you'll see tracks/agora. Change that to tracks/newbus. Now open up newbus.truck and look for tracks/agora, and change that to tracks/newbus.

You also use .material files for wheelfaces and treads. For this we'll look at the Caliber. Here's one line of the wheels section of caliber.truck, with some irrelevant sections removed:

wheels
radius,width,numrays,node1,node2,snode,braked,propulsed, arm, mass, spring, damp, simple/double

0.4, 0.60, ..... 3000.0, tracks/caliberwheelface tracks/wheelband1

The 2nd to last line, tracks/caliberwheelface, is what we're after. RoR reads that, and finds that line in caliber.material. Now, let's look in caliber.material. One of the references is as follows:

material tracks/caliberwheelface
{
	technique
	{
		pass
		{

			texture_unit
			{
				texture caliberwheelface.jpg
			}
		}
	}
}

The same technique applies here, the .jpg file gets loaded onto the wheels, and tracks/ is what links the .truck and .material file.

Also note that as of 0.35, only the selected truck's .zip file is opened, so you must include all needed files (.material and .dds included) otherwise you may get a material not found error.