|
20 | 20 |
|
21 | 21 | import typing |
22 | 22 | import bpy |
| 23 | +import bisect |
23 | 24 | import enum |
24 | 25 | import os |
25 | 26 | import glob |
26 | 27 | import collections |
| 28 | +import random |
27 | 29 | import logging |
28 | 30 | from . import polib |
29 | 31 | from . import asset_registry |
|
55 | 57 | TQ_MODIFIER_LIBRARY_BLEND = "tq_Library_Modifiers.blend" |
56 | 58 | TQ_EMERGENCY_LIGHTS_NODE_GROUP_NAME = "tq_Emergency_Lights" |
57 | 59 | TQ_LICENSE_PLATE_NODE_GROUP_NAME_PREFIX = "tq_License-Plate_" |
| 60 | +# Mimics the distribution of car colors in the real world |
| 61 | +TQ_COLOR_DISTRIBUTION = ( |
| 62 | + (0.0, (0.004, 0.004, 0.004)), # 0E0E0E |
| 63 | + (0.018, (0.063, 0.063, 0.063)), # 474747 |
| 64 | + (0.031, (0.558, 0.558, 0.558)), # C5C5C5 |
| 65 | + (0.041, (0.216, 0.004, 0.175)), # 800E74 |
| 66 | + (0.043, (0.012, 0.001, 0.028)), # 1D042F |
| 67 | + (0.045, (0.295, 0.185, 0.0)), # 947700 |
| 68 | + (0.053, (0.271, 0.22, 0.126441)), # 8E8164 |
| 69 | + (0.060, (0.04, 0.099, 0.006)), # 385913 |
| 70 | + (0.070, (0.006, 0.026, 0.002)), # 132D07 |
| 71 | + (0.074, (0.106, 0.192, 0.009)), # 5C7918 |
| 72 | + (0.078, (0.014, 0.183, 0.152)), # 1F766D |
| 73 | + (0.081, (0.043, 0.017, 0.003)), # 3B2309 |
| 74 | + (0.101, (0.096, 0.0, 0.002)), # 570006 |
| 75 | + (0.173, (0.333, 0.07, 0.0)), # 9C4B00 |
| 76 | + (0.178, (0.282, 0.0, 0.0)), # 910000 |
| 77 | + (0.2, (0.002, 0.011, 0.042)), # 071B3A |
| 78 | + (0.278, (0.006, 0.054, 0.264)), # 11428C |
| 79 | + (0.3, (0.187, 0.187, 0.187)), # 787878 |
| 80 | + (0.45, (0.037, 0.037, 0.037)), # 363636 |
| 81 | + (0.6, (0.558, 0.558, 0.558)), # C5C5C5 |
| 82 | + (0.8, (0.004, 0.004, 0.004)), # 0E0E0E |
| 83 | +) |
58 | 84 |
|
59 | 85 |
|
60 | 86 | PARTICLE_SYSTEM_PREFIX = f"engon_{polib.asset_pack.PARTICLE_SYSTEM_TOKEN}_" |
@@ -271,3 +297,9 @@ def gather_instanced_objects( |
271 | 297 | and instance_collection is not None |
272 | 298 | ): |
273 | 299 | yield from instance_collection.all_objects |
| 300 | + |
| 301 | + |
| 302 | +def get_car_color() -> typing.Tuple[float, float, float]: |
| 303 | + value = random.random() |
| 304 | + idx = bisect.bisect(TQ_COLOR_DISTRIBUTION, value, key=lambda x: x[0]) - 1 |
| 305 | + return TQ_COLOR_DISTRIBUTION[idx][1] |
0 commit comments