AnsweredAssumed Answered

City Engine - being able to choose texture for roofs

Question asked by ialixandroae on Sep 4, 2014
Latest reply on Sep 4, 2014 by Estaar

Hello,

 

I have a problem regarding importing some texture jpgs as texture for roof and then creating a rule that gives me the possibility to choose a texture for a random roof from those 4 jpgs.

 

I have 4 types of roofs and I created a rule that those 4 textures would apply for a specific roof type but I want also to be able to change the texture without changing the type.

Example : for Pyramid type I have a Zinc texture, but also I want to be able for the same type to change to a Slate texture

Can you help me please?

 

This is the rule :

 

 

 

attr Height = 4

@Range ( "pyramid", "shed", "gable", "hip")

attr RoofType = "random"

attr RoofHeight = rand (4,6)

 

const function_RoofType =

  case RoofType == "random" :

  30% : "pyramid"

  20% : "shed"

  20% : "hip"

  else : "gable"

  else : RoofType

 

##Casa1##

Casa1 -->

  extrude(world.y, Height)

  Cladire

Cladire -->

  comp(f) {side: SideFacade | top:  Roof }

 

 

Roof -->

case function_RoofType == "shed" : 

  roofShed(45) 

  s('1,RoofHeight,'1) # scale to the correct height

  setupProjection (1, scope.xy, scope.sx, scope.sy)

  texture("Paris/assets/parisianRoofs/slate.png")

  projectUV(0)

  case function_RoofType == "hip" : 

  roofHip(45) 

  s('1,RoofHeight,'1) # scale to the correct height

  setupProjection (1, scope.xy, scope.sx, scope.sy)

  texture("Paris/assets/parisianRoofs/tile.png")

  projectUV(0) 

  case function_RoofType == "gable" : 

  roofGable(45) 

  s('1,RoofHeight,'1) # scale to the correct height 

  setupProjection (1, scope.xy, scope.sx, scope.sy)

  texture("Paris/assets/parisianRoofs/zinc1.png")

  projectUV(0)

else : 

  roofPyramid(45) 

  s('1,RoofHeight,'1) # scale to the correct height 

  setupProjection (1, scope.xy, scope.sx, scope.sy)

  texture("Paris/assets/parisianRoofs/zinc2.png")

  projectUV(0) 

 

 

 

 

 

SideFacade -->

  setupProjection(0, scope.xy, '1, '1)

  projectUV(0)

  texture("Textura/casa1-2.jpg")

Outcomes