- Title: Superjoebob's Right Proper All Purpose Game Maker 3d Model Texturing and Importing Tutorial
- Description: A tutorial that explains how to properly import models into Game Maker, and how to UV map them in Maya and Wings 3d.
- GM Version: GM 6/7/8
- Registered: Yes
- File Type: .zip, .obj
- File Size: 60 Kb
- File Link: Mosaic Light and Plane Model<- Right-Click, Save target as
The final product of this tutorial can also be acquired from here: Tutorial Stuff
<If you don't have Maya, I've created a Wings 3D(Free) version of this tutorial. Just scroll down to the 3rd post.>
Hello everyone, I've noticed that there doesn't seem to be a right proper all purpose Game Maker 3d model tutorial around here, so I figured I would try and help the community out by coming up with one! Therefore, I would like to present to you:
Superjoebob's Right Proper All Purpose Game Maker 3d Model Texturing and Importing TutorialThis tutorial is focused around using Autodesk Maya to set up models for Game Maker, but if you don't have Maya, don't worry. You can follow along with any 3d modeling software you're comfortable with, since all the functions I will discuss are basic and should be included in any 3d modeling suite. Even If you don't own any 3d modeling software, I urge you to continue reading, as alot of this knowledge could come in handy in the future.
Thing's you will need for this tutorial:
- Game Maker 7 or 8 Pro (6 may be fine as well, I'm not completely sure though)
- Mosaic Light (Game Maker .obj importer, incredibly useful, credit Zoltan Percsich for this one, he certainly deserves it)
- Autodesk Maya (I recommend the Trial if you don't already own it, any other 3d modeling program you're comfortable with is fine as well if you're feeling diligent)
- Plane Model(Right-Click, save target as)
- Some sort of image editing software is great to have (If your going to get really serious about texturing your models I highly recommend learning Photoshop)
- Patience (An absolute must)
Part 1- UV Maps and You
The most important part of texturing models is your models UV maps, and it's important that you know how to use them. Start by opening up Maya and starting a new project. Go to "File->Import", and import the plane model provided for this tutorial. When it loads you should see a plane in the 4 view-ports. We'll start by opening up the UV Texture editor. Make sure you have the polygons set selected, and press "Edit UVs->UV Texture Editor". You should be presented with a window.
This, is the UV Texture editor. It is here that you will be setting up your model for texturing. There are 2 distinct ways (That I will talk about) to UV Texture your model. The first way, is to generate a UV map, export it as an image, and draw all over it in an image editing program.
First of all, we need to generate the UV map. Click on the plane to select it, then go to "Create UVs->Automatic Mapping" and click the box beside it. A window will pop up with a bunch of options for how you want to generate your map. You can experiment with what the options to later, but for now just make sure it's set up like so:
Your UV Texture Editor window should now look something like this:
What you're seeing is every face in the model laid out in front of you. This, is your UV map. We'll get more into how you can change your UV map shortly, but first we'll take a look at how this map behaves with the plane object in Game Maker. Take note that some faces are overlapping in the automatically generated UVs. Sometimes this is OK, but if you want every piece separate, just hold down the right mouse button in the UV Texture Editor, and select "Polygons->Layout". This will lay out all the faces separate.
In your UV Texture Editor, click "Polygons->UV Snapshot". A window will pop up asking you how you want to save the snapshot. Click "Browse" and locate the folder where you have your mosaic light gmk and your plane model, enter "PlaneTexture" in the name field, and click save. This sets the path so that Maya knows where to save the file. Under image format make sure you select JPEG, BMP, or PNG. Now, click OK. You will now have a UV image in your mosaic light folder.
The next step, is to re-export the model, since you changed its UV configuration when you set up automatic mapping. By default, Maya doesn't allow you to export .obj files, so you need to enable the ability to do so. Click "Window->Settings/Prefrences->Plug-In Manager". Locate "objExport.mll", and check the "Loaded" and "Auto load" boxes. You can now export .obj files. Click "File->Export All", and select OBJexport from the list of export file types. Export your newly mapped plane model into your mosaic light folder, overwriting the original objModel.obj file.
Load up Game Maker and open up your mosaic light gmk. Double click the object "obj_3d_model", and open up the code in its create event. In the line that says:
model = createFromObj("mosaic.obj",false);replace "mosaic.obj" with "objPlane.obj" (make sure you're model file is in the same folder as mosaic light!). If you try testing the game now, you should see the plane rotating around with an odd colorful texture. You can press "L" to enable lighting and see what the model looks like with lighting. The next step is to load up the UV Map we saved. Open up the sprite named "tx_mosaic" and load the PlaneTexture.jpg into it. If you're using Game Maker 8, make sure you un-check "Remove Background" in the file load window. If you were to run your game right now, you would notice that the lines on the texture don't match up with the shape of the plane. The reason for this, is that your textures always load in upside down. Open up your plane texture in the image editor and flip it vertically. If you run the game now, the texture should match up nicely with the plane. Congratulations, you've completed the first part of UV Mapping!
Part 2- Patience, Persistence, and Texturing Your ModelNow that we've applied a wire frame texture to our plane, it's time to give it some color. To do this, you will need to be running Maya and your image editing program at the same time. Fire up your image editor, and load in your plane texture. All of the faces in this texture are correctly mapped to the plane model, all we need to do now is draw what we want on them. This is where keeping Maya open comes in handy. If you click on a face in your model (Hold right click above the model and select "Face" if your not in face mode) you will see that face light up in the UV Texture editor. This way, you will know what you need to draw on each face.
A few tips for drawing onto your models:
- If your image editing program has layers, USE THEM. Put your UV Texture on the top layer and make it semi transparent, and draw on another layer below it. This makes it easy to draw into the faces, just make sure you delete/disable the UV Wire frame layer before you export the final image. Also, if you have layers make sure you keep everything on it's own layer, you never know when you might want to change something.
- If your model is mostly one color, color the whole UV in that color first, then add detail where needed. For example, our plane model is going to be mostly one color, so you can fill the canvas all one color to start.
- Make sure you go over edges of the UV with what you draw, and don't worry about any mess lying around outside of the UV Faces. If it's not in the lines, you won't see it.
- Leave details to the end, focus on coloring and texturing the faces first.
- If you want to add some realism to your texture after you're finished coloring it, try importing real world textures such as metal or wood, and overlay them over different spots. Then, saturate them and increase their transparency. You'll be surprised how well the real world textures bind with your UV maps.
- SAVE OFTEN! This is a big one, there are few things worse than spending a few hours texturing a complicated model only to have a crash at the last moment with no save file.
- Listen to music, It will help keep you sane while working on complex models!
I would really like to tell you that there's a better way to do this, but unfortunately, this is how it's done. There are different methods for achieving the same effect, but they require more work in other areas. One other way of setting up your UV map is to actually sew the UV pieces together in Maya like puzzle pieces, but we'll cover that later. I strongly urge you to try texturing the plane yourself, but if you're stuck you can get my finished texture here.
Part 3- Normals, and the Wonderful World of Illusion
If we take a look at our plane at this point, we'll notice that the rounded parts of our plane are feeling the ragged blocky goodness of low-poly modeling. This can actually be fixed by adjusting the models normals, giving it a more naturally rounded look. All you need to do is, using the face tool, select all the edges in your model that you want to be smoothed out (or the whole thing if you want, though a nice effect can sometimes be achieved from not smoothing specific edges). Once you have the faces selected, click "Normals->Soften Edge". After you've softened the edges, re-export the model again, and take a look at it in mosaic light. You'll notice that your model looks alot smoother, and you didn't have to add any faces.
The plane model with smoothed normal edges and real life photo texture overlay
Part 4- The Sewing Circle, More Fun With UVsI mentioned that there is another way to set up the UVs on your model. This method involves creating an automatic texture map like before, but you alter the map to be more convenient for texturing purposes. This method is also quite time consuming, and I recommend it more for parts of your model that need seamless texturing, such as faces or clothing.
If you go into the UV editor and select an edge on the outside of a piece (Right-Click and enter edge mode if you haven't already), another edge will light up somewhere on the UV. The edge that lights up is actually the exact same edge, but it belongs to a different part of the UV map. What needs to be done, is that edge and everything belonging to it needs to be oriented and brought up besides its partner, after which you can sew the edges together to create a seamless joint between the 2 UV faces. Sewing is done by selecting the edge you want to sew, and clicking the button that looks like tape going across checkerboard paper.
Sewing 2 parts of the planes UV's together
To orient the pieces, hold right-click in the UV editor and click UV. Now you can click or drag select UVs. Pressing "W", "E", and "R" allows you to swap through the move, rotate, and scale tools respectively. You can move the pieces off to the side to work with them if you want, but make sure to move them back into the square when you are finished with them.
With the ability to move UVs, you can actually bring an image file in as a texture and adjust your UV's to work around it, allowing you to work backwards from the method we already learned. To apply a texture to the model, just select it, right click it, and press "Assign New Material->Lambert". In the attribute editor, click the checkered box next to color, and select "File" from the pop up menu. Then, click the folder icon and browse to your plane texture file and open it. Your texture will now show up in the UV Texture Editor, and you will be able to move your UVs around it to position it on the model. If you can't see the texture once you've loaded it, just push "6" on the keyboard and it should show up.
Part 5- Closing StatementsProperly texturing 3d models for Game Maker takes time, but the final product is worth the extra effort. Although this tutorial was written based around Maya, the 3d concepts mentioned here hold true no matter what 3d modeling software you use. I hope this tutorial has helped you shed some light on how 3d models work, and I hope all your questions about texture mapping have been answered. Don't be afraid to leave a comment if there's something you don't understand, I'll be happy to explain whatever it is you need to know the best I can. Also don't be afraid to request UV Mapping tutorials for different 3d modeling software, I'll do my best to answer your requests. Good luck in the future, and good luck with Game Maker's 3D engine :D.
Edited by superjoebob, 20 February 2012 - 09:08 PM.