Select to view content in your preferred language

Make the facade orderly and random

203
2
01-01-2025 11:03 PM
Labels (1)
biaozeng
Occasional Contributor

How to assign the same seed to listRandom? I have divided the ground facade and the up facade in the same elevation CGA. I hope that they can index to the consistent textures when using listRandom for randomization. For example: In the "Upperfloors" folder, there are (u_f009_t006_Residential_000.jpg; u_f009_t006_Residential_001.jpg; u_f009_t006_Residential_002.jpg). In the "Groundfloors" folder, there are (u_f009_t006_Residential_000.jpg; g_f003_t006_Residential_001.jpg; g_f001_t006_Residential_002.jpg). I hope that they can be matched according to the serial numbers on the left side of the.jpg. (u_f009_t006_Residential_000.jpg and u_f009_t006_Residential_000.jpg) (u_f009_t006_Residential_001.jpg and g_f003_t006_Residential_001.jpg) (u_f009_t006_Residential_002.jpg and g_f001_t006_Residential_002.jpg)

0 Kudos
2 Replies
biaozeng
Occasional Contributor

I used this function to achieve the desired result

string listItem(stringList, index)

0 Kudos
desert
by
Occasional Contributor

I'm curious if you have a special reason for using "listItem"
I tested it using an array.
When extruded to 1m, it is treated as red;
when extruded to 5m, it is treated as green;
and when extruded to 10m, it is treated as blue."

I matched items in the same order from two arrays. 

There might be a better way, but I hope this helps.

desert_0-1736399468962.png

 

 

// Initialize height array for buildings
const bd_Height = [1, 5, 10]

// Initialize color array for buildings
const bd_Color = ["#FF0000", "#00FF00", "#0000FF"]

// Generate a random index based on the size of the height array
rand_index = floor(rand(size(bd_Height)))

Lot -->
    // Pass the random index to rule A
    A(rand_index)

A(value) -->
    // Extrude the shape based on the height from the bd_Height array
    extrude(bd_Height[value])
    // Set the color based on the value from the bd_Color array
    color(bd_Color[value])

 

 

 

 

0 Kudos