-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.js
2002 lines (1595 loc) · 57 KB
/
model.js
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @author Rebecca Fabrizio
*
* Drawing Villa Almerico Capra - La Rotonda
*/
!(function (){
/*
* Definition of local variables and utility functions
*/
//Colors
var baseColor1 = [255/255,248/255,220/255];
var baseColor = [255/255,248/255,220/255];
var columnsColor = [253/255,245/255,230/255];
var groundColor = [240/255,240/255,240/255];
var windowsColor = [164/255,211/255,238/255,0.9];
var grassColor = [84/255,139/255,84/255];
var roofColor = [165/255,42/255,42/255];
//Domains
var domain2 = DOMAIN([[0,1],[0,1]])([40,1]);
var domain2pi = DOMAIN([[0,1],[0,2*PI]])([20,80]);
var domain3 = DOMAIN([[0,1],[0,1],[0,1]])([30,1,1]);
var makeKnots = function(points,grade){
var g = grade || 2;
var knots = [];
knots.push(0); knots.push(0); knots.push(0);
for (var i = 1; i < points.length-6+grade+1+1; i++) {
knots.push(i);
};
knots.push(i); knots.push(i); knots.push(i);
return knots;
}
var scalePoints = function(pointList, scale) {
return pointList.map( function(pt) {
return [pt[0]*scale[0],
pt[1]*scale[1],
pt[2]*scale[2]];
});
};
var rotatePoints = function(pointList, angle, axis) {
if (axis === 0) {
var alfa = angle;
return pointList.map( function(pt) {
return [ pt[0], pt[1]*COS(alfa) + (-1)*pt[2]*SIN(alfa), pt[1]*SIN(alfa) + pt[2]*COS(alfa) ];
});
} else if (axis === 1) {
var beta = angle;
return pointList.map( function(pt) {
return [ pt[0]*COS(beta) + pt[2]*SIN(beta), pt[1], (-1)*pt[0]*SIN(beta) + pt[2]*COS(beta) ];
});
} else if (axis === 2) {
var gamma = angle;
return pointList.map( function(pt) {
return [ pt[0]*COS(gamma) + (-1)*pt[1]*SIN(gamma), pt[0]*SIN(gamma) + pt[1]*COS(gamma), pt[2] ];
});
}
return pointList;
};
var movesPoints = function(pointList, axis, qty) {
if (axis === 0) {
return pointList.map( function(pt) {
return [ pt[0]+qty, pt[1], pt[2] ];
});
} else if (axis === 1) {
return pointList.map( function(pt) {
return [ pt[0], pt[1]+qty, pt[2] ];
});
} else if (axis === 2) {
return pointList.map( function(pt) {
return [ pt[0], pt[1], pt[2]+qty ];
});
}
};
/*
* Base of the structure
*/
var drawBaseOfStructure = function() {
var base = [];
//Stairs
var stairsHeight = 3/23;
var stairsDepth = 6/22;
var stairsLength = 7;
var numberOfStairs = 22; //22+1
var drawStairs = function(){
var stairs = [];
for (var i = 0; i < numberOfStairs; i++) {
stairs.push(SIMPLEX_GRID([
[0,stairsLength],
[-i*(stairsDepth),stairsDepth],
[-i*stairsHeight,stairsHeight]
]));
};
return COLOR(columnsColor)(STRUCT(stairs));
}
base.push(T([0])([0.86])(drawStairs()));
var lengthLast = stairsLength-0.07;
var last = T([0,1,2])([0.43+0.465,6,3-stairsHeight])(
SIMPLEX_GRID([[0,lengthLast],[0,
0.3+1.3+2.1+0.7],[0,stairsHeight]]));
base.push(COLOR(baseColor)(last));
var makewallBase = function(l){
var wall = [];
var l = l || 6;
var wall1 = T([0])([-0.5])(
SIMPLEX_GRID([[0,1],[0,l],[0,0.8]]));
wall.push(wall1);
var wall2 = T([0])([-0.465])(
SIMPLEX_GRID([[0,0.93],[-0.07,l-0.07],[-0.8,0.4]]));
wall.push(wall2);
var wall3 = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[-0.14,l-0.14],[-1.2,1.5]]));
wall.push(wall3);
var wall4 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93],[-0.07,l-0.07],[-2.7,0.3]]));
wall.push(wall4);
return COLOR(baseColor)(T([0,1])([0.43,-0.14])(STRUCT(wall)));
};
var wallLength = 4.8;
// wall Edge stairs sx
var wallBaseL = makewallBase(wallLength);
base.push(wallBaseL);
// wall Edge stairs dx
var wallBaseR = makewallBase(wallLength);
base.push(T([0])([0.43+0.43+stairsLength])(wallBaseL));
var base1 = COLOR(baseColor1)(
SIMPLEX_GRID([[0,0.6],[0,0.6],[0,0.05]]));
base1 = T([0,1,2])([0.13,0.2,3])(base1);
base.push(base1);
base.push(T([0])([0.43+0.43+stairsLength])(base1));
var drawWallWithWindow = function(distanceFromBorder,wallLength){
var walls = [];
//Barrier
var orizontalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,1],[0,0.02],[0,0.02]]));
var verticalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.02],[0,0.02],[0,1]]));
walls.push(
T([0,1,2])([distanceFromBorder,0.3,1.4])(
R([0,1])(PI/2)(
STRUCT([
STRUCT(REPLICA(9)([T([2])([0.1]),orizontalBarrier])),
STRUCT(REPLICA(9)([T([0])([0.1]),verticalBarrier]))]
))));
//dark wall
var darkWindow = COLOR([0,0,0,0.8])(BOUNDARY(
SIMPLEX_GRID([[0,0.05],[0,1],[0,1]])));
if(distanceFromBorder>0)
walls.push(T([0,1,2])([distanceFromBorder-0.2,0.3,1.4])(darkWindow));
else
walls.push(T([0,1,2])([distanceFromBorder+0.2,0.3,1.4])(darkWindow));
var wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[0,0.3],[-1.2,1.5]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[-(1+0.3),wallLength],[-1.2,1.5]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[-0.3,1],[-1.2,0.2]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[-0.3,1],[-2.4,0.3]]));
walls.push(COLOR(baseColor)(wall));
var wall1 = T([0])([-0.5])(
SIMPLEX_GRID([[0,1],[0,wallLength+1.3],[0,0.8]]));
walls.push(COLOR(baseColor)(wall1));
var wall2 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93],[0,wallLength+1.3],[-0.8,0.4]]));
walls.push(COLOR(baseColor)(wall2));
var wall4 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93],[0,wallLength+1.3],[-2.7,0.3]]));
walls.push(COLOR(baseColor)(wall4));
return T([0])([0.43])(STRUCT(walls));
}
var wall = drawWallWithWindow(-0.3,1.5+0.14);
wall = T([1])([4.8-0.14])(wall);
base.push(wall);
var wallR = drawWallWithWindow(0.3,1.5+0.14);
wallR = T([0,1])([0.43+stairsLength+0.43,4.8-0.14])(wallR);
base.push(wallR);
var drawWallWithWindow1 = function(distanceFromBorder,wallLength){
var walls = [];
//Barriers
var orizontalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,1],[0,0.02],[0,0.02]]));
var verticalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.02],[0,0.02],[0,1]]));
walls.push(
T([0,1,2])([distanceFromBorder,0.3,1.4])(
R([0,1])(PI/2)(
STRUCT([
STRUCT(REPLICA(9)([T([2])([0.1]),orizontalBarrier])),
STRUCT(REPLICA(9)([T([0])([0.1]),verticalBarrier]))]
))));
//dark wall
var darkWindow = COLOR([0,0,0,0.8])(BOUNDARY(SIMPLEX_GRID([[0,0.05],[0,1],[0,1]])));
if(distanceFromBorder>0)
walls.push(T([0,1,2])([distanceFromBorder-0.2,0.3,1.4])(darkWindow));
else
walls.push(T([0,1,2])([distanceFromBorder+0.2,0.3,1.4])(darkWindow));
var wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86-0.4],[0,0.3],[-1.2,1.5]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86-0.4],[-(1+0.3),wallLength],[-1.2,1.5]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86-0.4],[-0.3,1],[-1.2,0.2]]));
walls.push(COLOR(baseColor)(wall));
wall = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86-0.4],[-0.3,1],[-2.4,0.3]]));
walls.push(COLOR(baseColor)(wall));
var wall1 = T([0])([-0.5])(
SIMPLEX_GRID([[0,1-0.9],[0,wallLength+1.3],[0,0.8]]));
walls.push(COLOR(baseColor)(wall1));
var wall2 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93-0.85],[0,wallLength+1.3],[-0.8,0.4]]));
walls.push(COLOR(baseColor)(wall2));
var wall4 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93-0.85],[0,wallLength+1.3],[-2.7,0.3]]));
walls.push(COLOR(baseColor)(wall4));
return T([0])([0.43])(STRUCT(walls));
}
//wall with gate
var makeWallWithGate = function(){
var wall = [];
//wall intorno
var wall1 = T([0])([-0.5])(
SIMPLEX_GRID([[0,1],[0,0.1],[0,0.8]]));
wall.push(wall1);
wall.push(T([0,1])([-0.5,2])(
SIMPLEX_GRID([[0,1],[0,0.8],[0,0.8]])));
var wall2 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93],[0,0.1],[-0.8,0.4]]));
wall.push(wall2);
wall.push(T([0,1])([-0.93/2,2])(
SIMPLEX_GRID([[0,0.93],[0,0.8],[-0.8,0.4]])));
var wall3 = T([0])([-0.43])(
SIMPLEX_GRID([[0,0.86],[0,0.1],[-1.2,1.5]]));
wall.push(wall3);
wall.push(T([0,1])([-0.43,2])(
SIMPLEX_GRID([[0,0.86],[0,0.8],[-1.2,1.5]])));
var wall4 = T([0])([-0.93/2])(
SIMPLEX_GRID([[0,0.93],[0,2.8],[-2.7,0.3]]));
wall.push(wall4);
//Gate
var p0 = [[-0.43,0.1,2.7],[-0.43,2,2.7],[-0.43,2,2.7]];
var k0 = [0,0,0,1,1,1];
var c0 = NUBS(S0)(2)(k0)(p0);
var p1 = [[-0.43,0.1,2.2],[-0.43,1.05,2.6],
[-0.43,2,2.2]];
var k1 = [0,0,0,1,1,1];
var c1 = NUBS(S0)(2)(k1)(p1);
var surf0 = BEZIER(S1)([c0,c1]);
wall.push(MAP(surf0)(domain2));
var p2 = [[0.43,0.1,2.7],[0.43,2,2.7],[0.43,2,2.7]];
var k2 = [0,0,0,1,1,1];
var c2 = NUBS(S0)(2)(k2)(p2);
var p3 = [[0.43,0.1,2.2],[0.43,1.05,2.6],
[0.43,2,2.2]];
var k3 = [0,0,0,1,1,1];
var c3 = NUBS(S0)(2)(k3)(p3);
var surf1 = BEZIER(S1)([c2,c3]);
wall.push(MAP(surf1)(domain2));
var surf3 = BEZIER(S1)([c1,c3]);
wall.push(MAP(surf3)(domain2));
return COLOR(baseColor)(T([0])([0.43])(STRUCT(wall)));
}
var wallPorta = T([1])([4.8+0.9+0.6+1.3])(makeWallWithGate());
var wallPorta1 = T([0,1])([stairsLength+2*0.43,
4.8+0.9+0.6+1.3])(makeWallWithGate());
base.push(wallPorta);
base.push(wallPorta1);
var parstairs = COLOR(baseColor)(
SIMPLEX_GRID([[0,stairsLength],[0,0.05],[0,2.9]]));
base.push(T([0,1])([0.86,6.3])(parstairs));
base.push(T([0,1])([0.86,4.8+1.5+1+0.3+2.8-0.05])(parstairs));
//wall sx
var makeWallSxFromStairs = function(){
var makesimpleWall = function(l){
var wall = [];
var l = l || 2;
var wall1 = T([1])([-0.10])(
SIMPLEX_GRID([[0,l],[0,0.10],[0,0.8]]));
wall.push(wall1);
var wall2 = T([1])([-0.065])(
SIMPLEX_GRID([[0,l],[0,0.065],[-0.8,0.4]]));
wall.push(wall2);
var wall3 = T([1])([-0.03])(
SIMPLEX_GRID([[0,l],[0,0.03],[-1.2,1.5]]));
wall.push(wall3);
var wall4 = T([1])([-0.065])(
SIMPLEX_GRID([[0,l],[0,0.065],[-2.7,0.3]]));
wall.push(wall4);
return COLOR(baseColor)(T([1])([0.03])(STRUCT(wall)));
}
var wallLength = 2.5;
var wallBaseSx = makesimpleWall(wallLength);
base.push(T([0,1])([-wallLength,
10.4])(
wallBaseSx));
var wallSemp = drawWallWithWindow1(-0.3,1.5);
wallSemp = T([0,1])([
-wallLength,
10.4])(
R([0,1])([PI/2])(
wallSemp));
base.push(wallSemp);
var wall = [];
var wall1 = T([0])([-0.07])(
SIMPLEX_GRID([[0,0.07],[0,1+0.07],[0,0.8]]));
wall.push(COLOR(baseColor)(wall1));
var wall2 = T([0])([-0.035])(
SIMPLEX_GRID([[0,0.035],[-0.035,1+0.035],[-0.8,0.4]]));
wall.push(COLOR(baseColor)(wall2));
var wall4 = T([0])([-0.035])(
SIMPLEX_GRID([[0,0.035],[-0.035,1+0.035],[-2.7,0.3]]));
wall.push(COLOR(baseColor)(wall4));
var wall5 = T([1])([1-0.07-0.4])(
SIMPLEX_GRID([[0,0.03],[0,0.14+0.4],[0,3]]));
wall.push(COLOR(baseColor)(wall5));
wall = STRUCT(wall);
base.push(T([0,1])([
-5.3,
10.4-0.07])(
wall));
var wallLength3 = 0.27; //1.5-0.93-0.3
var wallBaseSx1 = R([0,1])([-PI/2])(
makesimpleWall(wallLength3));
base.push(T([0,1])([
-5.3,
10.4+1+0.27])(
wallBaseSx1));
var wallSemp1 = drawWallWithWindow1(-0.3,0.3);
wallSemp1 = T([0,1])([-5.3,10.4+1+0.27])(
wallSemp1);
base.push(wallSemp1);
var wallLength3 = 2.5;
var wallBaseSx1 = R([0,1])([-PI/2])(
makesimpleWall(wallLength3));
base.push(T([0,1])([-5.3,10.4+1+0.27+0.3+1+0.3+2.5])(
wallBaseSx1));
}
makeWallSxFromStairs();
baseToRotate = T([0,1])([5.3-9.695,-10.4-9.695])(STRUCT(base));
//Reproduction for the other sides
var r = R([0,1])([-PI/2]);
base = STRUCT([baseToRotate,r,baseToRotate,r,baseToRotate,r,baseToRotate]);
var firstFloor = COLOR(baseColor)(
T([0,1,2])([-9.695,-9.695,3-0.02])(
SIMPLEX_GRID([[0,19.39],[0,19.39],[0,0.02]])));
var drawGround = function(){
//Ground
var ground = [];
var ground1 = T([0,1,2])([-21,-23-30,-1.5])(
SIMPLEX_GRID([[0,46],[0,50+30],[0,1.5]]));
ground.push(ground1);
var ground3 = T([0,1,2])([-21-14,-23-30,-1.5])(
SIMPLEX_GRID([[0,14],[0,23+20+30],[0,1.5]]));
ground.push(ground3);
var ground4 = T([0,1,2])([25,-23-30,-1.5])(
SIMPLEX_GRID([[0,8],[0,30],[0,1.5]]));
ground.push(ground4);
var goundBorder = T([0,1,2])([33,-23-30,-1.5])(
SIMPLEX_GRID([[0,0.6],[0,30],[0,1.5+0.6]]));
ground.push(goundBorder);
var goundBorder1 = T([0,1,2])([25,-23,-1.5])(
SIMPLEX_GRID([[0,8+0.6],[0,0.6],[0,1.5+0.6]]));
ground.push(goundBorder1);
var goundBorder2 = T([0,1,2])([25,-23+0.6,-1.5])(
SIMPLEX_GRID([[0,0.6],[0,50],[0,1.5+0.6]]));
ground.push(goundBorder2);
var goundBorder3 = T([0,1,2])([-21-0.6,27,-1.5])(
SIMPLEX_GRID([[0,46+0.6+0.6],[0,0.6],[0,1.5+0.6]]));
ground.push(goundBorder3);
var goundBorder4 = T([0,1,2])([-21-0.6,20,-1.5])(
SIMPLEX_GRID([[0,0.6],[0,7],[0,1.5+0.6]]));
ground.push(goundBorder4);
var goundBorder5 = T([0,1,2])([-21-0.6-14,20,-1.5])(
SIMPLEX_GRID([[0,14],[0,0.6],[0,1.5+0.6]]));
ground.push(goundBorder5);
var goundBorder6 = T([0,1,2])([-21-14-0.6,-23-30,-1.5])(
SIMPLEX_GRID([[0,0.6],[0,43+30],[0,1.5+0.6]]));
ground.push(goundBorder6);
ground = COLOR(groundColor)(STRUCT(ground));
//Grass
var grass = [];
var grass1 = COLOR(grassColor)(
SIMPLEX_GRID([[0,5.5],[0,10],[0,0.05]]));
grass.push(T([0,1])([-18,-19])(grass1));
grass.push(T([0,1])([18-5.5,-19])(grass1));
var grass2 = COLOR(grassColor)(
SIMPLEX_GRID([[0,11],[0,20],[0,0.05]]));
grass.push(T([0,1])([-5.5,-20-26])(grass2));
var grass3 = COLOR(grassColor)(
SIMPLEX_GRID([[0,10],[0,9],[0,0.05]]));
grass.push(T([0,1])([-21-10-3,20-9-1])(grass3));
var grass4 = COLOR(grassColor)(
SIMPLEX_GRID([[0,10],[0,12],[0,0.05]]));
grass.push(T([0,1])([-21-10-3,-6])(grass4));
var grass5 = COLOR(grassColor)(
SIMPLEX_GRID([[0,10],[0,30+9+4],[0,0.05]]));
grass.push(T([0,1])([-21-10-3,-30-9-14])(grass5));
var p0 = [[-12-0.5,-26,0],[-11-0.5,-26,0],
[-11-0.5,-30,0],[-11-0.5,-45,0],
[-10-0.5,-50,0],[-9-0.5,-52,0],
[-6-0.5,-53,0]];
var k0 = makeKnots(p0,2);
var c0 = NUBS(S0)(2)(k0)(p0);
var p1 = [[-24,-26,0],[-24,-53,0]];
var c1 = BEZIER(S0)(p1);
var vert0 = BEZIER(S1)([c0,c1]);
p0 = movesPoints(p0,2,0.05);
k0 = makeKnots(p0,2);
c0 = NUBS(S0)(2)(k0)(p0);
p1 = movesPoints(p1,2,0.05);
c1 = BEZIER(S0)(p1);
var vert1 = BEZIER(S1)([c0,c1]);
var s0 = BEZIER(S2)([vert0,vert1]);
var grass6 = MAP(s0)(domain3);
grass.push(grass6);
grass.push(S([0])([-1])(grass6));
grass = COLOR(grassColor)(STRUCT(grass));
return STRUCT([ground,grass]);
}
return STRUCT([base,firstFloor,drawGround()]);
}
DRAW(drawBaseOfStructure());
/*
* Facade of the villa
*/
var drawFacade = function(){
var drawGrate = function(hDistance, vDistance) {
var endLine = hDistance >= vDistance ? hDistance : vDistance;
var grateIntervals = 0.5;
var polyStruct = [];
for (var i = 0; i <= endLine; i += grateIntervals) {
polyStruct.push( POLYLINE([[0,0,i],[i,0,0]]) );
}
var quartercolumns = T([0,2])([-(hDistance/2),-(vDistance/2)])( STRUCT(polyStruct) );
var fullcolumns = STRUCT([quartercolumns,
S([2])([-1]), quartercolumns,
S([0])([-1]), quartercolumns,
S([2])([-1]), quartercolumns
]);
return COLOR([0,0,0])( T([0,2])([(hDistance/2),(vDistance/2)])( fullcolumns ) );
};
var drawSquareGrate = function(hDistance, vDistance) {
var grateIntervals = 0.2;
var polyStruct = [];
for (var i = 0; i <= hDistance; i += grateIntervals) {
polyStruct.push( POLYLINE([[i,0,0],[i,0,vDistance]]) );
}
for (var i = 0; i <= vDistance; i += grateIntervals) {
polyStruct.push( POLYLINE([[0,0,i],[hDistance,0,i]]) );
}
return COLOR([0,0,0])(STRUCT(polyStruct));
};
var drawVerticalGrate = function(hDistance, vDistance) {
var grateIntervals = 0.15;
var color = [0,0,0];
var polyStruct = [];
for (var i = 0; i <= hDistance; i += grateIntervals) {
polyStruct.push( POLYLINE([[i,0,0],[i,0,vDistance]]) );
}
return COLOR([0,0,0])(STRUCT(polyStruct));
};
var drawWindowEmbroidery = function(d){
var d = d || 0.05;
//Surface sx
var p0 = [[0,0,0],[0,-0.025,0.03],[0,-0.03,0.05],
[0,-0.02,0.07],[0,-0.02,0.09],
[0,-0.06,0.11],[0,-0.06,0.18],[0,-0,0.2]];
var k0 = [0,0,0,1,2,3,4,5,6,6,6];
var c0 = NUBS(S0)(2)(k0)(p0);
var p1 = [p0[0],p0[7]];
var c1 = BEZIER(S0)(p1);
var vert1 = BEZIER(S1)([c0,c1]);
//Surface dx
p0 = [[0+d,-0,0],[0+d,-0.025,0.03],[0+d,-0.03,0.05],
[0+d,-0.02,0.07],[0+d,-0.02,0.09],
[0+d,-0.06,0.11],[0+d,-0.06,0.18],[0+d,-0,0.2]];
k0 = [0,0,0,1,2,3,4,5,6,6,6];
c0 = NUBS(S0)(2)(k0)(p0);
p1 = [p0[0],p0[7]];
c1 = BEZIER(S0)(p1);
var vert2 = BEZIER(S1)([c0,c1]);
var vert = BEZIER(S2)([vert1,vert2]);
return S([0,1,2])([2,2,2])(MAP(vert)(domain3));
};
var drawEdgewall0 = function (d){
var d = d || 2;
//Surface sx
var p0 = [[0,0,0],[0,0,0],
[0,-0.03,0],[0,-0.03,0.06],[0,-0.06,0.06],
[0,-0.06,0.12],[0,-0.09,0.12],[0,-0.09,0.20],
[0,-0.13,0.22],[0,-0.09,0.24],[0,-0.09,0.26],
[0,-0.13,0.27],[0,-0.13,0.48],[0,-0.09,0.49],[0,-0.09,0.49],
[0,-0.09,0.5],[0,-0.09,0.5],[0,-0.13,0.5],[0,-0.13,0.5],
[0,-0.13,0.9],[0,-0.2,1],[0,-0.2,1],[0,0,1],
[0,0,1]
];
var k0 = makeKnots(p0,1)
var c0 = NUBS(S0)(1)(k0)(p0);
var p1 = [p0[0],p0[p0.length-1]];
var c1 = BEZIER(S0)(p1);
var vert1 = BEZIER(S1)([c0,c1]);
//Surface dx
p0 = movesPoints(p0,0,d)
k0 = makeKnots(p0,1)
c0 = NUBS(S0)(1)(k0)(p0);
p1 = [p0[0],p0[p0.length-1]];
c1 = BEZIER(S0)(p1);
var vert2 = BEZIER(S1)([c0,c1]);
var wall1 =
SIMPLEX_GRID([[0,d],[0,0.3],[0,1]]);
//Product surfaces
var vert = BEZIER(S2)([vert1,vert2]);
return COLOR(baseColor)(
STRUCT([MAP(vert)(domain3),wall1]));
};
var drawEdgewall1 = function (d){
var d = d || 2;
//Surface sx
var p0 = [[0,0,0],[0,-0.04,0.10],[0,-0.13,0.15],
[0,-0.24,0.19],[0,-0.24,0.19],
[0,-0.22,0.24],[0,-0.3,0.315],
[0,-0.335,0.3],[0,-0.335,0.3],
[0,-0.5,0.6],[0,-0.5,0.6],
[0,0,0.6]];
var k0 = makeKnots(p0,2);
var c0 = NUBS(S0)(2)(k0)(p0);
var p1 = [p0[0],p0[11]];
var c1 = BEZIER(S0)(p1);
var vert1 = BEZIER(S1)([c0,c1]);
//Surface dx
p0 = [[0+d,0,0],[0+d,-0.04,0.10],[0+d,-0.13,0.15],
[0+d,-0.24,0.19],[0+d,-0.24,0.19],
[0+d,-0.22,0.24],[0+d,-0.3,0.315],
[0+d,-0.335,0.3],[0+d,-0.335,0.3],
[0+d,-0.5,0.6],[0+d,-0.5,0.6],
[0+d,0,0.6]];
k0 = makeKnots(p0,2);
c0 = NUBS(S0)(2)(k0)(p0);
p1 = [p0[0],p0[11]];
c1 = BEZIER(S0)(p1);
var vert2 = BEZIER(S1)([c0,c1]);
var wall1 = SIMPLEX_GRID([[0,d],[0,0.3],[0,0.6]]);
var vert = BEZIER(S2)([vert1,vert2]);
return COLOR(baseColor)(STRUCT([MAP(vert)(domain3),wall1]));
};
var drawWindow1 = function(l){
var l = l || 5;
var walls = [];
var capwall = drawWindowEmbroidery();
var wall1 =
SIMPLEX_GRID([[0,0.1],[0,0.4],[0,2.1+0.34-0.22]]);
walls.push(T([0,1,2])([0.5,-0.03,-0.34+0.22])(wall1));
walls.push(T([0,1,2])([-0.5-0.1,-0.03,-0.34+0.22])(wall1));
var wall3 = SIMPLEX_GRID([[0,1],[0,0.4],[0,0.1]]);
walls.push(T([0,1,2])([-0.5,-0.03,-0.1])(wall3));
walls.push(T([0,1,2])([-0.5,-0.03,2])(wall3));
var wall2 = SIMPLEX_GRID([[0,1.4],[0,0.09],[0,0.03]]);
walls.push(T([0,1,2])([-0.7,-0.03-0.09,-0.03])(wall2));
var wall4 = SIMPLEX_GRID([[0,1.3],[0,0.07],[0,0.09]]);
walls.push(T([0,1,2])([-0.65,-0.03-0.07,-0.09-0.03])(wall4));
var wall5 = SIMPLEX_GRID([[0,1.2],[0,0.43],[0,0.2]]);
walls.push(T([0,1,2])([-0.6,-0.03-0.03,-0.09-0.03-0.2])(wall5));
var wall7 = SIMPLEX_GRID([[0,1.2],[0,0.3],[0,5-0.34-0.34-2.1+0.06+1]]);
walls.push(T([0,2])([-0.6,2.1])(wall7));
var wall6 = SIMPLEX_GRID([[0,0.4],[0,0.3],[0,4.68+0.02+1]]);
walls.push(T([0,2])([0.5+0.1,-0.32])(wall6));
walls.push(T([0,2])([-0.5-0.1-0.4,-0.32])(wall6));
var wall8 = SIMPLEX_GRID([[0,1.5],[0,0.15],[0,0.1]]);
walls.push(T([0,1,2])([-0.75,-0.09,2.1+0.05])(wall8));
walls.push(T([0,2])([0.75-0.1,2.1+0.05-0.4])(capwall));
walls.push(T([0,2])([-0.75,2.1+0.05-0.4])(capwall));
var wall9 = SIMPLEX_GRID([[0,0.866],[0,0.15],[0,0.1]]);
walls.push(
T([0,1,2])([+0.7,-0.09,2.1+0.05+0.01])(
R([0,2])([PI/6 + PI])(
T([2])([-0.1])(wall9))));
walls.push(
T([0,1,2])([-0.7,-0.09,2.1+0.05+0.01])(
R([0,2])([-PI/6])(wall9)));
var wall10 = SIMPLEX_GRID([[0,1+0.2+0.4+0.4],[0,0.1+0.3],[0,0.3]]);
walls.push(T([0,1,2])([-1,-0.035,-0.32-0.3])(wall10));
var wall = COLOR(baseColor)(STRUCT(walls));
var windows = [];
var verticalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.1],[0,0.05],[0,1.25]]));
var orizontalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,1-0.08],[0,0.05],[0,0.1]]));
var glass = COLOR(windowsColor)(BOUNDARY(
SIMPLEX_GRID([[0,1],[0,0.01],[0,2]])));
var stripe = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.04],[0,0.05],[0,2]]));
windows.push(T([0,1])([-0.5,0.01+0.2])(glass));
//windows.push(T([0,1])([-0.5,0.01+0.2+0.1])(COLOR([0.9999999,0.9999999,0.99999,1])(SIMPLEX_GRID([[0,1],[0,0.01],[0,2]]))));
windows.push(T([0,1])([-0.5,0.01+0.2])(drawSquareGrate(1,2)));
windows.push(T([0,1])([0.46,0.2-0.04])(stripe));
windows.push(T([0,1])([-0.46-0.04,0.2-0.04])(stripe));
windows.push(T([0,1,2])([-0.05,0.2-0.04,0.05])(verticalBarrier));
windows.push(T([0,1,2])([-0.5+0.04,0.2-0.04,1.3])(orizontalBarrier));
windows.push(T([0,1,2])([-0.5+0.04,0.2-0.04,1.9])(orizontalBarrier));
windows.push(T([0,1])([-0.5+0.04,0.2-0.04])(orizontalBarrier));
windows.push(wall);
return STRUCT([T([2])([6])(drawEdgewall0()),
T([2])([7])(drawWindow2()),
T([0,2])([1,0.32+0.3])(STRUCT(windows)),
T([2])([7+2.1])(drawEdgewall1())]);
};
var simpleWall = function(l){
var walls = [];
var l = l || 2;
var wall = SIMPLEX_GRID(
[[0,l],[0,0.3],[0,0.3]]);
walls.push(T([1])([-0.035])(wall));
var wall1 = SIMPLEX_GRID(
[[0,l],[0,0.3],[0,6-0.3]]);
walls.push(T([2])([0.3])(wall1));
var wall2 = SIMPLEX_GRID(
[[0,l],[0,0.3],[0,2.1]]);
return COLOR(baseColor)(STRUCT([T([2])([6])(drawEdgewall0(l)),
T([2])([6+1])(wall2),
STRUCT(walls),
T([2])([7+2.1])(drawEdgewall1(l))]));
};
var simpleWall1 = function(l){
var walls = [];
var l = l || 2;
var wall1 = SIMPLEX_GRID(
[[0,l],[0,0.3],[0,6]]);
walls.push(wall1);
var wall2 = SIMPLEX_GRID(
[[0,l],[0,0.3],[0,2.1]]);
return COLOR(baseColor)(STRUCT([T([2])([6])(drawEdgewall0(l)),
T([2])([6+1])(wall2),
STRUCT(walls),
T([2])([7+2.1])(drawEdgewall1(l))]));
};
var drawWindow2 = function (h){
var h = h || 5
var walls = [];
var wall1 = SIMPLEX_GRID([[0,0.5],[0,0.3],[0,2.1]]);
walls.push(T([0,1,2])([0.5,-0.03,-0.7])(wall1));
walls.push(T([0,1,2])([-0.5-0.5,-0.03,-0.7])(wall1));
var wall3 = SIMPLEX_GRID([[0,1],[0,0.3],[0,0.3]]);
walls.push(T([0,1,2])([-0.5,-0.03,1.1])(wall3));
var wall4 = SIMPLEX_GRID([[0,1],[0,0.3],[0,0.7]]);
walls.push(T([0,1,2])([-0.5,-0.03,-0.7])(wall4));
var wall = COLOR(baseColor)(STRUCT(walls));
var windows = [];
var verticalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.08],[0,0.05],[0,1.1-0.08]]));
var glass = COLOR(windowsColor)(BOUNDARY(
SIMPLEX_GRID([[0,1],[0,0.01],[0,1.1]])));
var stripe = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.04],[0,0.05],[0,1.1-0.04-0.04]]));
var stripeOriz = COLOR([0,0,0])(
SIMPLEX_GRID([[0,1],[0,0.05],[0,0.04]]));
windows.push(T([0,1,2])([-0.04,0.2-0.04,0.04])(verticalBarrier));
windows.push(T([0,1])([-0.5,0.01+0.2])(glass));
//windows.push(T([0,1])([-0.5,0.01+0.2+0.1])(COLOR([0.9999999,0.9999999,0.99999,1])(SIMPLEX_GRID([[0,1],[0,0.01],[0,1.1]]))));
windows.push(T([0,1,2])([0.46,0.2-0.04,0.04])(stripe));
windows.push(T([0,1,2])([-0.46-0.04,0.2-0.04,0.04])(stripe));
windows.push(T([0,1,2])([-0.5,0.2-0.04,1.06])(stripeOriz));
windows.push(T([0,1])([-0.5,0.2-0.04])(stripeOriz));
windows.push(wall);
return T([0,1,2])([1,0.03,0.7])(STRUCT(windows));
};
var drawWindow3 = function(h){
var h = h || 5
var walls = [];
var wall1 = SIMPLEX_GRID([[0,0.5],[0,0.3],[0,1.7+0.5+0.7+1]]);
walls.push(T([0,1,2])([0.5,-0.03,-0.62])(wall1));
walls.push(T([0,1,2])([-0.5-0.5,-0.03,-0.62])(wall1));
var wall3 = SIMPLEX_GRID([[0,1],[0,0.3],[0,0.5+1+0.08]]);
walls.push(T([0,1,2])([-0.5,-0.03,1.7])(wall3));
var wall4 = SIMPLEX_GRID([[0,1],[0,0.3],[0,0.62]]);
walls.push(T([0,1,2])([-0.5,-0.03,-0.62])(wall4));
var wall = COLOR(baseColor)(STRUCT(walls));
var windows = [];
var verticalBarrier = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.1],[0,0.05],[0,1.7-0.08]]));
var glass = COLOR(windowsColor)(BOUNDARY(
SIMPLEX_GRID([[0,1],[0,0.01],[0,1.7]])));
var stripe = COLOR([0,0,0])(
SIMPLEX_GRID([[0,0.04],[0,0.05],[0,1.7-0.04-0.04]]));
var stripeOriz = COLOR([0,0,0])(
SIMPLEX_GRID([[0,1],[0,0.05],[0,0.04]]));
windows.push(T([0,1,2])([-0.05,0.2-0.04,0.04])(verticalBarrier));
windows.push(T([0,1])([-0.5,0.01+0.2])(glass));
//windows.push(T([0,1])([-0.5,0.01+0.2+0.1])(COLOR([0.9999999,0.9999999,0.99999,1])(SIMPLEX_GRID([[0,1],[0,0.01],[0,1.7]]))));
windows.push(T([0,1])([-0.5,0.01+0.2])(drawGrate(1,1.7)));
windows.push(T([0,1,2])([0.46,0.2-0.04,0.04])(stripe));
windows.push(T([0,1,2])([-0.46-0.04,0.2-0.04,0.04])(stripe));
windows.push(T([0,1,2])([-0.5,0.2-0.04,1.66])(stripeOriz));
windows.push(T([0,1])([-0.5,0.2-0.04])(stripeOriz));
windows.push(wall);
return STRUCT([T([2])([6])(drawEdgewall0()),
T([2])([7])(drawWindow2()),
T([2])([3.9])(drawWindow2()),
T([0,1,2])([1,0.03,0.62])(STRUCT(windows)),
T([2])([7+2.1])(drawEdgewall1())]);
};
var drawAngleStruttura = function(){
var Edge = [];
var EdgeTriangolare = SIMPLICIAL_COMPLEX([[0,0],[0,0.3],[0.3,0]])([[0,1,2]]);
var extrude1 = EXTRUDE([7+2.1+0.6])(EdgeTriangolare);
Edge.push(extrude1);
//1 Edge
var wall = SIMPLEX_GRID([[0,0.3+0.035],[0,0.035],[0,0.3]]);
Edge.push(T([1])([-0.035])(wall));
//2 Edge 0 - 0.3
var wall1 = SIMPLEX_GRID([[0,0.3],[0,0.035],[0,0.3]]);
Edge.push(T([1])([-0.035])(wall));
//3 Edge at 6 (1)
//Surface sx
var p0 = [[0,0,0],[0,0,0],
[0,-0.03,0],[0,-0.03,0.06],[0,-0.06,0.06],
[0,-0.06,0.12],[0,-0.09,0.12],[0,-0.09,0.20],
[0,-0.13,0.22],[0,-0.09,0.24],[0,-0.09,0.26],
[0,-0.13,0.27],[0,-0.13,0.48],[0,-0.09,0.49],[0,-0.09,0.49],
[0,-0.09,0.5],[0,-0.09,0.5],[0,-0.13,0.5],[0,-0.13,0.5],
[0,-0.13,0.9],[0,-0.2,1],[0,-0.2,1],[0,0,1],
[0,0,1]];
var p1 = p0;
p0 = movesPoints(p0,2,6);
var k0 = makeKnots(p0,1);
var c0 = NUBS(S0)(1)(k0)(p0);
var p3 = [p0[0],p0[p0.length-1]];
var c3 = BEZIER(S0)(p3);
var vert1 = BEZIER(S1)([c0,c3]);
p1 = scalePoints(p1,[1,SQRT(2),1]);
p1 = rotatePoints(p1,PI/4,2);
p1 = movesPoints(p1,2,6);
p1 = movesPoints(p1,0,0.3);
k1 = makeKnots(p1,1);
c1 = NUBS(S0)(1)(k1)(p1);
p2 = [p0[0],p0[p0.length-1]];
c2 = BEZIER(S0)(p2);
var vert2 = BEZIER(S1)([c1,c2]);
var vert = BEZIER(S2)([vert1,vert2]);
Edge.push(MAP(vert)(domain3));
//4 Edge at 7 +2.1 (0.6)
//Surface sx
p0 = [[0,0,0],[0,-0.04,0.10],[0,-0.13,0.15],
[0,-0.24,0.19],[0,-0.24,0.19],
[0,-0.22,0.24],[0,-0.3,0.315],
[0,-0.335,0.3],[0,-0.335,0.3],
[0,-0.5,0.6],[0,-0.5,0.6],
[0,0,0.6]];
p1 = p0;
p0 = movesPoints(p0,2,7+2.1);
k0 = [0,0,0,1,2,3,4,5,6,7,8,9,10,10,10];
c0 = NUBS(S0)(2)(k0)(p0);
p3 = [p0[0],p0[11]];
c3 = BEZIER(S0)(p3);
vert1 = BEZIER(S1)([c0,c3]);
p1 = scalePoints(p1,[1,SQRT(2),1]);
p1 = rotatePoints(p1,PI/4,2);
p1 = movesPoints(p1,2,7+2.1);
p1 = movesPoints(p1,0,0.3);
k1 = [0,0,0,1,2,3,4,5,6,7,8,9,10,10,10];
c1 = NUBS(S0)(2)(k1)(p1);
p2 = [p1[0],p1[11]];
c2 = BEZIER(S0)(p2);
var vert2 = BEZIER(S1)([c1,c2]);
var vert = BEZIER(S2)([vert1,vert2]);
Edge.push(MAP(vert)(domain3));
return COLOR(baseColor)(STRUCT(Edge));
};
var drawTympanumPorta = function(){
var Tympanum = [];
var drawEmbroidery = function(l,d,trasl,x,y,z,n,f){
var cubes = [];
var p = l - (d + f + 2*x);
var i = p/n;
var cube = SIMPLEX_GRID([[0,x],[0,y],[0,z]]);
cubes.push(T([0,2])([d-(i/2-x/2),trasl])(cube));
cubes.push(T([0,2])([l-f-x+(i/2-x/2),trasl])(cube));
var j = 0;
while (j < n) {