-
Notifications
You must be signed in to change notification settings - Fork 0
/
Batiment.ms
403 lines (242 loc) · 9.11 KB
/
Batiment.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/*#######################################################################################################################
Christophe Pages (http://www.c-pages.fr)
##########################################################################################################################
URBA - BATIMENT
Batiment procédural pour utilisation avec générateur de ville procédurale
##########################################################################################################################
Plugin Batiment
##########################################################################################################################
NOTES :
##########################################################################################################################
todo:
- gerer les unités des parametres (pour le calcul ou l'affichage des longueurpar ex..)
##########################################################################################################################
changelog:
*v0.1 - [23/09/2017] -----------------------------------------------------------------------------
- Mise en place globale
*v0.2 - [20/02/2018] -----------------------------------------------------------------------------
- Reorganisation globale
########################################################################################################################*/
---- le presse papier pour copier coller -----
global urba_clipboard_batiment = ""
--------------- debugger ---------
-- (
include "$userScripts\\cp-Urba\\modules\\Commun\\Urba - Debug.ms"
/*
global debug, debuger, ecrire
global DEBUG_MODE = true
fn remplirTexte _txt var: param: prefix: = (
local oldPrintAllElements = options.printAllElements
options.PrintAllElements = true
local result =""
global dbg_elemTmp
if prefix != unsupplied and prefix != undefined do (
result += "<" + prefix + "> "
-- if prefix.count < 10 do result += " "
if prefix.count < 6 do result += " "
if prefix.count < 2 do result += " "
)
if var != unsupplied then (
result += " - " + _txt + " : "
if classof var == Array then (
if param != unsupplied then (
result += "(" + var.count as string + ") "
for i = 1 to var.count do (
if var[i] != undefined then (
dbg_elemTmp = var[i]
result += ( execute ("dbg_elemTmp." + param ) ) as string
if i != var.count do result += ", "
) else result += "undefined"
)
) else result += var as string
) else
if param != unsupplied then (
if var != undefined then (
dbg_elemTmp = var
result += ( execute ("dbg_elemTmp." + param ) ) as string
) else result += "undefined"
) else result += var as string
) else result += _txt
options.printAllElements = oldPrintAllElements
result
)
fn debuger _txt var: param: prefix: = (
if DEBUG_MODE do (
local txtFinal = "<DEBUG> "
txtFinal += remplirTexte _txt var:var param:param prefix:prefix
format "%\n" txtFinal
)
)
----- output ------------------------------
fn ecrire _txt var: param: script:"URBA|Batiment" = (
-- if not DEBUG_MODE then (
local txtFinal = "<" + script + "> "
txtFinal += remplirTexte _txt var:var param:param
format "%\n" txtFinal
-- ) else debuger _txt var:var param:param
)
*/
-- ) --------- fin debug --------------
--------------- le plug in ---------
plugin geometry Urba_Batiment
name:"Batiment"
classID:#(685325,452281)
category:"CP | Urba"
extends:Editable_poly replaceUI:true version:0
remap:#(#(#surface_node), #(#surface_node))
(
------------ DEBUG -------------------------------------------------------------------------------------------------------------------------
local m_debug = false
local m_dbgPrefix ="urba | Batiment Plg"
fn debug _txt var: param: =(
try if m_debug do ::debuger _txt var:var param:param prefix:m_dbgPrefix
catch ()
)
--------------- IMPORTS ----------------------------------------------------------------------------------------------------------------------
include "$userScripts\cp-Urba\Modules\Batiment\Batiment - Core.ms"
--------------- CORE ----------------------------------------------------------------------------------------------------------------------
local core = str_batiment_core ()
--------------- PARAMETRES et ROLLOUTS ----------------------------------------------------------------------------------------------------------------------
local roll_general, roll_toiture, roll_facades ----, roll_niveaux, roll_presets, roll_infos, roll_trace
include "$userScripts\\cp-Urba\\Modules\\Batiment\\rollouts\\Batiment - rollouts.ms"
include "$userScripts\\cp-Urba\\modules\\Commun\\Urba - rollout - A propos.ms"
--------------- INTERFACE ----------------------------------------------------------------------------------------------------------------------
/*
fn activer_ecouteur_selection = (
debug "activer ecouteur selection"
when select this changes id:#Urba_bat_selection obj do (
format "obj.isSelected :%\n" obj.isSelected
if not obj.isSelected do
if obj.core.editeur_estOuvert do m_editeur_dialog.fermer ()
)
) */
---Initialisations / Actualisations ------
fn initialiser doLogo:false =(
-- activer_ecouteur_selection ()
core.initialiser this
)
fn actualiser =(
core.actualiser ()
)
fn actualiser_rollouts =(
roll_general.actualiser ()
)
---- Contours ---------
fn assigner_shape _nodeTHIS _shape = core.assigner_surface _nodeTHIS _shape
---- Accessions --------------
fn get_facades = core.get_facades ()
fn get_etage_ht _etageNum = core.get_etage_ht _etageNum
fn get_toiture = core.get_toiture ()
fn set_etages_nbre _nbr_etages =(
etages_nbre = _nbr_etages
)
fn set_etages_ht _ht_etages =(
etages_hauteur_global = _ht_etages
)
---- Affichage --------------
fn set_proxy_mode _state =(
affiche_asProxy = _state
core.actualiser_geometrie ()
)
--- Models -------------
fn charger _nomDuFichier val_etages_nbre: val_etages_ht: = (
debug""
debug "charger"
debug "_nomDuFichier" var:_nomDuFichier
debug "val_etages_nbre" var:val_etages_nbre
debug "val_etages_ht" var:val_etages_ht
if doesFileExist _nomDuFichier then (
if val_etages_nbre != unsupplied or val_etages_ht != unsupplied then (
core.preset_charger fichier:_nomDuFichier maj:false
if val_etages_nbre != unsupplied do etages_nbre = val_etages_nbre
if val_etages_ht != unsupplied do etages_hauteur_global = val_etages_ht
debug "etages_nbre" var:etages_nbre
debug "etages_hauteur_global" var:etages_hauteur_global
core.actualiser ()
) else
core.preset_charger fichier:_nomDuFichier
)
else core.preset_charger() --format "/!\\ Attention! le fichier (%) n'existe pas, impossible à charger/n" (_nomDuFichier as string )
)
--- Quartier parent ----------------
fn assigner_quartier _quartier =(
quartier_parent = (nodeTransformMonitor node:_quartier forwardTransformChangeMsgs:false)
)
--------------- CREATION ----------------------------------------------------------------------------------------------------------------------
tool create (
on mousePoint click do (
nodeTM.translation = worldPoint
core.actualiser ()
#stop
)
)
--------------- EVENEMENTS ----------------------------------------------------------------------------------------------------------------------
on load do (
-- debug "load du plugin"
initialiser ()
)
on clone _original do (
-- debug "clone du plugin"
initialiser ()
)
on create do (
-- debug "creation du plugin"
initialiser ()
actualiser ()
)
on update do (
-- debug "update du plugin"
-- debug "shape : " var:surface_node
initialiser ()
-- actualiser ()
)
) --- fin du plug ---
/*
----- DEBUG-------------------------
if creerBat != undefined do (
bat = Urba_Batiment ()
bat.assigner_shape bat $Shape007
select bat
)
creerBat = true
*/
/*
-- try delete $ catch ()
-- debug_mode =false
debug_mode =true
--
for obj in objects do if superclassof obj == GeometryClass and obj != $'Rectangle001' and obj != $'Porte002' and obj != $'Porte003' do delete obj
bat1 = urba_batiment ()
clearlistener ()
for obj in helpers do delete obj
bat1.assigner_trace $'Rectangle001' bat1
-- bat1.assigner_trace $Shape009 bat1
-- bat1.facades.creer_facade bat1
select bat1
select $popo
bat1.pos = [0,0,0]
bat1.trace.rectangles_traces
bat1.sousTraces
try unregisterRedrawViewsCallback bat1.fn_VP_afficher_axePrincipal
catch ()
$.VP_toggle ()
ray <pos_point3> <dir_point3>
intersectRay
plugin folder
$.facades.facade_courante.sequence
$.construire.batiment $
$.facades.modeles_total
$.facades_modeles[1]
$.facades.composants_total
$.facades.get_composants $
$.facades.composants_total
$.facades_parametriques[1]
for obj in objects do WITH REDRAW OFF try obj.actualiser_geometrie () catch ()
$.actualiser_geometrie ()
--- Pente aléatoire ---
for obj in selection do try (
local angle = random 15. 35.
obj.toit_pente = angle
obj.actualiser_geometrie ()
) catch ()
*/