*Help!* Texturing a cube
3 posters
Page 1 of 1
*Help!* Texturing a cube
I'm after a bit of help, I'm tring to build a bridge object that requires the parapit to be topped with a stone, I've decided the easiest way to do this is to use a cube but I can't get the texture right, if anyone can give me some guidance as to how the texture needs to be coded I'd appriciate it... the code for the cube it's self is as below.
[Meshbuilder]
Cube 1.05,0.15,0.55
Translate -7.5,7.65,2
Color 100,0,0
It's in B3D format, essentialy, what I need to do is replace the color with a texture, just repeated once on all 6 faces, if I'm making sense.
Thanks in advance!
Adam
[Meshbuilder]
Cube 1.05,0.15,0.55
Translate -7.5,7.65,2
Color 100,0,0
It's in B3D format, essentialy, what I need to do is replace the color with a texture, just repeated once on all 6 faces, if I'm making sense.
Thanks in advance!
Adam
Re: *Help!* Texturing a cube
Doesn't quite work like that.
You will never get the texture to work on all 6 faces.
Let me try to explain a little:
Your cube consists of 8 vertices, each of which may have texture co-ordinates assigned to them.
First, let's take a sample cube object-
If you load this cube into Object Viewer, you'll find that the cube textures correctly on all 4 sides, but not on the top or bottom.
Why is this?
First, let's look at an illustration showing the vertex numbers:
This means that if we were to have constructed our cube manually, we'd require the following Face statements:
Let's therefore think about the texture co-ordinates that apply to the top:
As you can see, the texture co-ordinates all have the Y value of 0.
A similar case applies to the bottom, and as you can therefore hopefully see, it's physically impossible to texture two faces of a cube, which will always be directly opposite one-another
Playing with the co-ordinates will allow you to position these two faces on the top/ bottom, left/ right etc.
The only way around this is to create your cube manually with additional vertices for the top/ bottom, or to use another face a millimeter or so above the cube.
Cheers
Chris Lees
http://www.bvecornwall.co.uk
You will never get the texture to work on all 6 faces.
Let me try to explain a little:
Your cube consists of 8 vertices, each of which may have texture co-ordinates assigned to them.
First, let's take a sample cube object-
- Code:
[MeshBuilder]
Cube 3.8,4.69,1
Translate 3.5,-5,24
[Texture]
Load ..\common\redbrick2.png
Coordinates 0,2,0
Coordinates 1,2,4
Coordinates 2,0,4
Coordinates 3,0,0
Coordinates 4,3,0
Coordinates 5,3,4
Coordinates 6,2,4
Coordinates 7,2,0
If you load this cube into Object Viewer, you'll find that the cube textures correctly on all 4 sides, but not on the top or bottom.
Why is this?
First, let's look at an illustration showing the vertex numbers:
This means that if we were to have constructed our cube manually, we'd require the following Face statements:
- Code:
;;FRONT
Face 0,1,2,3
;;LEFT SIDE
Face 5,4,3,2
;:REAR
Face 4,5,6,7
;;RIGHT SIDE
Face 7,6,1,0
;;TOP
Face 1,2,5,6
;;BOTTOM
Face 7,4,3,0
Let's therefore think about the texture co-ordinates that apply to the top:
- Code:
Coordinates 0,2,0
...
Coordinates 3,0,0
Coordinates 4,3,0
...
Coordinates 7,2,0
As you can see, the texture co-ordinates all have the Y value of 0.
A similar case applies to the bottom, and as you can therefore hopefully see, it's physically impossible to texture two faces of a cube, which will always be directly opposite one-another
Playing with the co-ordinates will allow you to position these two faces on the top/ bottom, left/ right etc.
The only way around this is to create your cube manually with additional vertices for the top/ bottom, or to use another face a millimeter or so above the cube.
Cheers
Chris Lees
http://www.bvecornwall.co.uk
Re: *Help!* Texturing a cube
Thanks for such a detailed reply, I've had a play with the coordinates you've provided and got something I'm happy enough with, it's only for the 4 stones that top the bridge pillars.
I'll have to have a proper look in to it tomorrow.
Using this,
[Texture]
Load bridge.png
Coordinates 0,1,0
Coordinates 1,1,1
Coordinates 2,0,1
Coordinates 3,0,0
Coordinates 4,2,0
Coordinates 5,2,1
Coordinates 6,1,1
Coordinates 7,1,0
Produced this
Texture is temporary I may add!
Adam
I'll have to have a proper look in to it tomorrow.
Using this,
[Texture]
Load bridge.png
Coordinates 0,1,0
Coordinates 1,1,1
Coordinates 2,0,1
Coordinates 3,0,0
Coordinates 4,2,0
Coordinates 5,2,1
Coordinates 6,1,1
Coordinates 7,1,0
Produced this
Texture is temporary I may add!
Adam
Re: *Help!* Texturing a cube
I recommend not doing cubes at all. Do AddFaces instead. You will even save some rendering power, because you usually don't need all 6 sides of the cube, but you are still rendering them... Not even mentioning that texturing a cube is a pain in the lower back.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|