Page 1 of 5

Blender to Sandbox: step by step

Posted: January 17th, 2010, 5:22 pm
by daniel_san
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.

Image
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.
1.png
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.
2.png


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
3.png
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.
4.png
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.
texture for tutorial
texture for tutorial

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.
5.png
6.png
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
7.png
8.png
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
9.png
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.
10.png
Load your model and there you go, a very simple map model. :geek:
11.png
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

Re: Blender to Sandbox: step by step

Posted: January 29th, 2010, 9:04 am
by myromance123
Hey there, first of all thank you for this great how to :D
I've been wanting to know how to do this for a while :)

My only problem is with this part, "First lets create a new directory within /packages/models of your Sandbox installation.". I cannot tell if you are using Microsoft Windows or a KDE Linux distro? I am an Ubuntu (linux distro) user, and I do not know where to locate that directory. If you could help me locate it, then that would be the end of my problems hopefully :D

I have located a .platinumarts folder under Home and tried creating the folders packages and models but no luck. I installed Platinum Arts Sandbox through playdeb.net if thats any help.

Once again thank you, I really hope you can help me with this :)

*EDIT: After a good long look (and search for "sandbox"), I found the /packages/model directory. It is located at /usr/share/games/sandboxgamemaker/packages/models . Also, had to use gksudo nautilus to enable create and delete files and folders for the model folder otherwise I couldn't make the box folder.

Now my only problem is the Cube loads up textureless. I believe it is the cube I made in Blender, but just with no texture. I rechecked my .cfg file, there should be nothing wrong with it. What could I have missed out?

Re: Blender to Sandbox: step by step

Posted: January 29th, 2010, 8:50 pm
by daniel_san
wow a response.... I myself use kubuntu and the dev(subversion) version of PAS. However I tried to gear this tutorial to anyone using any OS. Sorry for the confusion.
I could have answered your playdeb question but it seems you found it in usr/share/games.

Id be willing to be your texture isn't showing up because you didn't copy over your texture image, at least that would be my first guess.
My next guess would be the name of your object in blender doesn't match up with the md3skin Cube texturename.jpg line in your model configuration.
I highly recommend you just download the zipped up archive of the multiplatform version of sandbox from the main site.
That way can just extract it to your home directory, so you don't have to use gksudo nautilus to create files/copy files to a directory owned by root user.
It makes creating content a heck of a lot easier. Playdeb is nice an all, but as you can see the fact it installs to /usr/share it doesn't make deving the quickest process.
Hope this clarified some of your issues. Best of luck and take care.

-daniel_san

Re: Blender to Sandbox: step by step

Posted: February 3rd, 2010, 11:20 pm
by NoraaPro
I've done everything so far but once i get to exporting it comes up and says "Python error: check consol" So i guess the question is what stupid thing am i doing?

Re: Blender to Sandbox: step by step

Posted: February 4th, 2010, 1:46 am
by daniel_san
sounds like a python problem. copy and paste the exact error from the console if you could.

Re: Blender to Sandbox: step by step

Posted: February 4th, 2010, 7:18 am
by NoraaPro
“Python script error: check console” It then highlights the line that’s a few lines under the end of the notes that says “import md3”

Re: Blender to Sandbox: step by step

Posted: February 4th, 2010, 10:50 pm
by daniel_san
edit: ahh looks like someone else is having the same problem
now that I think of it though that error seems familiar. I think I, myself may have seen it when I was using windows.
as opposed to opening the script in blenders text editor, I think you should copy all the md3 scripts to your hidden scripts directory.
edit2: i changed where i wrote about the scripts folder path in the tutorial. it can now be found right after the export step.
make sure you have the correct python installed and that it says it has found it in the console when you launch blender.
then you can just go to file > export .md3
good luck

-daniel_san

Re: Blender to Sandbox: step by step

Posted: March 12th, 2010, 10:25 pm
by Manbearpig
hello, i am also having problems with the texture on the model. once i get the box into sandbox it has no texture. i have the wood texture saved as a .jpg in the correct folder and everything. i saved everything exactly as you did so i just copy and pasted the script. i'm not sure what im doing wrong here. if someone could please get back to me on this as soon as possible, that would be great. sorry if this is kind of a dumb question.

Re: Blender to Sandbox: step by step

Posted: March 16th, 2010, 1:46 am
by yongsui
i am sorry i am also having a problem with the phyton error thing i was wondering if it has to do with incompatibility with windows 7? cause according to the black box thingy(i am sorry i am new to this) it says it found phyton however theres no numbers

Re: Blender to Sandbox: step by step

Posted: July 4th, 2010, 10:39 am
by siimvuss
blah

Code: Select all

//load model
md3load tris.md3

//skin model
md3skin Cube 1_store.jpg

//increase scale
mdlscale 2000
//turn off specularity
mdlspec -1
blah