Texture projection - keeping textures vertically orientated

1497
4
Jump to solution
04-15-2012 09:37 AM
DavidOConnor
New Contributor
[ATTACH=CONFIG]13544[/ATTACH]

Howdy - I'm hoping you can help.  At the moment, I'm figuring out how to keep a texture vertically aligned, but projected flat onto a face.  Normally, the rules I've put together below work fine, but (from what I read) it seems that faces without a horizontal edge at the bottom... give problems to the texture rotation.  As you'll see from the photo, upside down triangles* are the issue, so the texture is projected flat (good) but rotated a bit skewed (which is bad) on that face (... it seems to be aligned with an edge).

It is clear that you have solved this in the NYC 2259 example, but there is a lot of wizardry that I don't quite understand.  Is there a more simple way to do this?

Thank you!  😄

* It may be obvious to some, but for those who are puzzled, the triangles are caused by an imported shape that is formed from two pyramids, one inverted into the other.  Those faces don't LOOK triangular, but the rest of the face is inside the structure so it is actually an upside down triangle

[ATTACH=CONFIG]13535[/ATTACH]

################################ # FILES import flatroof      : "flatroof.cga"   ################################ # ATTRIBUTES attr LOD = 2 attr finalBuildingHeight = 100 attr floorH = rand(5,6) attr tileW  = rand(2.2,3.7)  ################################ # FUNCTIONS getWallATex    = "facades/facade1_color.png" getFloorHeight(h)   = case h >= floorH  : h/rint(h/floorH)  else : scope.sy/ceil(scope.sy/floorH+0.0001) getTileWidth(w)   = case w >= tileW  : w/rint(w/tileW)  else : scope.sx/ceil(scope.sx/tileW+0.0001)     ################################ # RULES Lot -->  Footprint   Footprint -->  s('0.9,'1,'0.9)   center(xz)   alignScopeToAxes(y)   s('1,0,'1)  Mass  Mass -->  extrude(finalBuildingHeight)  Shapes  Shapes -->  10%:   i( "volumes/cube_slanted_edges2.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/cyl24_ver_bevel.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/cyl8_ver.obj" )   comp(f){ side : Facade | horizontal : Roof }   10%:   i( "volumes/o_shape.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/prism1.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/cube_taper_steps1.obj" )   comp(f){ side : Facade | horizontal : Roof }  10%:   i( "volumes/u_shape.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/cube_translated2.obj" )   comp(f){ side : Facade | horizontal : Roof }     10%:   i( "volumes/cube_slanted_faces1.obj" )   comp(f){ side : Facade | horizontal : Roof }     else:   NIL  Roof -->   GetToItLater.   Facade -->     alignScopeToGeometry(zUp, auto)    texture(getWallATex)     setupProjection(0, scope.xy, 16*getTileWidth(scope.sx), 16*getFloorHeight(scope.sy), 1)     projectUV(0) # colormap texture projection    
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor
hi.

yep, this is a famous problem. 🙂

the issue is that there's no 'lowest horizontal edge' to align to.

thus, the easiest way to solve this issue is to split off a tiny fraction of the shape which will give you this lowest edge :
alignScopeToAxes(y) split(y) {0.01 : X. | ~1 : Y.}


then on the Y shape, you can align to the lowest edge and continue texturing.

I know, this is not a beautiful solution, but currently, it's the easiest. I'll dig a little deeper if there's a better option available.

ok ?

View solution in original post

0 Kudos
4 Replies
MatthiasBuehler1
Frequent Contributor
hi.

yep, this is a famous problem. 🙂

the issue is that there's no 'lowest horizontal edge' to align to.

thus, the easiest way to solve this issue is to split off a tiny fraction of the shape which will give you this lowest edge :
alignScopeToAxes(y) split(y) {0.01 : X. | ~1 : Y.}


then on the Y shape, you can align to the lowest edge and continue texturing.

I know, this is not a beautiful solution, but currently, it's the easiest. I'll dig a little deeper if there's a better option available.

ok ?
0 Kudos
MatthiasBuehler1
Frequent Contributor
btw.

instead of 10 times 10% case statement, you could also use :

i ( fileRandom("volumes/*.obj"))


😮
0 Kudos
by Anonymous User
Not applicable
Original User: WhiteNorthStar

hi Matthias, thank you for your quick responses, that is very helpful 😄

By the way, I'm getting to grips with CGA shape grammar.  It is really powerful and easy to use... genius work!
0 Kudos
MatthiasBuehler1
Frequent Contributor
thank you as a user to be so patient with us !


it's great to see users getting used to CGA and actually accomplish things !

not every person is interested in scripting, we know, that's why we'll be working more on rule templates which should make the lifes of non-tekkies easier !
0 Kudos