Select to view content in your preferred language

One building with one texture

04-29-2016 12:33 PM
New Contributor III

I am creating 3D textured models for a college campus with over 200 buildings. I need to create one building with its corresponding texture, in the other words one building uses one texture. I searched the CityEngine samples and most samples use a random method to randomly pick up a texture for a façade, which I cannot apply the random method to my project as we are creating realistic settings. I also tried some Python codes but do not work well. 

Is there any method in CGA or Python can figure out the issue of one building applying one texture for over 200 buildings? Thanks.

0 Kudos
4 Replies
Occasional Contributor III

This sounds like you need an attribute in your buildings dataset containing "texture names" or "building names" that matches your texture images.  Then you could write the CGA code to match the building to the texture.  Can you give some more information?

1. Are your buildings originally 2D GIS data (such as footprint polygons)?

2. Are you generating these buildings with CGA rules...or are they from some other 3D object import?

3. Did you write a CGA rule, or are you using a downloaded rule?

3. Are your texture images you wish to use for an entire building face (walls, windows, etc) or are you applying general textures (solid brick, solid vinyl, concrete, etc) and creating the windows separately withing the rule?

0 Kudos
New Contributor III

Thanks for your reply. I have footprints’ attribute table that contacts texture names and building names. I think your solution is correct and I am looking for the connection between texture names and building names. Can you provide the sample code?

The following is my answers to your questions.

  1. Yes, I use footprint polygon to extrude buildings
  2. I am currently using CGA rules. But I also explored Python a bit and my Python code can only extrude grey buildings. I can go either CGA rules or Python codes.
  3. I wrote my CGA rule. I attach the image for a part of my CGA code .
  4. I am using one image for one façade right now. And I think this way can reduce the file size to publish online. It would be nice if the code can create a building with two facades as some real buildings have two or three different facades. code1.JPG
0 Kudos
Occasional Contributor III it seems you have a couple of options here.

1.  If you have an attribute in the footprints data that has the texture can create (in the CGA code) one variable that references the folder that has the texture images (i am assuming jpg) and another variable that represents the texture name..then you can connect that CGA texture name attribute to the footprint texture name attribute.

Then connect the attributes here...

2.  If you want to use the "building names" from your footprint will possibly need to rename your texture images to match the building names

      for your building name is "building1"----rename the texture image for that building "building1.jpg".  Then use the following code..


Then follow the "connect the attributes" section above to connect your building name attribute to your CGA attribute (I called it "BuildingTexture_From_Attribute_Table") and then the rule should put the appropriate texture to the building.

I hope this helps.  Let me know how it goes.

New Contributor III

R: One Building with one texture

Thank you for providing the solution. I use the first method and it works.

I am happy to see my buildings with different textures. I knew the

Attribute Connection Editor for the real Height, which is the numerical

value. I did not know before it can connect with string type of value. That

is great! I can put more attributes stored in attribute table.



P.S. I cannot log into the account and send my reply. So I email you.