Blender to Sandbox: step by step
Posted: January 17th, 2010, 5:22 pm
I see this question asked often, and I know the wiki already has documentation for this,
but I thought I'd be a good idea to write a more step by step tutorial for those new to Sandbox and 3d in general.
Part I: Setup and installation.
For this tutorial you will need 3 things.
Blender: http://www.blender.org/download/get-blender/
Python: http://python.org/download/
Md3 export script: http://johnny3d.promail.ca/wikitut/blen ... pdated.zip
Download and install both blender 2.49b as well as Python 2.6.4. Also download and extract blendermd3_updated and save somewhere you will remember.
Open blender and check the console window. Make sure it has found you're python installation as it is needed for the export script to work properly. It should look something like the image below.
Note: your console window does not need to say those extra numbers. It just needs to say compiled with python version 2.x.x, and Checking for installed Python.... got it!
Part II: Setting up the model and texture in blender.
Note: some users who are familiar with other 3d software may want to go into blenders user preferences and change the view rotation to turntable and around selection.
Here is a link explaining what I mean. http://www.scribd.com/doc/10082639/Esse ... nd-Options
Go into front view by pressing 1 on the numpad or Go to view > Front from the menu.
Press Tab and go into edit mode.
While holding ctrl, move the box up with with the blue handle so your cube sits flush with the grid.
This ensures that when you add the model in sandbox, it is not sitting through the ground in it's default position.
Now we're going to split up our view to include a UV/Image Editor window, so we can unwrap our UVs and see what the model will eventually look like in game.
Here is a link explaining how to split your views. http://en.wikibooks.org/wiki/Blender_3D ... ing_System
Now while still in edit mode, make sure your cursor is within the 3d viewport and press U on your keyboard. Click unwrap and your uvs should be ready to go.
Now we'll apply an image to our uvs. You can use whatever image you would like, I'm going to use the image below.
Go to Image > Open within the uvimage editor and select your image. Also change the drawtype to textured in your 3d window.
We are now ready for export. Press Tab and go back into Object mode. Rotate around your model with middle mouse button or alt and mouse button 1 to ensure all looks well.
Part III: Exporting and writing your md3.cfg
First lets create a new directory within /packages/models of your Sandbox installation. For this example I will just create a new folder called box.
Now change the uvimage editor into a text editor. Browse to where you extracted the export scripts and open md3_export_test2.py.
Make sure your object is selected, and with your cursor in the text editor workspace, press alt + p on your keyboard to execute the script.
Save as tris.md3 within /packages/models/box
Note : If you get an import md3 error while trying to export from blender's text editor, try doing this.
Alternatively to loading the export script through the text editor, you can copy all the .py files within the blendermd3_updated archive to your /.blender/scripts/blender folder.
After doing so you should see .md3 under file > export. Makes for a simple and quick export process. You need to enable view of hidden folders in windows explorer,
and the path to this directory may be different depending on which windows OS you're using and/or how blender was installed. Both links below should be helpful in finding that path.
http://www.katsbits.com/htm/tutorials/b ... t_keys.htm
http://www.blender.org/forum/viewtopic. ... df48a2c3e5
Copy your texture over to this directory and right click > create a new text file. Once again right click and edit with your favorite text editor.
Windows users can just use wordpad. Don't use notepad as it won't save formatting.
Here is my config, You can just copy and paste this in your text file. Now save as md3.cfg
Note: the line md3skin Cube - Cube refers to whatever your object was named in blender.
//load model
md3load tris.md3
//skin model
md3skin Cube 1_store.jpg
//increase scale
mdlscale 2000
//turn off specularity
mdlspec -1
Here's a link for important commands to use within your model configurations. (Thank you cube 2 community for such solid documentation!!!)
http://sauerbraten.org/docs/models.html
Part IV: Importing into Sandbox/Cube2.
Finally the last the probably the easiest step. Fire up sandbox, create a new map.
Toggle edit mode and go into the dev console by pressing tilde (key above tab just in case you didn't know)
Type in this command:
/mmodel box
Press F1 and you will see box at the end of your model list.
Note: alternatively to using the mmodel command you can edit the default_map_models list within the data folder, just make sure you put your models path at the very end of the list.
Load your model and there you go, a very simple map model.
One final note:
Cube 2 gridsize vs mdlscale
When exporting a cube at default size in blender:
gridsize 0 cube = mdlscale 200
gridsize 1 cube = mdlscale 400
gridsize 2 cube = mdlscale 800
gridsize 3 cube = mdlscale 1600
and so forth
I hope someone here finds this tutorial useful and informative. I tried being as clear as possible.
Any thoughts/questions or feedback would be much appreciated. Cheers and take care.
-daniel_san
but I thought I'd be a good idea to write a more step by step tutorial for those new to Sandbox and 3d in general.
Part I: Setup and installation.
For this tutorial you will need 3 things.
Blender: http://www.blender.org/download/get-blender/
Python: http://python.org/download/
Md3 export script: http://johnny3d.promail.ca/wikitut/blen ... pdated.zip
Download and install both blender 2.49b as well as Python 2.6.4. Also download and extract blendermd3_updated and save somewhere you will remember.
Open blender and check the console window. Make sure it has found you're python installation as it is needed for the export script to work properly. It should look something like the image below.
Note: your console window does not need to say those extra numbers. It just needs to say compiled with python version 2.x.x, and Checking for installed Python.... got it!
Part II: Setting up the model and texture in blender.
Note: some users who are familiar with other 3d software may want to go into blenders user preferences and change the view rotation to turntable and around selection.
Here is a link explaining what I mean. http://www.scribd.com/doc/10082639/Esse ... nd-Options
Go into front view by pressing 1 on the numpad or Go to view > Front from the menu.
Press Tab and go into edit mode.
While holding ctrl, move the box up with with the blue handle so your cube sits flush with the grid.
This ensures that when you add the model in sandbox, it is not sitting through the ground in it's default position.
Now we're going to split up our view to include a UV/Image Editor window, so we can unwrap our UVs and see what the model will eventually look like in game.
Here is a link explaining how to split your views. http://en.wikibooks.org/wiki/Blender_3D ... ing_System
Now while still in edit mode, make sure your cursor is within the 3d viewport and press U on your keyboard. Click unwrap and your uvs should be ready to go.
Now we'll apply an image to our uvs. You can use whatever image you would like, I'm going to use the image below.
Go to Image > Open within the uvimage editor and select your image. Also change the drawtype to textured in your 3d window.
We are now ready for export. Press Tab and go back into Object mode. Rotate around your model with middle mouse button or alt and mouse button 1 to ensure all looks well.
Part III: Exporting and writing your md3.cfg
First lets create a new directory within /packages/models of your Sandbox installation. For this example I will just create a new folder called box.
Now change the uvimage editor into a text editor. Browse to where you extracted the export scripts and open md3_export_test2.py.
Make sure your object is selected, and with your cursor in the text editor workspace, press alt + p on your keyboard to execute the script.
Save as tris.md3 within /packages/models/box
Note : If you get an import md3 error while trying to export from blender's text editor, try doing this.
Alternatively to loading the export script through the text editor, you can copy all the .py files within the blendermd3_updated archive to your /.blender/scripts/blender folder.
After doing so you should see .md3 under file > export. Makes for a simple and quick export process. You need to enable view of hidden folders in windows explorer,
and the path to this directory may be different depending on which windows OS you're using and/or how blender was installed. Both links below should be helpful in finding that path.
http://www.katsbits.com/htm/tutorials/b ... t_keys.htm
http://www.blender.org/forum/viewtopic. ... df48a2c3e5
Copy your texture over to this directory and right click > create a new text file. Once again right click and edit with your favorite text editor.
Windows users can just use wordpad. Don't use notepad as it won't save formatting.
Here is my config, You can just copy and paste this in your text file. Now save as md3.cfg
Note: the line md3skin Cube - Cube refers to whatever your object was named in blender.
//load model
md3load tris.md3
//skin model
md3skin Cube 1_store.jpg
//increase scale
mdlscale 2000
//turn off specularity
mdlspec -1
Here's a link for important commands to use within your model configurations. (Thank you cube 2 community for such solid documentation!!!)
http://sauerbraten.org/docs/models.html
Part IV: Importing into Sandbox/Cube2.
Finally the last the probably the easiest step. Fire up sandbox, create a new map.
Toggle edit mode and go into the dev console by pressing tilde (key above tab just in case you didn't know)
Type in this command:
/mmodel box
Press F1 and you will see box at the end of your model list.
Note: alternatively to using the mmodel command you can edit the default_map_models list within the data folder, just make sure you put your models path at the very end of the list.
Load your model and there you go, a very simple map model.
One final note:
Cube 2 gridsize vs mdlscale
When exporting a cube at default size in blender:
gridsize 0 cube = mdlscale 200
gridsize 1 cube = mdlscale 400
gridsize 2 cube = mdlscale 800
gridsize 3 cube = mdlscale 1600
and so forth
I hope someone here finds this tutorial useful and informative. I tried being as clear as possible.
Any thoughts/questions or feedback would be much appreciated. Cheers and take care.
-daniel_san