Texture on only one side/face of box

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.
Post Reply
telengard
Posts: 5
Joined: Wed Aug 29, 2007 4:18 am

Texture on only one side/face of box

Post by telengard »

Hi there,

I've been searching the forums for some info on this and didn't turn up anything.
I have a simple rectangular box and I'd like to apply a texture just to one side.
I'd like to do it programatically rather than in a modeling program since the program will eventually have an editor where someone could change select a different image to put on it.

Is this possible?

any info would be awesome,
~telengard
Still stuck in the 1980s. My mame cabinet and 8 bit game room:
http://users.adelphia.net/~bsturk
ansu832001
Posts: 95
Joined: Thu Mar 01, 2007 6:39 am

Post by ansu832001 »

Hi,

Are you Creating this Rectangle box as four different Planes(Objects),if so then on MouseDown get the object selected and apply texture as

selectedObj.GetMaterial(0).Texture1=device.VideoDriver.GetTexture(ImagePath);

the above code is in .NET,you can easily convert the same to C++.

Best Regards.
telengard
Posts: 5
Joined: Wed Aug 29, 2007 4:18 am

Post by telengard »

ansu832001 wrote:Hi,

Are you Creating this Rectangle box as four different Planes(Objects),if so then on MouseDown get the object selected and apply texture as

selectedObj.GetMaterial(0).Texture1=device.VideoDriver.GetTexture(ImagePath);

the above code is in .NET,you can easily convert the same to C++.

Best Regards.
Hi there,

Thanks for the response.

I'm just adding a cube like this

ISceneNode* node = smgr->addCubeSceneNode( 1000, NULL, -1, vector3df( 0, 0, 0 ), vector3df( 0, 0, 0 ), vector3df( 100.0f, 0.1f, 100.0f ) );

I've also tried w/ a model I exported from blender in 3ds format.

The key is I need to programatically do this. So selecting with a mouse isn't an option.

~telengard
Still stuck in the 1980s. My mame cabinet and 8 bit game room:
http://users.adelphia.net/~bsturk
ansu832001
Posts: 95
Joined: Thu Mar 01, 2007 6:39 am

Post by ansu832001 »

Hi,How do you decide which side to ApplyTexture??

Best Regards.
telengard
Posts: 5
Joined: Wed Aug 29, 2007 4:18 am

Post by telengard »

ansu832001 wrote:Hi,How do you decide which side to ApplyTexture??

Best Regards.
On the top is where I'd like it, but I have no idea how to do it.

~telengard
Still stuck in the 1980s. My mame cabinet and 8 bit game room:
http://users.adelphia.net/~bsturk
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You can't acomplish what you want with cube you get with addCubeSceneNode function.
Firsth because there is no way howe to acces UV coordinates of indiviadual cube vertices.
Second because even if you could sides of this cube share vertices between each other.

There are two ways to go:
1. model your own cube and load it. cube sides should not share vertices so you can set UV coordinates of sides independently. You also may want to make each side to use its own material. One material per side.

2. create your own custom cube scene node.
Look here for inspiration:
http://irrlicht.sourceforge.net/tut003.html
or here:
http://irrlicht.sourceforge.net/phpBB2/ ... light=cube
ansu832001
Posts: 95
Joined: Thu Mar 01, 2007 6:39 am

Post by ansu832001 »

Okie,Create the Rectangle as Four Different Planes

p1(left)+p2(top)+p3(right)+p4(bottom)=Rectangle.

Now Apply Texture to any one of the Plane(note,plane is also an Object)

Note : each plane is created as two Triangles

i'll give you idea for creating one plane

Vertex Buffer= { define our points}
index Buffer={Define the triangles}

in the above manner add four planes,but to directly apply texture to only one side of cube(created as AddCubeSceneNode) you have to play with Texture Coordinates.

Hope this is clear
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just a short note: A box has at least 5 sides, most have 6.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

A box with 5 sides? ...are you sure? I would say all boxes must have exactly 6 sides... left + right + front + back + top + down = 6.
ansu832001
Posts: 95
Joined: Thu Mar 01, 2007 6:39 am

Post by ansu832001 »

iam soory i forgot that,i was in some other world while posting this,anyway now i correct myself......Create the Rectangle as six Different Planes

p1(left)+p2(top)+p3(right)+p4(bottom)+p5(front)+p6(back)=Rectangle.

Now Apply Texture to any one of the Plane(note,plane is also an Object)

Note : each plane is created as two Triangles

i'll give you idea for creating one plane

Vertex Buffer= { define our points}
index Buffer={Define the triangles}

in the above manner add four planes,but to directly apply texture to only one side of cube(created as AddCubeSceneNode) you have to play with Texture Coordinates.

Hope this is clear
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If it's a box you can put things in it would be enough to have 5 sides, a closed box should have 6, though :wink:
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Well you'r right, that would be wery practical box :)
telengard
Posts: 5
Joined: Wed Aug 29, 2007 4:18 am

Post by telengard »

ansu832001 wrote:Okie,Create the Rectangle as Four Different Planes

p1(left)+p2(top)+p3(right)+p4(bottom)=Rectangle.

Now Apply Texture to any one of the Plane(note,plane is also an Object)

Note : each plane is created as two Triangles

i'll give you idea for creating one plane

Vertex Buffer= { define our points}
index Buffer={Define the triangles}

in the above manner add four planes,but to directly apply texture to only one side of cube(created as AddCubeSceneNode) you have to play with Texture Coordinates.

Hope this is clear
Ahh, 4 planes is a good idea, or just one plane on top of my rectangle (directly) although that is still 2 sides for each plane. Great idea! I'll read up on Texture Coords.

~telengard
Still stuck in the 1980s. My mame cabinet and 8 bit game room:
http://users.adelphia.net/~bsturk
Post Reply