Jump to content


Photo
* * * * * 2 votes

Game Maker 3d Model Importing/texturing Tutorial


  • Please log in to reply
20 replies to this topic

#1 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 16 February 2010 - 09:01 PM

  • 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
Additional Info
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 Tutorial

This 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:

Posted Image

Your UV Texture Editor window should now look something like this:

Posted Image

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 Model

Now 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

Posted Image

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.

Posted Image

The plane model with smoothed normal edges and real life photo texture overlay


Part 4- The Sewing Circle, More Fun With UVs

I 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.

Posted Image

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 Statements

Properly 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.


Search Tags
  • GMCTUTORIAL
  • GMC3D
  • GMC3DMODEL
  • GMCUVMAPPING

Edited by superjoebob, 20 February 2012 - 09:08 PM.

  • 9

#2 xot

xot

    GMC Dismember

  • GMC Elder
  • 4775 posts
  • Version:GM:Studio

Posted 18 February 2010 - 03:28 AM

Outstanding tutorial!
  • 1

#3 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 19 February 2010 - 11:00 PM

Thanks xot, that means a lot coming from you :). I notice that this tutorial isn't getting a lot of readers though, probably due to the fact that it is based around Maya. Maya is a pretty expensive program, I'm aware of that. So, I've decided to adapt my tutorial for users who don't have/can't afford Maya! So I would like to present:

Superjoebob's Right Proper All Purpose Game Maker 3d Model Texturing and Importing Tutorial, Adapted for Wing's 3d


What you'll need:
  • Game Maker 7 or 8 Pro (6 may be fine as well, I'm not completely sure though)
  • Wings 3d(100% Free!)
  • Mosaic Light (Game Maker .obj importer, incredibly useful, credit Zoltan Percsich for this one, he certainly deserves it)
  • 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 (Again, this is very important)

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 Wings 3d and starting a new project. Go to "File->Import->Wavefront (.obj)", and import the plane model provided for this tutorial. When it loads you should see the plane in the viewport. We'll start by opening up the UV Map editor. Drag select all the faces on the plane, and right-click. Select ".UV Mapping." from the drop down menu. 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.

First of all, we need to generate the UV map. Roll the mouse wheel down in the UV window to zoom out, you should see the plane in 3d. Drag select all of its faces, right-click, and select "Segment By", then select "Projection". Now, right-click the model in the UV Mapper again, and select "Continue", then select "Unfolding". You should now see something like this:

Posted Image

What you're seeing is every face in the model laid out in front of you. This, is your UV map. Now, we'll take a look at how the UV map behaves with the model in Game Maker.

In the UV Texture Editor, right-click and press "Create Texture". For the purpose of this tutorial, select 1024x1024 in the size drop down, and press OK. If everything worked correctly you will notice that the background of your UV Editor turned white. Now, in your main Wings 3d window, click "Window->Outliner".

Posted Image
The Outliner

A list of components in your scene will pop up. One of the components should have a white square below it, this is your texture map. Select it, right-click, and click "Make External". A window will pop up asking you how and where to save the image. Select JPEG, and save the image as "PlaneTexture" into 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. In the main Wings 3d window, click "File->Export->Wavefront (.obj)" and overwrite the old plane model file. Now we will see how the model behaves in Game Maker.

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 Model

Now 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 Wings 3d 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 Wings 3d open comes in handy. In the UV Texture editor, you will see 4 cubes up at the top. Click the one that looks like a cube with one red face. Now if you click on a face in your model in the main Wings 3d window you will see that face turn white 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.



Part 3- Normals, and the Wonderful World of Illusion

Posted Image

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. Go back to the Wings 3d main window. You will see 4 cubes at the top, click the one that looks like a cube with one red edge. This will allow you to select edges instead of faces. Drag select all the faces (if they are red they are selected), and right-click one edge and press "Hardness", then click "Soft". This will soften all the edges in your model to make the lighting look smoother. You can also harden certain edges if you want, depending on the effect you want to achieve. 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.

Posted Image

The plane model with smoothed normal edges and real life photo texture overlay


Part 5- Closing Statements

Properly texturing 3d models for Game Maker takes time, but the final product is worth the extra effort. 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.
  • 6

#4 pokemonxs

pokemonxs

    GMC Member

  • New Member
  • 247 posts

Posted 02 April 2010 - 10:59 PM

Did I miss the part where it say how to import the models into Game Maker?

Awesome tutorial though, nice work.
  • 0

#5 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16059 posts
  • Version:GM:Studio

Posted 03 April 2010 - 02:34 AM

Did I miss the part where it say how to import the models into Game Maker?

Awesome tutorial though, nice work.


mosaic lite is the gml script to load the obj... I prefer to use a converter, like GMModelFix or Mosaic Marzipan to convert to actual d3d gm model file instead of using mosaic lite to load obj files. it's faster.

Edited by icuurd12b42, 03 April 2010 - 02:37 AM.

  • 0

#6 pokemonxs

pokemonxs

    GMC Member

  • New Member
  • 247 posts

Posted 04 April 2010 - 09:52 PM

Ahh... I see.

(well not really, 3D has never been my thing ^_^)
  • 0

#7 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 16 June 2010 - 12:16 AM

Thanks for the responses :).

