+ Reply to Thread
Results 1 to 5 of 5

Thread: Texture projection - keeping textures vertically orientated

  1. #1
    David OConnor
    Join Date
    Mar 2012
    Posts
    21
    Points
    0
    Answers Provided
    0


    0

    Talking Texture projection - keeping textures vertically orientated

    Click image for larger version

Name:	Texture2.jpg
Views:	75
Size:	235.7 KB
ID:	13544

    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

    Click image for larger version

Name:	Texture.jpg
Views:	79
Size:	165.2 KB
ID:	13535

    Code:
    ################################
    # 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
    Last edited by WhiteNorthStar; 04-16-2012 at 02:44 AM. Reason: edited to clarify issue

  2. #2
    Matthias Buehler

    Join Date
    Oct 2011
    Posts
    1,676
    Points
    438
    Answers Provided
    140


    0
    This post is marked as the answer

    Default Re: Texture projection - keeping textures vertically orientated

    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 :
    Code:
    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 ?
    _________________

    CityEngine Machinist

    * YOUTUBE CHANNEL : www.youtube.com/channel/UCNS4TLgToEDQiH9pi06ofOA
    * tutorial videos : http://forums.arcgis.com/threads/648...URCES-FAQ-HELP
    * Please use the rating buttons on the right side !

  3. #3
    Matthias Buehler

    Join Date
    Oct 2011
    Posts
    1,676
    Points
    438
    Answers Provided
    140


    0

    Default Re: Texture projection - keeping textures vertically orientated

    btw.

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

    Code:
    i ( fileRandom("volumes/*.obj"))
    _________________

    CityEngine Machinist

    * YOUTUBE CHANNEL : www.youtube.com/channel/UCNS4TLgToEDQiH9pi06ofOA
    * tutorial videos : http://forums.arcgis.com/threads/648...URCES-FAQ-HELP
    * Please use the rating buttons on the right side !

  4. #4
    David OConnor
    Join Date
    Mar 2012
    Posts
    21
    Points
    0
    Answers Provided
    0


    0

    Talking Re: Texture projection - keeping textures vertically orientated

    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!

  5. #5
    Matthias Buehler

    Join Date
    Oct 2011
    Posts
    1,676
    Points
    438
    Answers Provided
    140


    0

    Default Re: Texture projection - keeping textures vertically orientated

    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 !
    _________________

    CityEngine Machinist

    * YOUTUBE CHANNEL : www.youtube.com/channel/UCNS4TLgToEDQiH9pi06ofOA
    * tutorial videos : http://forums.arcgis.com/threads/648...URCES-FAQ-HELP
    * Please use the rating buttons on the right side !

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts