Richard Burns Rally Car Exporter
================================
Included in this package is the 3dsmax exporter we used for exporting the cars, and a .max file
for a car used in the actual game (the Impreza 03). Hopefully this will help people getting their
own cars in the game.


Getting Started
===============
The exporter has only been tested under 3dsmax 5.0, so I'm not sure if it will work under later
versions.

Copy the contents of the plugins and plugcfg directories to your 3dsmax directory.

To be able to run the exporter, you need the following dlls: MFC71.DLL, MSVCR71.DLL
and MSVCP71.DLL somewhere in your path. They will most likely already be there,
but if the exporter doesn't load, make sure you have the proper dlls.


A brief description of the objects needed
=========================================
parent - 	The root of the car. All other objects must be children to the parent.

ghost_parent - 	The root of the ghost car. The ghost car mesh is exported at the same time as
		the "real" car.
		
Objects beginning with:
c_ - 		Collision meshes. Only one is used. It is texture mapped with a 256 color
		texture (coll2.tga), where each color corresponds to a "damage zone" on the car.
		
e_ - 		External objects. Different objects are visible depending on the camera mode, ie
		are we inside or outside the car.

i_ -		Internal objects. See above.

s_ - 		Shadow objects. Used to generate the shadow volumes. Must be children to the
		"real" geometry.
		
d_ - 		The deformed (morphed) versions of objects.

D_ -		Points needed for the driver/codriver animation/IK.

Point_ -	Point helpers used to mark a certain point on the car. Used for particle effects,
		sound position etc.
		
texture_ -	A lazy hack by a graphics artist, who just wanted these textures copied automatically :)		


e_light_XX
e_light_XX_lit - Sometimes objects can appear in different states, for example a light being switched
		on and off. Both objects are exported, and they are marked as "switches" in the
		CarExporterSettings.ini file.
		
		
I think the easiest way to go about creating a new model would be to just copy the Impreza03.max file,
and then replace existing objects with new ones; it's probably just too easy to mess up and miss
something otherwise.


Exporting
=========
Before you begin exporting anything, you should probably backup your Cars directory.

You probably have to rescale the scene before it's exported. The included car is modelled in mm, but
ingame everything is measured in meters, so you need a scale factor of 0,001. 
"Rescale World Units" does the job fine. I noticed that rescaling sometimes screws objects up by moving 
and/or rotating them. It worked fine if I saved the unscaled model, reloaded it, and then rescaled.

To export, select File/Export, and then choose to overwrite an existing .sgc file. Leave everything
selected, and choose to overwrite the existing .ini file. By default, all the textures used by
the model will be copied to a "textures" subdirectory. Ignore the warnings and errors :)


Fixing up the exported model
============================
If you start RBR now, and choose your exported car, it should look right, except for the textures
being all white. Two things have to be done to correct this.

Create a default texture set
----------------------------
In the beginning of RBR, we thought we would be able to swap all the textures of meshes in some
way, so we used something called a "Texture Set" which gives a name to each texture, but no actual
filename. This wasn't used in the end, but a default texture set still has to be created so the 
3d-engine can load the correct textures.

If you look in one of the xxx_shaders.ini files, you'll find the following:

[Textures]
Texture0 = impreza03_external.dds
Texture1 = impreza03_external_dynamic.dds
Texture2 = impreza03_external_dynamic_mud.dds
Texture3 = impreza03_external_mud.dds
Texture4 = impreza03_external_scrape.dds
Texture5 = impreza03_external_transparent.dds
Texture6 = impreza03_internal.dds
Texture7 = impreza03_internal_kwindscreen.dds
Texture8 = impreza03_internal_scrape.dds
Texture9 = impreza03_internal_transparent.dds

[TextureSets]
TextureSet0 = TSDefault

[TSDefault]
impreza03_external.dds = cars\impreza03\textures\impreza03_external.dds
impreza03_external_dynamic.dds = cars\impreza03\textures\impreza03_external_dynamic.dds
impreza03_external_dynamic_mud.dds = cars\impreza03\textures\impreza03_external_dynamic_mud.dds
impreza03_external_mud.dds = cars\impreza03\textures\impreza03_external_mud.dds
impreza03_external_scrape.dds = cars\impreza03\textures\impreza03_external_scrape.dds
impreza03_external_transparent.dds = cars\impreza03\textures\impreza03_external_transparent.dds
impreza03_internal.dds = cars\impreza03\textures\impreza03_internal.dds
impreza03_internal_kwindscreen.dds = cars\impreza03\textures\impreza03_internal_kwindscreen.dds
impreza03_internal_scrape.dds = cars\impreza03\textures\impreza03_internal_scrape.dds
impreza03_internal_transparent.dds = cars\impreza03\textures\impreza03_internal_transparent.dds

The first heading, "Textures", says that the following textures are needed for the car. Note that
even though they end in .dds, they aren't actual file names.

The next heading, "TextureSets", says which texture sets are used by the car. This must be TSDefault.

The final heading, "TSDefault", maps the names found in "Textures" to the actual file used.

So, to get the 3d-engine to load the correct textures, you need to:
	- Create a Textures section, and add the name of each texture you want to be loaded. Search
	  for "Filename=", and you'll find all the textures.
	- Create a TextureSets section, and add the TSDefault texture set
	- Create a TSDefault section, and for each texture name in "Textures" point it to the
	  correct filename.

Note also that the game uses .dds textures, but when exporting you get tga files. You can use
something like nvdxt to create .dds files from the tga files, but the game works fine with tgas too.


Fixing dirt & scrape maps
-------------------------
To get the dirt and scrape textures working, a "friendly name" has to be assigned to the textures.
The 3d-engine uses this name to ask for a specific texture, without needing to know the actual
filename.

In the same shader file as above, add the following headers:

[impreza03_external_dynamic_mud.tga]
FriendlyName = TireDirt

[impreza03_external_mud.tga]
FriendlyName = Dirt

[impreza03_external_scrape.tga]
FriendlyName = Scrape

[impreza03_internal_scrape.tga]
FriendlyName = InternalScrape

This assigns all the required friendly names.
  
	  
Internally we had a tool that did all this, but it's just too weird to release. Just ask anyone at
Warthog about "the tool" :) 

By the way, the .ini files are compatible with win32 .ini files, so the Get/WritePrivateProfile family
of functions can be used if anyone is thinking of writing their own tools.

Conclusion
==========
I really hope this will help the mod community out there. 

I'm quite frankly amazed at how far the guys hacking the sgc format have come 
(guys, I think the only thing you missed are those 56 bytes that contain the decomposed pivot matrix 
[have a look in the 3ds max sdk docs], and that the header actually spells Hedgehog Scene :).

If any questions do come up, post on one of the regular forums, and hopefully someone will be able
to help.


Merry Christmas,
	Warthog Sweden 
	