City Engine - being able to choose texture for roofs

2799
5
Jump to solution
09-04-2014 01:58 AM
IonutAlixandroae
Occasional Contributor

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")

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
johne
by
New Contributor III

You can make the line that selects the texture an attribute.

e.g

attr Texture = ("Paris/assets/parisianRoofs/slate.png")

so it will look like this.

.......................

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(Texture)

.....................

View solution in original post

0 Kudos
5 Replies
johne
by
New Contributor III

You can make the line that selects the texture an attribute.

e.g

attr Texture = ("Paris/assets/parisianRoofs/slate.png")

so it will look like this.

.......................

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(Texture)

.....................

0 Kudos
IonutAlixandroae
Occasional Contributor

I have 4 pngs that I want to use as textures and to be able to choose between them.

In the case you wrote for the shed type, automatically the texture will be slate.png.

How should I write to be able to choose between those 4 textures?

Thanks !

0 Kudos
johne
by
New Contributor III

Yeah. it will give you the slate.png as the default in the rule but since Texture will appear on the inspector you can browse any other file to replace the slate.png besides your four textures

TimothyHales
Esri Notable Contributor

I've moved your post into the CityEngine space. You will get a much better answer here as posting to the entire community allows everyone to see it on the home page, but no one is notified of your recent activity like a group can do. You can see more on the community structure, and what topics are under each space from the following documents:

GeoNet Community Structure

ArcGIS Discussion Forums Migration Strategy

Thanks!

Timothy

IonutAlixandroae
Occasional Contributor

Thank you !

0 Kudos