Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / [Tutorial] UVMapping and Lithunwrap

Author
Message
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Oct 2008 03:44 Edited at: 31st Aug 2010 02:48
UV Mapping
Revamped 4/16/09

I've seen a few good tutorials on basic UV mapping out there, like Screwed Over's short how-to for UV Mapper classic. This one's designed for Lithunwrap, which is a bit different.

I'll be using Lithunwrap and Blender, but the theory should be applicable to other modeling programs as well.

Lithunwrap: (Free) http://www.filefront.com/51766/lithunwrap_setup.zip
Blender: (Free) http://www.blender.org


Intro

I'm sure almost everyone here has made a model at some point and said, "Sweet, now I can make my own awesome game models!! Wait, why is it all grey like that?" Well, most people can probably figure out that it needs a texture. But how do you go about making a texture for it?

The key to texturing models is a UV Map. The UV Map basically tells your program how to take an image, which you can make, and apply it properly as a texture on the model.


Part 1 - The Model

First you need to make sure your model is going to show up properly in DarkBASIC or wherever you're putting it. One major issue that can affect your model's appearance is having the normals switched around. This means that some of your faces may be facing the wrong way, and they won't show up properly ingame.

To check the normals in Blender, while in edit mode, scroll over to "Mesh Tools 1" on the bottom toolbar. Press the button that says "Draw Normals." You should see some light blue lines coming out of your model's faces now (You can use the NSize box to make them longer if you need to).

A face's normal direction is essentially the direction that face points when it is rendered. In Blender, both sides of the face are always rendered, but in DarkBASIC, when the model is rendered only the normal direction will show up. If a face's normal is facing the wrong way, the face will only be visible from inside the model!

The lines go in the same direction as the face's normals, so if you see a line on a face (facing outwards), that means that face is facing the right way. However, when you only see a blue dot facing outwards, that means you have the normal flipped. If you find any blue dots, select all faces with A and press Ctrl-N. Hopefully all the normals should now be the right way: if they aren't, you may need to flip some of the faces manually with W->Flip Normals.


These normals point the WRONG way - inside the model.


The Draw Normals button.

Once you have all the normals in the right direction, go to 'File->Export' and choose DirectX. Set the exporter to use "Left-Handed System" and to "Swap YZ". Save the model somewhere you can find it easily.


Part 2 - The UV Map

Now for the tricky part. Open up your model in Lithunwrap ('File->Model->Open'). Lith will probably tell you the model has no UVs, but that's supposed to happen, don't let the 'error' sound scare you.

To create the UVs, go to 'Select->All', and then 'Tools->UV Mapping'. You can see that you have a few options here.

Decal - This will ask you for a direction you want to texture the model from, and a few other options. Basically, it only allows you to texture one side of the model. This is best used for - yep, you guessed it - decals. It can also come in handy for things such as 3D HUDs, where only one side is visible.
Face - A very difficult way to texture your model. This puts each face seperately on the UV Map, so essentially you texture each face individually. You really want to avoid this - it is nearly impossible to tell what the heck each face is from when you do this.
Planar - Similar to decal, but lets you texture two sides of the model - a front and a back. Not used often, as even seemingly 2D objects like signs often have an edge in 3D.
Box - Most frequently used option. It allows you to texture the top, bottom, left, right, front, and back of the model seperately.
Cylindrical - Maps the texture onto a cylinder, great for cylindrical objects like arrows and barrels.
Spherical - Maps the texture onto a sphere. In the same way as cylindrical mapping, usually best for spherical objects only.

Select whichever fits your model best. Usually this will be whatever shape best matches the shape of your model. If in doubt, go with Box. You should note that after you've done this for the whole model, you can afterwards select different parts of the model and map them different ways. For example, say you had a cube wielding a cylindrical gun. You would start with a Box map, then select all the parts of the gun and do a cylinder map. Just make sure you properly space out all the parts after doing this.

Now go to 'Select->None'. You can now manipulate each part of the UV map individually. Drag a box to select different faces. You can scale, rotate, and flip parts of the map with the options under the 'Edit' menu.

Your goal to make a good UV map is to have as much of the sheet covered with faces as possible - blank space is wasted bytes in your video memory in-game. Be careful not to overlap parts of the object on the UV map - this will cause the overlapping parts to display the exact same texture.

On occasion, overlapping parts of the UV map can help you save valuable texture space. An example of this would be this target model I created:


The target looks exactly the same on both sides. Therefore, to allow a more detailed texture, I box-mapped the object and put the front and the back directly on top of each other. This gave me more space to enlarge other stuff, and also saved me from having to texture the front and back seperately.

Once you're done laying out the UV Map, go to 'File->Model->Save'. Save it as a DirectX - compressed binary will do for import into DBPro. Then go to 'File->UV Map->Save'. Save that as a bmp or tga at the size you want your texture.


Part 3 - The Texture

Open the bmp or tga you saved in your favorite image editing program. Now, by whatever means you like, you get to draw the actual texture over the UVs in the image. The white lines on the image, as you should have figured out, are the edges on the model. Use those to tell you where to draw the texture.

When you're done drawing, go ahead and save the image again. At this point, you have a UV Mapped model and a completed texture ready to be applied to it. Yay!


Using Your Model

Using this model in your DarkBASIC Pro or DarkBASIC games is simple. Load the model using LOAD OBJECT. Load the texture using LOAD IMAGE. Texture the model using TEXTURE OBJECT. Ta-da!


Happy modelling!


Latest progress: Fog of War implemented; frustrated by pathfinding >.>
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 17th Oct 2008 04:36
Pretty good tutorial, but...

Quote: "Load the model using LOAD MODEL."


LOAD MODEL?

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 19th Oct 2008 02:37
lol, thanks Andrew
Quik
16
Years of Service
User Offline
Joined: 3rd Jul 2008
Location: Equestria!
Posted: 19th Oct 2008 02:43
great tutorial!

Quik, Quiker than most
Jesusaurisrex
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location: the heart and soul of all
Posted: 20th Oct 2008 04:35
great tutorial, but pictures always help!

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 20th Oct 2008 04:47 Edited at: 20th Oct 2008 05:07
Hehe, thanks guys, I'll take some screenshots...

Edit: Okay, I put up a few images that should help.
timmie124
16
Years of Service
User Offline
Joined: 29th Feb 2008
Location: some were in time
Posted: 21st Nov 2008 04:01
hey thanks for sending me this but um how do you import the image

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 24th Nov 2008 04:24
Import which image? Into what? Sorry if I'm missing the obvious

timmie124
16
Years of Service
User Offline
Joined: 29th Feb 2008
Location: some were in time
Posted: 26th Nov 2008 22:40
i must be the one missing the obviouse then i thought this did unraping but i was wrong

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 24th Dec 2008 06:14 Edited at: 24th Dec 2008 06:14
Everything in the UV Mapping dropdown is greyed out. I did open the model, its a .x binary!

And, you're giving your model it's stolen virginity back by unraping it?
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 24th Dec 2008 15:40
That's weird. Did you remember to hit Select All?

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 26th Feb 2009 10:18
Thanks bmaczero, one picture at the begin explain what miles of text never did, what the normals did in your model.

cheers.

Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-11-25 07:40:16
Your offset time is: 2024-11-25 07:40:16