Throwing all my better judgment out the window, I've decided to bump this topic. I've included information in here that I feel many new 3d users don't know, so I'd hate to see my time go to waste :(.
  • 0

#8 Fruckert

Fruckert

    GMC Member

  • New Member
  • 72 posts

Posted 23 June 2010 - 08:17 AM

I find it kind of funny that this is the best UV mapping information that I've found on the net so far.
I'll be sure to keep everything here in mind once I start making my own models to use in Ogre.
  • 1

#9 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 3535 posts
  • Version:GM:Studio

Posted 23 June 2010 - 11:03 AM

Excellent tutorial, trough, as you said, its written for maya and most people cant afford a piece of sotware like that.

Its fun, because you have done everything i do every time i must add a 3d model onto gamemaker :P, even the createFromObj() script! If you check my signature youll see a Pokemon 3D engine in wich i did the exact same thing you are doing in here, but with 3DsMax ( The steps remain the same anyway ).
The only problem i found in this method is the polygons count... most of theese programs are made for high quality models, it gets really hard to keep polygons in a low level so gamemaker can support it.. (alright, i admit it, sometimes i forget thtat my models mustnt be too fancy :P ) to fix this i ussually try to remove all hidden faces, but its still a pain in the guts for more complex games, where there are multiple models and tasks.


Edit: I where a staff memeber i would move this to 'staff choice' right away.. ^_^

Edited by manuel777, 23 June 2010 - 11:06 AM.

  • 1

#10 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 27 June 2010 - 04:25 AM

I find it kind of funny that this is the best UV mapping information that I've found on the net so far.

Thanks, thats why I made a tutorial ^_^. Generally you need to look through 2 or 3 seperate tutorials to get enough information to properly UV models, and they often cover all kinds of irrelevant information to confuse things further.

Excellent tutorial, trough, as you said, its written for maya and most people cant afford a piece of sotware like that.

There's actually a Wings3D(free) version of the tutorial posted below the Maya version. Unfortunately I wrote it after the Maya tutorial, so they're not in the same post.

Edit: I where a staff memeber i would move this to 'staff choice' right away.. ^_^

Well I would really appreciate if you would reccomend it :). I used to be seriously ignorant about GM's 3d before I learned this stuff, I would hate for anyone to have the same problem.
  • 0

#11 tdkr80

tdkr80

    GMC Member

  • GMC Member
  • 270 posts
  • Version:Mac

Posted 17 December 2010 - 02:56 PM

...WHAT THE FRUIT STICK

you've just provided an amazing tutorial that is amazing ... and there's not enough replies on it at all.
I'll be doing this my self but once I get my mate to fix up my models, and I'll be doing this right away.

I'll be sure to contact you if this doesn't work out.

- Tdkr80.
  • 0

#12 1234thisisfun

1234thisisfun

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM:Studio

Posted 15 May 2011 - 10:47 PM

i love 3d!

Edited by 1234thisisfun, 15 May 2011 - 10:49 PM.

  • 0

#13 1234thisisfun

1234thisisfun

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM:Studio

Posted 15 May 2011 - 10:48 PM

SWEET; 3D STUFF


LOVE IT
  • 0

#14 Martho

Martho

    GMC Member

  • GMC Member
  • 159 posts
  • Version:Unknown

Posted 11 September 2011 - 11:10 PM

Hmm... The tutorial is great but when I try to do it with my own model the model loads fine into wings but when I open up the UV mapper it just shows a cube.
EDIT: It seems the problem is that my model has multiple objects, I will go make a topic elsewhere as this isn't the place for this.

Edited by Martho, 12 September 2011 - 12:13 AM.

  • 0

#15 beeproductions

beeproductions

    Helping gmc users

  • GMC Member
  • 1316 posts
  • Version:GM:Studio

Posted 14 September 2011 - 04:16 AM

Well this is just amazing..Just wanted to tell you Good Job mate:)
  • 0

#16 blanton

blanton

    GMC Member

  • GMC Member
  • 121 posts

Posted 19 November 2011 - 06:02 PM

mosaic light - 404 error not found ...
  • 0

#17 JonathanPzone

JonathanPzone

    GMC Member

  • GMC Member
  • 1215 posts
  • Version:GM:Studio

Posted 20 November 2011 - 04:13 AM

mosaic light - 404 error not found ...


Mr. Percsich has recently removed his plethora of GM tools. I'm sure there are other .OBJ importers around the forums.
  • 0

#18 superjoebob

superjoebob

    YM2612

  • New Member
  • 1515 posts

Posted 03 February 2012 - 06:59 PM

I've replaced the missing link for Mosaic Light for anyone having trouble finding it elsewhere.
  • 0

#19 theg721

theg721

    G Dawg

  • GMC Member
  • 1959 posts
  • Version:GM8

Posted 16 February 2012 - 10:00 PM

I've replaced the missing link for Mosaic Light for anyone having trouble finding it elsewhere.


Still not working.
  • 0

#20 Hazard94

Hazard94

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM8

Posted 13 May 2013 - 04:16 AM

I think something is wrong with the code.. When you import a .obj file it is rotated 90° on the X axis.. If you make a cylinder with 100 height in the Z axis then GM will show you the 100 height in the X axis.. Do you understand what I mean? Do you know how to fix this? because rotating the object before exporting is really annoying.. thanks


  • 0

#21 MrKevMan

MrKevMan

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM:Studio

Posted 03 October 2014 - 06:58 PM

Yes, rotating the object is just as annoying as having to flip and mirror your texture map.  Since GM 3D isnt very robust, you have to a lot of prep work for it to happen.  Im pretty much only going to use the 3D feature for 2.5D projects and use rendered images for most objects.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users