BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

*Help!* Texturing a cube

3 posters

Go down

*Help!* Texturing a cube Empty *Help!* Texturing a cube

Post by ap1991 Wed Jun 08, 2016 6:14 pm

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.

*Help!* Texturing a cube Textur10

Thanks in advance!

Adam
ap1991
ap1991

Posts : 296
Join date : 2014-07-25
Age : 32
Location : Warwickshire

https://adamp19914.wixsite.com/bvecentral

Back to top Go down

*Help!* Texturing a cube Empty Re: *Help!* Texturing a cube

Post by leezer3 Wed Jun 08, 2016 6:34 pm

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-
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:
*Help!* Texturing a cube Cube

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 Smile

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

leezer3

Posts : 1959
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

*Help!* Texturing a cube Empty Re: *Help!* Texturing a cube

Post by ap1991 Thu Jun 09, 2016 5:13 am

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

*Help!* Texturing a cube Textur11

Texture is temporary I may add! Very Happy

Adam
ap1991
ap1991

Posts : 296
Join date : 2014-07-25
Age : 32
Location : Warwickshire

https://adamp19914.wixsite.com/bvecentral

Back to top Go down

*Help!* Texturing a cube Empty Re: *Help!* Texturing a cube

Post by ap1991 Thu Jun 09, 2016 3:30 pm

I think I've just about managed to achieve the effect I was hoping for

*Help!* Texturing a cube Textur10
ap1991
ap1991

Posts : 296
Join date : 2014-07-25
Age : 32
Location : Warwickshire

https://adamp19914.wixsite.com/bvecentral

Back to top Go down

*Help!* Texturing a cube Empty Re: *Help!* Texturing a cube

Post by Dexter Fri Jun 10, 2016 12:45 am

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

Posts : 2153
Join date : 2011-07-08
Age : 38
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

*Help!* Texturing a cube Empty Re: *Help!* Texturing a cube

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum