Adding texture to cube

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
StargateSG1
Posts: 15
Joined: Sun Aug 22, 2004 2:06 pm
Location: Estonia

Adding texture to cube

Post by StargateSG1 »

Hi,

How to add texture to only one side of a cube model?
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

UV map it?
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
StargateSG1
Posts: 15
Joined: Sun Aug 22, 2004 2:06 pm
Location: Estonia

Post by StargateSG1 »

Umm... sorry but what's that :oops:
StargateSG1
Posts: 15
Joined: Sun Aug 22, 2004 2:06 pm
Location: Estonia

Post by StargateSG1 »

Could somebody please help me, I am making a GTA2 like top down game...

I want to add a texture to only on the top of the cube. So it looks like only a texture. Why I want it? Because there are no functions to rotate textures by given degree. However, it is possible with 3D objects.

One way is to make a big texture with my Car picture in the center of it. But how to put it on the cube the way it only is on top of the cube and not on the other sides. The other sides must be transparent.

I want to know how the texture is placed on the object. For example when adding texture to a human model then the texture must be placed very precisely. I just don't understand how it works. What is the coordination of the object(3D model) where the texture is placed.

:?:
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

i think you should use a normal texture for the whole cube. If you use a compressed format like jpg and let the other parts white, i think the white parts are compressed to something like some bytes and thats no problem. And the best like i wrote before, if you later want not only look from above, you can paint the white parts, too and have real 3D.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Each vertex of model have its coordinates in 3d space + it have its coordinates in texture space ..its caled UV coordinates.

Texture space is only 2d with U=0, V=0 in upper left corner of texture and U=1, V=1 in bottom right corner. Means that regardles on pixel size, texture have allways size of 1,1. Even texture of 256/128 pixels is 1,1 big.

U is horizontal coordinate while V is vertical.

To edit UV coords of model there are editors called UV editors. Most of modeling progs. have one built in. There are also pure UV editors. You can download one freeware one on my site. Its called LithUnwrap and its one of the best.

Another freeware one is here: http://www.uvmapper.com/ but I have no experience with this one.

Bye the way from what you described I think that simple plane (box) would serve you better than cube since you need only top side of it.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

You mean a cube created with Irrlicht or by a 3d modeling package? (BTW, does Irrlicht have commands to create basic geometrical solids, or everything has to be modeled in a package and imported?)

The easiest way is to create your cube (in something like 3dsmax or maya or even milkshape3d), then go into face/polygon selection mode and apply your texture to only one of the faces (side). Then export your model as an Irrlicht compatible one preserving your UV coordinates and finally load it.

cheers!
Image
StargateSG1
Posts: 15
Joined: Sun Aug 22, 2004 2:06 pm
Location: Estonia

Post by StargateSG1 »

arras:

Man, you made it quite clear. Thanks :D

I'll take a look at those programs.


afecelis:

The cube is made in anim8or and exported to .3ds.

It seems to be impossible to create box with driver->draw3dBox() and add texture to it.

The problem is that I have very small knowledge of 3d modeling tools.
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

afecelis wrote:(BTW, does Irrlicht have commands to create basic geometrical solids, or everything has to be modeled in a package and imported?)
It has. Check the CustomSceneNode example.
To add a standard cube (http://irrlicht.sourceforge.net/docu/cl ... er.html#a3):

smgr->addTestSceneNode();

Though this contains some bugs with the normals (so textures get stretched and placed wrong), but are fixed in IrrlichtNX :).
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

There is official help in pdf format somevere on the home page of Anim8tor. Look at it.

What you need is probably under:

Applying multiple materials
Material editor
Texture editor
Texture mode


Oh ...one more thing. Something so simple as cube or plane you can do directly in Irrlicht, just look at Custom scene node example.
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Why not just use a texture?
The Robomaniac
Project Head / Lead Programmer
Centaur Force
StargateSG1
Posts: 15
Joined: Sun Aug 22, 2004 2:06 pm
Location: Estonia

Post by StargateSG1 »

OK, but when I add a texture to cube in anim8or then will it be added inside the model file or not? If I remember correct, it was not added into the model file so
I have to load it "externally" via node->setMaterialTexture(). Or does the model file store the coordinates of the texture(UV mapping) and when I load the model in irrlicht and then load and add the texture, then will it be correctly placed onto the map? And what happens if I want to add many texture to a model?

For example:

I create a cube or plane in anim8or. Add it a texture on the top side. Then I'll add another to the right side for example. Ok, now I'll export it to .3ds. And what I see is three files: model file and two texture files. Now how do I add it to irrlicht project the way everything looks exatly like in anim8or? I can't set the material texture twice, can I.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

@bal: thnx for the links! pretty interesting stuff.
Image
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

afecelis wrote:@bal: thnx for the links! pretty interesting stuff.
Np, but could you check your PM's please :) ?
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

StargateSG1>> no, texture is not inside model file, it contain only data about vertex position, normals, UV and possibly animation. But normaly it links to texture file which usualy have the same name like model (not neceserily). Normaly when you load model in to the Irrlicht, it automaticly load texture too if its at the right path (usualy along model file)

If not, you have to load texture separately. Bye the way, you can load any texture on any model if it have been UV maped. And in any time during your program is running you can change texture.

As for several textures on one model ...up to my knoweledge you can use only one texture in Irrlicht for one model (you can use more but you have to apply them to diferent layers which owerlap so its not what you ask about)

If you want to have more, you have to put those two or more textures in to the one texture file (for example like diferent tilles) and UV map your model in way that diferent sides of cube use diferent parts of texture (diferent tiles).

Or you have to broke your model and load its parts separately and make them child to each other.
Post Reply