face culling when scattering

1934
3
04-18-2012 06:36 AM
JesseGould
New Contributor
I am trying to scatter an asset across a facade which ive been able to do successfully. however when i do so the facade disappears..  How can I keep the facade visible? below is my rule, as well an image of the issue.

thanks.

/**
 * File:    120417-rule-02.cga
 * Created: 18 Apr 2012 00:01:55 GMT
 * Author:  alexandergibson
 */

version "2010.3"

attr height  = 30
attr floor_height = 4
attr tile_width = 4
attr obstacle = 0
attr residential = 0 
attr commercial = 0
attr retail = 0


Building1-->
 s(4,0,4)
 i("assets/120415-01.obj")
 center(xz)
 color("#ff0000")
 
Building2-->
 s(1,0,1)
 i("/assets/120415-02.obj")
 center(xz)
 color("#00a600")
 
Building3-->
 s(4,0,4) 
 i("assets/120415-03.obj")
 center(xz)
 color("#00a6de")

Lot --> 
 extrude(height) Building

Building -->
 comp(f) { front : Frontfacade | side : Sidefacade | top: Roof}
 
Frontfacade --> 
 split(y){{~floor_height : Floor}* }

Floor -->
    split(x){ 1: Wall 
            | { ~tile_width: tile }* 
            | 1 : Wall }


tile -->
 case residential < 0.2 && obstacle < 0.5 : scatterBuilding2
 case residential < 1 && residential > 0.2 && obstacle < 0.5 : scatterBuilding
 case commercial < 0.2 && obstacle < 0.5 : scatterBuilding3
 case commercial < 1 && commercial > 0.2 && obstacle < 0.5 : scatterBuilding
 case retail < 0.2 && obstacle < 0.5 : scatterBuilding3
 case retail < 1 && retail > 0.2 && obstacle < 0.5 : scatterBuilding
 else: NIL

 
scatterBuilding -->
 scatter(scope, 1, uniform) { Building1 }
 
scatterBuilding2 -->
 scatter(surface, 1, uniform ) { Building2 } 
 
scatterBuilding3 -->
 scatter(surface, 1, gaussian, center, '0.3 ) { Building3 }
 
scatterBuilding4 -->
 scatter(surface, 0, uniform) { Building1 }
0 Kudos
3 Replies
MatthiasBuehler1
Frequent Contributor II
good question. this is about one of the fundamental elements of CGA.

A --> B
forwards the geometry from A into B

A --> B C
forwards the copy from A to B and then makes an other copy called C

you can use this e.g. like this :

A --> B t(0,50,0) C
like this, you make B, then translate the scope and make an other copy C

* * *

in your case, the geometry moves on into the geometry of the scatter operation and 'lives there'. Thus, you just need a copy of the incoming facade Geometry !

FacadeScatter -->
    FacadeCopy.
    scatter(..)

ok ?
0 Kudos
DanielO_Shaughnessy
New Contributor II
Thanks Matthias (or is it Matt?) - turns out this is also very helpful if you are importing a model and want, for example, to keep the ground plane green under the imported buidling. The result still generates some overlapping geometries (ie, the full lot, even under the imported model, is green), but I don't see a better way around it.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hey !


actually it's Matthias, but Matt in short is faster to type .. :o


exactly. the strategy of this is completely generic. it does not matter what specific you are coding in CGA (buildings, roofs, forests, ..), if you need, you can always create copies of a shape like this to do different things on the copies. Once you're familiar with it, you'll use it A LOT !

depending on if you 'want/can easily work with' overlapping geometries, or need them to be cut out, is up to you and depends just on how you write the code.


cheers !
0 Kudos