• Welcome to SC4 Devotion Forum Archives.

Blender to Gmax, Models and UVW maps.

Started by Xiziz, April 19, 2009, 02:09:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xiziz

I've for quite some time been looking for ways to export models from Blender into Sim City 4, without having to purchase any expensive software (3ds studio Max would be able to read .3ds files blender is capable of exporting). As I use UVW unwrapping when mapping textures, and gmax seems to have a problem importing .3ds files with embeded UVW maps. Well I finally found the solution through two import/export scripts for the game "Battle for Middle Earth", which also uses Gmax as editor. Found a link to this package in one of a small tutorial Jeronij made here.

Although the prefered way would be to export models directly from Blender(like bat4max does from 3ds studio max), this involves a lot of scripting and maybe even some programming, something which I'm rather unfamiliar with. This way lets you create your models in Blender, Texture them in Blender and throw them over to Gmax for the rendering phase. This allows all of us that cant or don't want to spend a fortune on 3ds max to use an advanced program to create our models in. As Blender is free, and significantly more advanced than Gmax.

I'm also assuming some prior experience of Blender, for those that wish to learn there are a huge pile of good tutorials aimed for complete beginners here.


Preparing gmax to import the model:
1. Download the file "renx_obj_tools.zip" from here.
2. Unzip "importobj.ms" and "xzzy_obj_tool.ms" into your \gmax\gamepacks\BAT\scripts\startup folder (Eg "C:\Program Files\Gmaxgamepacks\BAT\scripts\startup"). (saves us from having to load them manually later).
There is a third file in the zip, we don't need this now, but if you want to export .obj files from Gmax(to edit a gmax file in your favourite 3d creation software) there are some instructions to follow on how to do this here.

Ether you use your own blender model, or use the one I have attached to this post.
First we want to export our model from blender as a wavefront object(.obj) This is rather simple, just go to file->export->wavefront, a new frame that looks just like the save frame will appear. Choose a name a click save, next a dialogue box appears with settings, we don't touch anything, the default settings work just fine.



Great, we got our model out of blender now, lying somewhere safe and sound I presume. So go get a cup of tea, coffee or whatnot, (it will be the perfect temperature to drink when we get to the rendering).
Good, put the cup aside and fire up Gmax(with BAT).

Bring up the utilities menu(hammer icon), press the button "More..." and select "MAXScript", press OK. A new tab will appear.

Now we want to activate our scripts, they should show up in the list already, if they did not, simply press "run script" and browse to them.

First we will want to load our UVW maps, so we select "Wavefront OBJ Import" from the dropdown, a new pane shows(you might have to scroll down or minimise the utilities pane to see it depending on your resolution, I had to). No fiddling here, press "Import" and browse to our .obj file and load it.

This Importer is a little broken as you may see, the mesh is only visible in the perspective viewport. Select the object and add a "UVW Unwrapper" from the modifier list.

Pressing the "Edit" button will bring up the UV Editor, here we can see that it successfully imported our UVW map. Now save the UVW map by pressing save. Now were going to import the proper mesh, so hit delete to remove the broken mesh and go back to the utilities tab(hammer icon).

Now we want to activate the "OBJ Import/Export" script, choose it from the dropdown in the "MAXScript" pane and click it. A New frame appears.

Hit Import and browse to our .obj file. This script successfully imports our mesh, but fails to load our UVW map.

To fix this we go and add a "UVW unwrapper" to the object(just as we did earlier). Load the .uvw file we saved earlier, and verify that the maps look as they should.

As you may have noticed, we still have three things left to do before we can render. Map the texture, Rotate the building 90 degrees so it faces the correct way, and move it to the centre of the scene.

Texture it as you normally would, and apply, since the model is UVW unwrapped, chances are you only have one material.

To rotate it so it shows up correctly, enter the left viewport, use the rotate tool and rotate it 90 degrees on the X axis.

Now to center the object, we will need to join all the pieces(even if its only one) into a group. then use the move tool to move it to the center(X & Y Axis = 0), Leave the Z axis alone, it should be correct. Anything below Z0 will appear "underground" ingame.

Now, time to save the scene, and go through the normal BAT-rendering procedure, just like you normally would from Gmax/BAT.



Notes: As wavefront objects by default merge into a single mesh, names of individual objects do get replaced. It seems you will still have to do your night lights in Gmax. As for modeling in Blender, its rather different than gmax/max. And you generally don't have very many objects(I usually stick to a single object, easier to UVW map textures that way).

Just thought I'd share my recent experiences in how to do this, and to keep it in a safe location in case I forget it, hope someone else finds this useful.

Time for sleep now, I'll try to clean it up a little bit later.

Chip chop