CityEngine- being able to choose texture for facades

4257
6
Jump to solution
06-03-2015 01:34 AM
Rosa_
by
New Contributor II

Hi,

I'm creating a real city in CE and I'm using a shape file for buildings. I must use different textures for each facade, so I should create a rule that allows me to choose the texture for each facade. Anyone can help me? Thanks.

1 Solution

Accepted Solutions
MicahTaylor
Occasional Contributor III

Ok...I think I understand. You want to select facades for different faces of a single model (such as walls).

You would need to separate the walls in the code into individual components...and then write a rule for each one....for example....

attr HEIGHT = 10

attr texturesFront = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesRight = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesLeft = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesBack = fileRandom("assets/Brick_Red_Wall.jpg")

@StartRule

Lot -->

    extrude(HEIGHT)Bldg

   

Bldg --> comp(f){front : FacadeFront | right : FacadeRight | left : FacadeLeft | back : FacadeBack | top : Roof }

FacadeFront -->

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

     texture(texturesFront)

     projectUV(0)

    

FacadeRight -->

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

     texture(texturesRight)

     projectUV(0)

    

FacadeLeft -->

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

     texture(texturesLeft)

     projectUV(0)

    

FacadeBack -->

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

     texture(texturesBack)

     projectUV(0)

   

Roof -->

    roofGable(45,0,0,false,0)

However, this may be a bad way to do it if you do not have exactly 4 walls. I would suggest clicking on your "Help" option and search for the "Comp Split Operation".  It will give you an idea of how the rule file identifies a single face.

But again, there are lots of rules online (mostly inside of tutorial downloads) that work great and can be modified to do what you need.

View solution in original post

6 Replies
MicahTaylor
Occasional Contributor III

Here is a link to tutorials that have a lot of building rules with the download; you can modify these to use your textures.

CityEngine Gallery | ArcGIS Resource Center

You can use the file path of the textures in those rules (usually in "assets/textureName.jpg") and just add your own textures into the assets folder....("assets/YOURtextureName.jpg").

A simple way to select your own texture in the inspector window (with a browse button) is to make an attribute for your texture in the rule file.

for example....

attr HEIGHT = 10

attr Mytextures = fileRandom("assets/Brick_Red_Wall.jpg") #THIS MAKES TEXTURE SELECTABLE!!

@StartRule

Lot -->

    extrude(HEIGHT)MakeBuilding

   

MakeBuilding --> comp(f){side : Facade | top : Roof }

Facade -->

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

     texture(Mytextures)

     projectUV(0)

    

Roof -->

    roofGable(45,0,0,false,0)

This will allow you to select a building in the scene...and choose its texture from the inspector window.

Good luck!

Reply
0 Kudos
Rosa_
by
New Contributor II

Thanks for your timely response. Does this rule allow to select a different texture for each facade of building?

If building has four facades, I should select four different texture.

Reply
0 Kudos
MicahTaylor
Occasional Contributor III

Ok...I think I understand. You want to select facades for different faces of a single model (such as walls).

You would need to separate the walls in the code into individual components...and then write a rule for each one....for example....

attr HEIGHT = 10

attr texturesFront = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesRight = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesLeft = fileRandom("assets/Brick_Red_Wall.jpg")

attr texturesBack = fileRandom("assets/Brick_Red_Wall.jpg")

@StartRule

Lot -->

    extrude(HEIGHT)Bldg

   

Bldg --> comp(f){front : FacadeFront | right : FacadeRight | left : FacadeLeft | back : FacadeBack | top : Roof }

FacadeFront -->

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

     texture(texturesFront)

     projectUV(0)

    

FacadeRight -->

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

     texture(texturesRight)

     projectUV(0)

    

FacadeLeft -->

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

     texture(texturesLeft)

     projectUV(0)

    

FacadeBack -->

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

     texture(texturesBack)

     projectUV(0)

   

Roof -->

    roofGable(45,0,0,false,0)

However, this may be a bad way to do it if you do not have exactly 4 walls. I would suggest clicking on your "Help" option and search for the "Comp Split Operation".  It will give you an idea of how the rule file identifies a single face.

But again, there are lots of rules online (mostly inside of tutorial downloads) that work great and can be modified to do what you need.

View solution in original post

MicahTaylor
Occasional Contributor III

Also, be sure your facade pictures (jpg, png, etc..) are saved in your assets folder.

Reply
0 Kudos
Rosa_
by
New Contributor II

Thank you very much, you have solved my problem. This rule is perfect!!!

BenjaminChmiel
New Contributor

I had the same problem. Would you be willing to share this rule with me?

Reply
0 Kudos