Select to view content in your preferred language

Random Texture

1063
1
11-16-2011 03:35 AM
NoemiNeuenschwander1
Deactivated User
I want to model a one family house complex on one lot. For this purpose I make two rule files: the first one ???buildingComplex.cga??? splits the lot in smaller parcels. In each parcel the second rule ???building.cga??? is accessed.
For the roof I use random textures (inside the building.cga):

const randomRoofTexture = "textur/roof/ziegel_efh_"+ceil(rand(0,6))+".jpg"


but now each building on the lot has the same texture.
How can I make one texture per house but different textures for different buildings in one complex?
0 Kudos
1 Reply
MatthiasBuehler1
Deactivated User
'const' makes an attribute constant for the whole shape. thus, there's no direct differentiation between the facades of the different buildings.

so what you have to do is pass one random 'chosen' texture down to each one of the building footprints for using as the facade texture.

If you are on 2010.3, you have to pass the value from rule to rule, like :
Lot -->
    Rule(rand(10,20))

Rule (value) -->
    print (value)


This can of course get confusing if you have many many rules, because you need to pass the values down like, even over rules which do not use this value.



For this, in the 2011 version, GENERIC ATTRIBUTES were introduced, which let you set and change any attribute in the Rules. These are then passed down automatically.

E.g.

attr myValue= 1

Lot -->
    set (myValue, 10)
    Rule

Rule -->
    print  (myValue)


Please note that these attribute values are handed down to the different 'subtrees' in the Model Hierarchy, thus each branch can have different values.
0 Kudos