Can CGA be efficient and pithy for different building types?

423
3
05-21-2014 08:06 PM
qingyangliu
New Contributor II
Hi,
  I have 30 types of buildings and each type of them have many buildings. I classify buildings with the attribution class1, class2, class3... What's more, I have many different textures. Now I want to give each type of buildings the same texture.
  Now this is what I can do:
  lot-->
     case buildingType == "class1": buildingTex1
     case buildingType == "class2": buildingTex2
     case buildingType == "class3": buildingTex3
     ...
  buildingTex1-->
    setupProjection(0,scope.xy,~7,~3,0)
    texture("assets/texture/facade2/CRBuilding_1.jpg")
    projectUV(0)
  ...
  You can see that I have to do similar things for many times. The texture can be random for different types of the buildings, but it should keep the same texture in the same type of the buildings. The "buildingType" and "buildingTex" are regular, so can I use a pithy method to do this work?
  thanks
Tags (2)
0 Kudos
3 Replies
BenLeslie1
Regular Contributor
If projection is to be the same you don't have to set for every texture, you can just set it once at the beginning:
....
lot-->
setupProjection(0,scope.xy,~7,~3,0)
projectUV(0)
Lot2

Lot2-->
case buildingType == "class1": buildingTex1
case buildingType == "class2": buildingTex2
case buildingType == "class3": buildingTex3
...
buildingTex1-->
texture("assets/texture/facade2/CRBuilding_1.jpg")
....................

or if you can rename your texture something like "CRBuilding_class1.jpg" you could do this:
...
lot-->
setupProjection(0,scope.xy,~7,~3,0)
texture("assets/texture/facade2/CRBuilding_"+buildingType+".jpg")
projectUV(0)

i.e. think about making your attributes and texture names work together:
0 Kudos
qingyangliu
New Contributor II
Hi,
  It works. I make my attributes and texture names work together and the CGA becomes very pithy. Thanks.

I have other questions. I want to  give one types of the buildings two different textures. This is what I do:
facadeTexDBuilding-->
  50% :
  setupProjection(0,scope.xy,~10,~15,0)
  texture(DBuilding_B_facade)
  projectUV(0)
  else:
  setupProjection(0,scope.xy,~7,~3,0)
  texture(DBuilding_facade)
  projectUV(0)
But sometimes one building will have two different textures. Do you have other good suggestions for this situation?

thanks
0 Kudos
BenLeslie1
Regular Contributor
The 50%: rule looks at each polygon and streams a certain percentage in a certain direction.  So if your building is made of 4 polygons (i.e. 4 walls) each one can go into a different stream.  So you need to move the 50% rule to a point in your code where each building is only one polygon (i.e. just a building footprint).
0 Kudos