If you'd rather work offline, you can download the tutorial here, which includes an example GM6 file for testing your models, as well as all the text and images that appear below.
And with that, I present you with my example / tutorial:
Getting your models into Game Maker
One of the most common questions people have when they start working with 3D in Game Maker is how to get their own models into the game. That is what I will try to explain here – hopefully this will clear some things up for anyone who just doesn’t understand the process, or who would like to see how I do it.
To begin, here are the steps that I will go through in this example / tutorial. I won’t cover every little detail of these things, but I will show you how I do it myself, hopefully so as to shed some light on the overall process.
· Constructing the model & exporting the model as an OBJ
· Fix UV coordinates
· Create a texture map
· Import into GM
Of course, just as a painter would be nowhere without his brush, we would be nowhere without tools to help us accomplish our goals. Here is a list of all the tools I am using, with links provided to those that are freely available for you to use.
· Truespace 5
· UVMapper Classic
· Marzipan (by percsich.hu)
· Mosaic Light (by percsich.hu, included in editable)
Constructing the model & exporting the model as an OBJ
Alright, first things first, let’s get a quick little custom model out of the way. I used Truespace 5 to create a simple model, like the one pictured below. You can use whatever object you want. One thing to note though, if you use Truespace to model, you’ll probably notice that it does not export to OBJ file format natively (at least, version 5 and below do not, to my knowledge), so you’ll have to find a plug-in for that. I use a plug-in called Luuv, which you can find here.
When you export your model, take note of where it is in your 3D modeler. If the program exports objects relative to the origin of the 3D world, then that will be the default location around which your object rotates when you get it in GM. You can use this knowledge to your advantage though, and pre-plan the axis locations of your objects by exporting them in different places depending on your needs. For now, I recommend placing your object in the world so that the origin is right at the center of it.
My weird blocky model
Once you’ve got your model exported, find the file and put it somewhere that will be easy to access by your game. I recommend placing it in the same directory as your game while you test – you can always add directories to organize your files later, when you’ve got the details worked out.
I’ve provided a simple example gm6 file that can load models on-the-fly using Mosaic Light. Since I have no idea how you might have your game structured to load models, I think it’ll be best if we use the example program to load and test the model, and you can look at the actual code later. It is simple stuff though, I assure you. If you like, try loading your model into this program right now. Just open up the gm6 and run it. Press Space to load your model. The program will also ask you to load a texture file, but we’ll worry about that later (press Cancel when prompted for a texture). Also, bear in mind that if your object is on an extremely different scale than this program draws, you may wind up seeing a very small or large model in the vew. Adjust your model scales accordingly in your modeler, or edit the code of the viewer to scale your objects itself. When you’re done checking out your model, continue below.
One thing I’ve noticed with Truespace is that for some reason, when I export models as OBJ files and import them directly in GM with Mosaic Light without any alterations, they have their normals rounded, so the object appears to be shaded smoothly, even on flat surfaces. To fix this, I import my OBJ files into Marzipan. This step should be unnecessary for most people, but I opted to include it because it probably does pop up every now and then. If your set of tools doesn’t suffer this problem, you can skip the next few paragraphs and resume at the UV mapping section.
The default view of the model viewer example gm6
Here’s what my model looks like when I import it into GM without any changes, to better illustrate my point:
Note the rounded shading
Edited by FredFredrickson, 19 December 2007 - 05:01 PM.