Documentation for the blend2cs.py script.

Features:


1.) Requirements

This script was designed for Blender V2.14, It may not work on other versions of Blender.

Also I used the CVS version of CS (cs-2001-06-21[1].083702.tar)

You will need to have Python installed, I am not positive what version you need, but to be safe install V2.0

In order for Blender to find the Python modules you will have to do the following (Linux)

put this in your /etc/profile

PYTHONHOME=/usr/lib/python2.0
export PYTHONHOMEcs-2001-06-21[1].083702.tar

You might have to do something similar on a windows machine.

Blender 2.14
If you want to use Blender 2.12 then look at the python file and replace all the Blender210 with Blender.

2.) Setup

Blender does not have a textures module in the Blender Python API, but I here the next release will have a lot more support added to the API!
Because of this we need to make a file containing the material and texture information. Currently this file must be called template.
If you have problems with Python not being able to find this file, then edit the blendToCS.py file and put the full path to the file.

Next fire up Blender!

3.) Creating the sector 'room'

Remove the plane, if it is there.
Switch to top view and add a mesh>>cube
Scale the cube while holding [Ctrl]

Now go to the "Edit Buttons" [F9]
Make the following changes:

To specify a mesh as a sector enter the following into the OB: button:

The sector_  part of the text tells the blendToCS.py script that this mesh object is a sector. The default sector which CS starts in is 'room'
If you forget to put the sector_  in the OB: button, then the blendToCS.py script will not export the mesh!

Next take a look at the worldStart file. You will see:

    MATERIAL 'mosaic' (TEXTURE ('mosaic.gif'))
    MATERIAL 'oldmetal' (TEXTURE ('oldmetal.gif'))
    MATERIAL 'parket' (TEXTURE ('parket.gif'))
    MATERIAL 'asphalt' (TEXTURE ('asphalt.gif'))
    MATERIAL 'mosholes' (TEXTURE ('mosholes.gif'))
    MATERIAL 'oldbrick' (TEXTURE ('oldbrick.gif'))
    MATERIAL 'window' (TEXTURE ('window.gif'))
    MATERIAL 'red' (TEXTURE ('red.gif'))
    MATERIAL 'green' (TEXTURE ('green.gif'))
    MATERIAL 'blue' (TEXTURE ('blue.gif'))
    MATERIAL 'yellow' (TEXTURE ('yellow.gif'))
    MATERIAL 'sky' (TEXTURE ('sky.gif'))
    MATERIAL 'misty' (TEXTURE ('misty.gif'))

We want to walls of the room to have the texture 'mosaic' so go to "the material buttons" [F5]
Add a new material and name it:

This will tell the script that the mesh(s) with this material will use the texture mosaic.
I was looking through the message forms at Blender, and some one said that the next Blender release will have full texture support (-:

(IMPORTANT) CS only renders one side of the polygons. So for both sectors and things all the normals must be facing outward from the object.
If you see a normal facing the wrong direction. Select the face by selecting the vertices around the face, and press the "Flip Normals" button in the
"Edit buttons" window. Also Try using [Ctrl+Alt+N] with all the vertices selected to recalculate the normals.

4.) Exporting the world.

Make sure you are not in "edit mode". If you are, then the script will not export the changed information.

Press [Shift+F11] to go to the script window.
Type this in:

execfile("/usr/local/CS/scrpits/blender/blend2cs/blend2cs.py")

You must give the full path for this to work. You could just open the script in the window, but this allows you to use an external editor to make changes to
the script.

Press [Alt+P]

The script will place the file world in the directory you started blender. If you don't like this, then edit the script.

Zip the world file into a zip file(put the zip file in the CS/data directory) and test it with walktest!

Next you might want to add another room.

Add another cube mesh:

Name the the new cube

Set the material for this cube the same as the first one.

To see the name of the meshes press:

You will have to press "name" for each mesh.

Select sector_room and press [Tab]

Press [B] and select:

Now while in the "Edit buttons" window add a "new" material and press "assign".

Switch to the "Material buttons" window.

Click on the "3" to the right on the name of the material, and click on "Single user"

The "3" might be a different number.

Rename the material to:

This will tell the script that the face with the material name 'portal_room1' is a portal to room1

Now export the world, zip it, and run CS with the -nolight option.
Walk into the other room, and turn around. What, where did the room I was just in goto?
For sector_room1 you need to add a portal to sector_room

I have an idea on how to make the portal stuff easier. If it works it will be in the next version.

Next you might want to add a Light.

Place the Blender cursor where you want to add a light.
Add>>Lamp

Goto "Edit buttons"

OB: Is the name of the light
LA: Is the sector which the light is in.

Goto "Lamp Buttons" [F4]

And set the following parameters:

The "Dist" is the radius of the light.

Export it, zip it, and run ./walktest -relight test

Now I bet you want to add a thing.

Put the Blender cursor where you want to add the thing and add a mesh of some kind. I added a cone.
Scale, rotate, and move the mesh to where you want it.
Remember the normals must be facing out from the object!

Assign a texture

Tell the script the mesh is a thing and what sector it is in

Export, zip, walktest -relight test

The Blender file: tutorial.blend

Tips:

When you get into complex mesh modeling, you might have extra vertices in the mesh. To avoid this select a mesh, enter edit mode,
select all the vertices [A] and press [W], click on remove doubles. If there are any double vertices in a mesh, CS will give you an error.

If walktest will not load the world, then check the caps of all the names, materials. Capitalization matters!
Just check to see if everything is correct.

Contrubute/Bugs:

If you find any bugs, or have an idea, or have some code, or have created a cool world email me at mltang@carbon.cudenver.edu

Thanks (-: