-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtesting12.py
1003 lines (918 loc) · 57 KB
/
testing12.py
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
from visual import *
from visual.controls import *
import math
class Colliding: #Nothing in here but has_intersect_z is actually used
def find_corners(self,*things):
'''Find the corners you need to project on axes for the separating axis theorem.
Works for boxes and cylinders only, and only in the xy plane (cylinders must be a circle in the xy plane).
For cylinders, finds the points on the circumfrence along the axis pointing towards the boxes center.
For boxes, finds the corners.'''
res = []
for thing in things:
if thing.__class__.__name__ == 'box':
ax = thing.axis
p = [.5*vector(thing.size.x,thing.size.y,0), #makes a list of the corner points assuming a box at (0,0,0) perpendicular to x and y axes
.5*vector(thing.size.x,-1*thing.size.y,0),
.5*vector(-1*thing.size.x,-1*thing.size.y,0),
.5*vector(-1*thing.size.x,thing.size.y,0)]
angle = ax.diff_angle(vector(1,0,0))
for i in range(len(p)): #rotate and shift the box
p[i] = rotate(p[i], angle = angle, axis = (0,0,1))
p[i] = p[i] + thing.pos
res.append(p)
if thing.__class__.__name__ == 'cylinder':
if thing.axis.x==0 and thing.axis.y==0:
p = []
for thing2 in things:
if thing2 != thing:
ax = thing.pos - thing2.pos
vec = vector(ax.x,ax.y,0)
vec.mag = thing.radius
p.append(thing.pos + vec)
p.append(thing.pos - vec)
res.append(p)
return tuple(res)
def has_intersect_xy(self,p1,p2):
'''takes two lists of the vectors that are the corners of two concave shapes
and finds if the shapes intersect using the separating axis theorem.
Has some bug I haven't found yet - doesn't detect collsion in all cases.'''
Flag = 0
for i in range(len(p1)):
proj1 = [] #initialize lists to hold the projections of the corners onto the vectors
proj2 = []
side = p1[i] - p1[i-1] #find the sides we need to check along
if len(p1)<3 and i==1: #basically if this a cylinder and the second time through
vec = side #also check the vector going through the center
else:
vec = cross(side,vector(0,0,1)) #the vector you need to check, in general, is the one perpendicular to the side
for j in range(len(p1)): #find all the projections of p1 onto the vector
proj1.append(dot(p1[j],vec))
for k in range(len(p2)): #find all the projections of p2 onto the vector
proj2.append(dot(p2[k],vec))
if not ((max(proj2) > max(proj1) and min(proj2) > max(proj1)) or (max(proj2) < min(proj1) and min(proj2) < min(proj1))): #if the aren't disjoint
Flag += 1
for i in range(len(p2)): # do the same as above, with the second object's points
proj1 = []
proj2 = []
side = p2[i] - p2[i-1]
if len(p2)<3 and i==1:
vec = side
else:
vec = cross(side,vector(0,0,1))
for j in range(len(p1)):
proj1.append(dot(p1[j],vec))
for k in range(len(p2)):
proj2.append(dot(p2[k],vec))
if not ((max(proj2) > max(proj1) and min(proj2) > max(proj1)) or (max(proj2) < min(proj1) and min(proj2) < min(proj1))):
Flag += 1
if Flag == len(p1)+len(p2): #if they have overlapped on every vector, they collide (in the x,y plane)
return True
else:
return False
def has_intersect_z(self,*things):
'''finds if two objects (cylinders or boxes that have their vertical orientation parallel
to (0,0,1)) intersect vertically (on the z axis)'''
things = list(things)
try:
while len(things) > 1:#while there remain two objects that have not been checked against each other
thing1 = things.pop(0)
try:
center1 = thing1.frame.pos.z
except:
center1 = 0
if thing1.__class__.__name__ == 'box':
center1 += thing1.pos.z
dist1 = abs(.5*thing1.size.z) #the distance to the top and bottom from the center
elif thing1.__class__.__name__ == 'cylinder' and thing1.axis.x == 0 and thing1.axis.y == 0: #if this is a vertically oriented cylinder
dist1 = abs(.5*thing1.length)
center1 += thing1.pos.z + (dist1 * (thing1.axis.z/abs(thing1.axis.z))) #the vertical center of the cylinder
for thing2 in things: #same as above
try:
center2 = thing2.frame.pos.z
except:
center2 = 0
if thing2.__class__.__name__ == 'box':
center2 += thing2.pos.z
dist2 = abs(.5*thing2.size.z)
if thing2.__class__.__name__ == 'cylinder' and thing2.axis.x == 0 and thing1.axis.y == 0:
dist2 = abs(.5*thing2.length)
center2 += thing2.pos.z + (dist2 * (thing2.axis.z/abs(thing2.axis.z)))
if center1+dist1-.01 > center2-dist2 and center1-dist1+.01 < center2+dist2: #If the two vertical spans are not disjoint
return True
return False
except:
return False
def collide(self,thing1,thing2):
'''only works for boxes and cylinders with axis n*(0,0,1).
Finds if they collide in the x, y, and z directions'''
p1,p2 = self.find_corners(thing1,thing2)
if self.has_intersect_xy(p1,p2):
return self.has_intersect_z(thing1,thing2)
return False
def are_colliding(self,thing1,thing2):
'''takes things with object list and tests every thing in each object list against each other for a collision.'''
try:
for subthing1 in thing1.ObjectList:
try:
for subthing2 in thing2.ObjectList:
if self.collide(subthing1,subthing2):
return True
except:
return False
except:
return False
return False
def collide_with_room(self,thing, room):
for other_thing in room.ObjectList:
if other_thing != thing:
if self.are_colliding(thing,other_thing):
return True
return False
class Room(object):
def __init__(self,width=14.5,height=10,length=20,ambient=0.2,lights=[0.5*norm(vector(0,0,-2)),0.25*norm(vector(0,0.5,2))],autoscale=False,walls=True):
self.Width = width
self.Height = height
self.Length = length
self.Display = display(center = (width/2.,height/2.,length/2.), #create the display window
uniform = True,
range = (width,height,length),
autoscale = autoscale,
ambient = ambient,
lights = lights,
up = (0,0,1),
forward = (0,-.01,-1))
self.Walls = Walls(width, height, length, walls) #create the walls
self.Selected = None
self.ObjectList = [self.Walls] #add the walls to the object list - room object list should only contain things with an object list. Those object lists should only contain objects
def handler(self): #take input, call interaction functions as appropriate
self.walls_view()
if self.Display.mouse.events:
m1 = self.Display.mouse.getevent() #get any mouse events
else:
m1=None
if m1:
if m1.click:
done = False
for thing in self.ObjectList[1:]: #if an object is picked, or is currently being dragged or turned, call drag (currently a little buggy - try it out and you'll see what i mean)
picked= False
for part in thing.ObjectList:
picked = (self.Display.mouse.pick == part) or picked
if picked:
done = True
if self.Selected:
self.Selected.Selected = False
self.Selected = thing
thing.Selected = True
if not done:
if self.Selected:
self.Selected.Selected = False
self.Selected = None
if self.Display.kb.keys: # if the keyboard's been used
k = self.Display.kb.getkey()
if k == '1' or k =='2' or k == '3' or k =='4' or k=='5': #if the x,y,or z keys were pressed, call snap to view
self.snap_to_view(k)
if k =='s': #if the s key was pressed, called snap to grid (right now, it just snaps everything to grid. if we want to change that, we can use the picking code below
if self.Selected:
self.Selected.Snap_To_Grid(self.Display)
else:
for thing in self.ObjectList[1:]:
thing.Snap_To_Grid(self.Display)
if k =='up' or k=='down' or k=='left' or k=='right':
if self.Selected:
self.Selected.move(k)
else:
self.rotate_view(k)
if k=='g':
if self.Selected:
self.Selected.gravity(self.ObjectList[0].ObjectList[0])
else:
for thing in self.ObjectList[1:]:
thing.gravity(self.ObjectList[0].ObjectList[0])
if k=='delete':
if self.Selected:
self.Selected.delete()
for thing in self.ObjectList[1:]: #if an object is picked, or is currently being dragged or turned, call drag (currently a little buggy - try it out and you'll see what i mean)
picked= False
for part in thing.ObjectList:
picked = (self.Display.mouse.pick == part) or picked
if picked or thing.DragSettings[0] or thing.DragSettings[3]:
thing.drag(self,m1)
#print thing, picked
def walls_view(self): #make the walls disappear if they're between the viewer and the center
try:
if self.Display.forward.x>.29:
self.Walls.WestWall.visible = False
self.Walls.EastWall.visible = True
if self.Display.forward.x<-.29:
self.Walls.EastWall.visible = False
self.Walls.WestWall.visible = True
if self.Display.forward.y>.23:
self.Walls.NorthWall.visible = False
self.Walls.SouthWall.visible = True
if self.Display.forward.y<-.23:
self.Walls.SouthWall.visible = False
self.Walls.NorthWall.visible = True
if self.Display.forward.z>0.34:
self.Walls.Floor.visible = False
self.Walls.Ceiling.visible = True
if self.Display.forward.z<0.34:
self.Walls.Ceiling.visible = False
self.Walls.Floor.visible = True
except:
return
def snap_to_view(self,k):
if k == '1':
self.Display.forward = vector(1,0,0)
if k == '2':
self.Display.forward = vector(0,1,0)
if k == '3':
self.Display.forward = vector(-1,0,0)
if k == '4':
self.Display.forward = vector(0,-1,0)
if k == '5':
self.Display.forward = vector(0,.01,-1)
def rotate_view(self,k):
if k=='up':
if abs(self.Display.forward.norm().x) < .1 and abs(self.Display.forward.norm().y) < 0.1 and self.Display.forward.norm().z<0:
pass
else:
axis = cross(self.Display.forward,self.Display.up)
self.Display.forward = rotate(self.Display.forward, angle = -.1,axis = axis)
elif k =='down':
axis = cross(self.Display.forward,self.Display.up)
self.Display.forward = rotate(self.Display.forward, angle = .1,axis = axis)
elif k == 'left':
self.Display.forward = rotate(self.Display.forward, angle = -.1,axis = self.Display.up)
else:
self.Display.forward = rotate(self.Display.forward, angle = .1,axis = self.Display.up)
class Walls: #class only to be called by room function to create walls
def __init__(self,width, height, length, walls): #width = x, height = z, length = y, walls = boolean
self.WallThickness = 0.425
self.Floor = box(pos=(width/2.,length/2.,0), axis = (1,0,0), size=(width,length,self.WallThickness), color=(.5,.25,.15))
self.ObjectList = [self.Floor]
if walls:
self.Ceiling = box(pos=(width/2.,length/2.,height), axis = (1,0,0), size=(width,length,self.WallThickness))
self.NorthWall = box(pos=(width/2.,0,height/2.), axis=(1,0,0), size = (width,self.WallThickness,height))
self.EastWall = box(pos=(width,length/2.,height/2.), axis=(1,0,0), size = (self.WallThickness,length,height))
self.SouthWall = box(pos=(width/2.,length,height/2.), axis=(1,0,0), size = (width,self.WallThickness,height))
self.WestWall = box(pos=(0,length/2.,height/2.), axis=(1,0,0),size = (self.WallThickness,length,height))
self.ObjectList = self.ObjectList + [self.Ceiling,self.NorthWall,self.EastWall,self.SouthWall,self.WestWall]
class RightDormRoom(Room):
def __init__(self):
Room.__init__(self)
self.WallThickness = 0.425
self.Walls.DivWall1 = box(pos=(self.Width-4,13,self.Height/2.), axis=(1,0,0), size = (8,self.WallThickness,self.Height))
self.Walls.DivWall2 = box(pos=(1.75,13,self.Height/2.), axis=(1,0,0), size = (3.5,self.WallThickness,self.Height),)
self.Walls.SinkBack = box(pos=(self.Width-8+2.1,13+1.4,self.Height/2.), axis=(1,0,0), size = (self.WallThickness,2.8,self.Height))
self.Walls.SinkSide = box(pos=(self.Width-8+2.1/2,13+2.8-self.WallThickness/2.,self.Height/2.), axis=(1,0,0), size = (2.1,self.WallThickness,self.Height))
self.Walls.Sink = box(pos=(self.Width-8+1.05,13+1.4,1.4), axis=(1,0,0), size = (2.1,2.8,2.8))
self.Walls.Window = box(pos=(self.Width/2.,0.01,4.55), axis=(1,0,0), size = (4.5,self.WallThickness,7.15), color=color.yellow, material = materials.emissive)
self.Walls.ObjectList = self.Walls.ObjectList + [self.Walls.DivWall1,self.Walls.DivWall2,self.Walls.SinkBack,self.Walls.SinkSide,self.Walls.Sink,self.Walls.Window]
def walls_view(self):
if self.Display.forward.x>.29:
self.Walls.WestWall.visible = False
self.Walls.EastWall.visible = True
if self.Display.forward.x<-.29:
self.Walls.EastWall.visible = False
self.Walls.WestWall.visible = True
if self.Display.forward.y>.21:
self.Walls.NorthWall.visible = False
self.Walls.Window.visible = False
self.Walls.SouthWall.visible = True
if self.Display.forward.y<-.21:
self.Walls.SouthWall.visible = False
self.Walls.NorthWall.visible = True
self.Walls.Window.visible = True
if self.Display.forward.z>0.35:
self.Walls.Floor.visible = False
self.Walls.Ceiling.visible = True
if self.Display.forward.z<0.35:
self.Walls.Ceiling.visible = False
self.Walls.Floor.visible = True
class LeftDormRoom(Room):
def __init__(self):
Room.__init__(self)
self.WallThickness = 0.425
self.Walls.DivWall1 = box(pos=(4,13,self.Height/2.), axis=(1,0,0), size = (8,self.WallThickness,self.Height))
self.Walls.DivWall2 = box(pos=(self.Width-1.75,13,self.Height/2.), axis=(1,0,0), size = (3.5,self.WallThickness,self.Height),)
self.Walls.SinkBack = box(pos=(8-2.1,13+1.4,self.Height/2.), axis=(1,0,0), size = (self.WallThickness,2.8,self.Height))
self.Walls.SinkSide = box(pos=(8-2.1/2,13+2.8-self.WallThickness/2.,self.Height/2.), axis=(1,0,0), size = (2.1,self.WallThickness,self.Height))
self.Walls.Sink = box(pos=(8-1.05,13+1.4,1.4), axis=(1,0,0), size = (2.1,2.8,2.8))
self.Walls.Window = box(pos=(self.Width/2.,0.01,4.55), axis=(1,0,0), size = (4.5,self.WallThickness,7.15), color=color.yellow, material = materials.emissive)
self.Walls.ObjectList = self.Walls.ObjectList + [self.Walls.DivWall1,self.Walls.DivWall2,self.Walls.SinkBack,self.Walls.SinkSide,self.Walls.Sink,self.Walls.Window]
def walls_view(self):
if self.Display.forward.x>.29:
self.Walls.WestWall.visible = False
self.Walls.EastWall.visible = True
if self.Display.forward.x<-.29:
self.Walls.EastWall.visible = False
self.Walls.WestWall.visible = True
if self.Display.forward.y>.21:
self.Walls.NorthWall.visible = False
self.Walls.Window.visible = False
self.Walls.SouthWall.visible = True
if self.Display.forward.y<-.21:
self.Walls.SouthWall.visible = False
self.Walls.NorthWall.visible = True
self.Walls.Window.visible = True
if self.Display.forward.z>0.35:
self.Walls.Floor.visible = False
self.Walls.Ceiling.visible = True
if self.Display.forward.z<0.35:
self.Walls.Ceiling.visible = False
self.Walls.Floor.visible = True
class Furniture:
def __init__(self, Room, Width, Length, Height, Position = []):
Room.Display.select()
self.Container = frame(display = Room.Display)
self.Width = Width
self.Length = Length
self.Height = Height
self.ObjectList = []
self.Grid_Resolution = 1./6
self.DragSettings = (False,None,None,False,None,None,None) #inital values for the drag function
self.Collide = Colliding()
self.Selected = False
if Position == []:
self.Pos = vector(0,0,Height)
else:
self.Pos = Position
Room.ObjectList = Room.ObjectList + [self]
def gravity(self, floor):
while True:
for part in self.ObjectList:
if self.Collide.has_intersect_z(part,floor):
print part
return
try:
if part.pos.z + self.Container.pos.z < -5:
return
except:
pass
self.Container.pos -= vector(0,0,.005)
def move(self,k):
if k=='up':
self.Container.pos -= vector(0,1./3,0)
if k=='down':
self.Container.pos += vector(0,1./3,0)
if k=='left':
self.Container.pos += vector(1./3,0,0)
if k=='right':
self.Container.pos -= vector(1./3,0,0)
def drag(self, room, m):
drag, New_Pos, Drag_Pos, turn, Turn_Start, Turn_End, m1 = self.DragSettings
m1 = m
scene = room.Display
try:
if m1.click:
drag = False
turn = False
elif m1.press and not m1.alt: #If mousebutton is pressed and alt is not
#If cursor position is within the bounds of the tabletop
for part in self.ObjectList:
drag = (m1.pick == part) or drag
if drag:
Drag_Pos = m1.pos #saves initial location
picked = False
elif m1.press and m1.alt: #If mousebutton is pressed and alt is also
for part in self.ObjectList:
turn = (m1.pick==part) or turn
if turn:
Turn_Start = m1.pos
picked = False
except:
picked = False
if drag:
New_Pos = scene.mouse.pos
try:
if m1.drop or m1.click:
drag = False
except:
drag = drag
while New_Pos and Drag_Pos and New_Pos!= Drag_Pos: #if the cursor has move from its initial location
Move = New_Pos - Drag_Pos
Drag_Pos = New_Pos #save new position
#Move object to the new location
self.Container.pos += Move
'''if self.Collide.collide_with_room(self, room):
for part in self.ObjectList:
part.pos -= Move'''
if turn:
Turn_End = scene.mouse.pos
try:
if m1.drop or m1.click:
turn = False
except:
turn = turn
while Turn_End and Turn_Start and Turn_End!=Turn_Start:
Distance = Turn_End.x - Turn_Start.x
Turn_Start = Turn_End
Spin = math.pi*(Distance/((self.Width+self.Length)))
self.Container.rotate(angle = Spin, axis = (0,0,1), origin = self.Container.pos)
self.DragSettings = (drag, New_Pos, Drag_Pos, turn, Turn_Start, Turn_End, m1)
def Snap_To_Grid(self, scene):
Grid_X = int(self.Container.pos.x/self.Grid_Resolution)
Grid_Y = int(self.Container.pos.y/self.Grid_Resolution)
Grid_Z = int(self.Container.pos.z/self.Grid_Resolution)
Move_Pos = vector(self.Container.pos.x- Grid_X*self.Grid_Resolution, \
self.Container.pos.y- Grid_Y*self.Grid_Resolution, \
self.Container.pos.z- Grid_Z*self.Grid_Resolution,)
self.Container.pos -= Move_Pos
self.picked = False
def delete(self):
for thing in self.ObjectList:
thing.visible = False
class Refrigerator(Furniture):
def __init__(self, Room, Width=1.63, Length=1.83, Height=2.75, Position = [0,1,0]):
fridgedata = materials.loadTGA("fridge")
fridgetex = materials.texture(data = fridgedata, mapping="sign")
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Body = box(axis=(0,1,0), pos = (self.Pos), size = (self.Length, self. Width, self.Height),
material = fridgetex, color = (.05, .05, .05), frame = self.Container)
self.ObjectList = [self.Body]
class Bed(Furniture):
def __init__(self, Room, Width=3.17,Length=7.17, Height=2.83, Material=materials.wood, Back_Height=3, Wood_Thickness=.18, Mattress_Thickness = 8./12, Position = [], Leg_Radius = 0.5,\
Wood_Color = (1,.9,.5), Sheet_Color = (255, 255, 255)):
Furniture.__init__(self, Room,Width, Length, Height, Position)
self.Mattress_Thickness = Mattress_Thickness
self.Back_Height = Back_Height
self.Sheet_Color = Sheet_Color
self.Wood_Thickness = Wood_Thickness
self.Wood_Color = Wood_Color
self.Material=Material
self.Mattress = box(pos = (self.Pos), size = (self.Width, self.Length, self.Mattress_Thickness), \
color = self.Sheet_Color, frame = self.Container)
self.Head_Start = self.Pos+vector(0, self.Length/2.+self.Wood_Thickness/2., self.Back_Height/2.- self.Height)
self.Head_End = self.Pos+vector(0, self.Length/2.-self.Wood_Thickness/2., self.Back_Height/2.- self.Height)
self.Foot_Start = self.Pos+vector(0, -self.Length/2.+self.Wood_Thickness/2., self.Back_Height/2.- self.Height)
self.Foot_End = self.Pos+vector(0, -self.Length/2.-self.Wood_Thickness/2., self.Back_Height/2.- self.Height)
self.Head_Shape = shapes.rectangle(height = self.Back_Height+2*self.Mattress_Thickness, width = self.Width) & \
shapes.circle(radius = self.Back_Height+self.Mattress_Thickness,
pos = (0, -(self.Back_Height+self.Mattress_Thickness)/2.), np = 64)
self.HeadBoard = extrusion(pos = [(self.Head_Start),(self.Head_End)],
shape = self.Head_Shape, frame = self.Container,
color = self.Wood_Color, material = self.Material)
self.FootBoard = extrusion(pos = [(self.Foot_Start),(self.Foot_End)],
shape = self.Head_Shape, frame = self.Container,
color = self.Wood_Color, material = self.Material)
self.BoundingBoxFoot = box(pos = (self.Foot_Start + self.Foot_End)/2.,
size = (self.Width,abs(self.Foot_Start-self.Foot_End),self.Back_Height+2*self.Mattress_Thickness),
visible = False, frame = self.Container)
self.BoundingBoxHead = box(pos = (self.Head_Start + self.Head_End)/2.,
size = (self.Width,abs(self.Head_Start-self.Head_End),self.Back_Height+2*self.Mattress_Thickness),
visible = False, frame = self.Container)
self.ObjectList = [self.Mattress, self.HeadBoard, self.FootBoard,self.BoundingBoxFoot,self.BoundingBoxHead]
class BookShelf(Furniture):
def __init__(self, Room, Width = 2.5, Length=1.25, Height=2.25, Material=materials.earth, Shelf_Number=2, Wood_Thickness = 0.0583,\
Position = [], Wood_Color = (1,.9,.5)):
Furniture.__init__(self, Room, Width, Length, Height, Position)
if Position == []:
self.Pos = vector(0,0,0)
else:
self.Pos = Position
self.Material=Material
self.Wood_Thickness = Wood_Thickness
self.Shelf_Number = Shelf_Number
self.Wood_Color = Wood_Color
self.Back_Pos = self.Pos + vector(0, Length, Height/2.)
self.Backing = box(pos = self.Back_Pos, size = (self.Width,\
self.Wood_Thickness, self.Height), color = self.Wood_Color,\
material = self.Material, frame = self.Container)
self.Left_Pos = self.Pos + vector(Width/2., Length/2., Height/2.)
self.Right_Pos = self.Pos + vector(-Width/2., Length/2., Height/2.)
self.Left_Wall = box(pos = self.Left_Pos, size = (self.Wood_Thickness, \
self.Length, self.Height), color = self.Wood_Color,\
material = self.Material, frame = self.Container)
self.Right_Wall = box(pos = self.Right_Pos, size = (self.Wood_Thickness, \
self.Length, self.Height), color = self.Wood_Color,\
material = self.Material, frame = self.Container)
self.Bottom = box(pos = self.Pos + vector(0, Length/2.,\
0), size = (self.Width, \
self.Length, self.Wood_Thickness*2.5), color = self.Wood_Color,\
material = self.Material, frame = self.Container)
self.ObjectList = [self.Backing, self.Left_Wall, self.Bottom,self.Right_Wall]
self.Shelf_Increment = self.Height/float(self.Shelf_Number)
for step in range(0,Shelf_Number):
self.ObjectList.append(box(pos = self.Pos + vector(0, Length/2.,\
(step+1)*(self.Shelf_Increment)), size = (self.Width, \
self.Length, self.Wood_Thickness*2.5), color = self.Wood_Color,\
material = self.Material, frame = self.Container))
class Closet(BookShelf):
def __init__(self, Room, Width=3, Length=1.85, Height=6.25, Material=materials.wood, Wood_Thickness=.1, Hanger_Height = None, Open = True,
Position = [],Wood_Color = (1,.9,.5), Hanger_Radius = 1./12):
BookShelf.__init__(self, Room, Width, Length, Height, Material, 1, Wood_Thickness,
Position, Wood_Color)
self.Open = Open
self.Material=Material
self.Hanger_Radius = Hanger_Radius
if Hanger_Height == None:
self.Hanger_Height = Height*0.8
else:
self.Hanger_Height = Hanger_Height
self.Top_Pos = vector(0, Length/2., self.Height)
self.Top = box(pos = self.Top_Pos, size = (self.Width, self.Length, self.Wood_Thickness),
color = self.Wood_Color, material = self.Material, frame = self.Container)
if not self.Open:
self.Left_Front_Pos = (self.Width/4., 0, self.Height/2.)
self.Right_Front_Pos = (-self.Width/4., 0, self.Height/2.)
self.Front_Size = (self.Width/2., self.Wood_Thickness, self.Height)
elif self.Open:
self.Left_Front_Pos = (self.Width/2., -self.Width/4., self.Height/2.)
self.Right_Front_Pos = (-self.Width/2., -self.Width/4., self.Height/2.)
self.Front_Size = (self.Wood_Thickness, self.Width/2., self.Height)
self.Left_Front = box(pos= self.Left_Front_Pos, size = self.Front_Size,
color = self.Wood_Color, material = self.Material,
frame = self.Container)
self.Right_Front = box(pos = self.Right_Front_Pos, size= self.Front_Size,
color = self.Wood_Color, material = self.Material,
frame = self.Container)
self.Hanger_Bar = cylinder(pos = (self.Right_Pos.x, self.Right_Pos.y, self.Hanger_Height),\
axis = (self.Width, 0, 0), radius = self.Hanger_Radius, \
color = self.Wood_Color, material = self.Material,
frame = self.Container)
self.Shelf = box(pos = vector(0, Length/2., .9), size = (self.Width, self.Length, self.Wood_Thickness),
color = self.Wood_Color, material = self.Material,
frame = self.Container)
self.ObjectList.append(self.Top)
self.ObjectList.append(self.Shelf)
self.ObjectList.append(self.Left_Front)
self.ObjectList.append(self.Right_Front)
self.ObjectList.append(self.Hanger_Bar)
class Lamp(Furniture):
def __init__(self, Room, Height=5, Material=materials.shiny, Base_Radius=.75, Base_Height=.1, Shade_Max_Radius=.6, Shade_Min_Radius=.2,
Shade_Height=1, Shade_Base=[], Shade_Thickness=0.5/12, Stand_Radius=1./12, Position = []):
Furniture.__init__(self, Room, 1, 1, Height, Position)
self.Base_Radius = Base_Radius
self.Base_Height = Base_Height
self.Shade_Max_Radius = Shade_Max_Radius
self.Shade_Min_Radius = Shade_Min_Radius
self.Stand_Radius = Stand_Radius
self.Shade_Height = Shade_Height
self.Material=Material
if Shade_Base == []:
self.Shade_Base = 0.9 * self.Height
else:
self.Shade_Base = Shade_Base
self.Shade_Thickness = Shade_Thickness
self.Stand = cylinder(pos = self.Pos, axis = (0, 0, -self.Height), radius = self.Stand_Radius,\
material = materials.chrome, frame = self.Container)
self.Shade_Scale = float(self.Shade_Min_Radius)/self.Shade_Max_Radius
self.Shade_Shape = shapes.circle(radius = self.Shade_Max_Radius, np = 50,
thickness = self.Shade_Thickness)
self.shadepos = [(0, 0, self.Shade_Base), (0, 0, self.Shade_Base+self.Shade_Height)]
self.Lamp_Shade = extrusion(pos = self.shadepos, \
shape = self.Shade_Shape, color = (255,0,0), material = self.Material,
scale = [(1.0, 1.0), (self.Shade_Scale, self.Shade_Scale)], frame = self.Container )
self.Light = local_light(pos=(0,0,(2*self.Shade_Base+self.Shade_Scale)/2.), color=(.1,.1,.1),
frame = self.Container)
self.Radius_of_Circle = Base_Height*5. #Radius of the arc to make the cross section, should be
#Calculated in a more rigorous way.
self.Base_Circle = shapes.circle(pos = (-self.Base_Radius/2., -self.Radius_of_Circle + (self.Base_Height/2.)),\
radius = self.Radius_of_Circle, np=60)
self.Base_Rectangle = shapes.rectangle(width = self.Base_Radius, height = self.Base_Height)
self.Base_Shape =self.Base_Circle&self.Base_Rectangle
self.Base = extrusion(pos = paths.circle(up = (0,0,1), radius = self.Base_Radius/2., np = 50),
shape = self.Base_Shape, material = self.Material, frame = self.Container)
self.Shade_Cylinder = cylinder(pos = (0,0,self.Shade_Base), axis = (0,0,self.Shade_Height),
radius = self.Shade_Max_Radius, opacity = 0, frame = self.Container)
self.Base_Cylinder = cylinder(pos = (0,0,0), axis = (0,0, self.Base_Height),
radius = self.Base_Radius, opacity = 0, frame = self.Container)
self.BoundingBoxBase = cylinder(axis = (0,0,self.Base_Height), radius = self.Base_Radius/2.,
pos = (0,0,-self.Base_Height/2.), visible = False, frame = self.Container)
self.ObjectList = [self.Stand, self.Lamp_Shade, self.Base, self.Light, self.Base_Cylinder, self.Shade_Cylinder, self.BoundingBoxBase]
class Handle(Furniture):
#Can only be added to other objects, doesn't really do anything by itself.
#Furniture_Base is the object that this will be added to.
def __init__(self, Room, Furniture_Base, Length=.5, Material=materials.wood, Handle_Orientation = (0,0,1),Clearance = 3./12, Handle_Radius = 0.5/12,
Strut_Radius = 0.5/12, Strut_Orientation = (0,1,0), Position = []):
Furniture.__init__(self, Room, Width, Length, Height, Position)
#TODO fix this class
print type(self.Length)
self.Material=Material
self.Handle_Orientation = Handle_Orientation
self.Strut_Orientation = Strut_Orientation
self.Clearance = Clearance
self.Handle_Radius = Handle_Radius
self.Strut_Radius = Strut_Radius
#I'm not sure why all of these are empty vectors, will ask Diana
self.Clearance_Offset = vector(0,0,0)
self.Strut_Axis = vector(0,0,0)
self.Main_Axis = vector(0,0,0)
self.Handle_Pos = vector(0,0,0)
print type(self.Length)
for i in range(0, 3):
if self.Strut_Orientation[i] != 0:
self.Clearance_Offset[i] = -self.Strut_Orientation[i]*self.Clearance
self.Strut_Axis[i] = self.Strut_Orientation[i]*self.Clearance
if self.Handle_Orientation[i] != 0:
self.Main_Axis[i] = self.Handle_Orientation[i]*self.Length
self.Handle_Pos[i] = (-self.Length/2.*self.Handle_Orientation[i])
self.Handle = cylinder(pos = self.Handle_Pos, axis = self.Main_Axis, radius = self.Handle_Radius,
material = Material, frame = Furniture_Base.Container)
self.Strut1 = cylinder(pos = self.Handle_Pos, axis = self.Strut_Axis, radius = self.Strut_Radius,
material = Material, frame = Furniture_Base.Container)
self.Strut2 = cylinder(pos = self.Handle_Pos + self.Main_Axis, axis = self.Strut_Axis,
radius = self.Strut_Radius, material = Material,
frame = Furniture_Base.Container)
Furniture_Base.ObjectList = [self.Handle, self.Strut1, self.Strut2]
class Desk(Furniture):
def __init__(self, Room, Width = 2.5,Length = 5, Height = 2.5, Material=materials.wood, Wood_Thickness = .1, axis = (0,1,0), Position = [], Leg_Radius = 0.12,\
Wood_Color = (1,.9,.5), Leg_Color = (.8,.8,.8)):
deskdata = materials.loadTGA("desk_front")
desktex = materials.texture(data = deskdata, mapping="sign")
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Material=Material
self.Wood_Thickness = Wood_Thickness
self.Wood_Color = Wood_Color
self.X_Margin = Width/2. #Distance from leg center to edge
self.Y_Margin = Length/10. #Distance from leg center to edge
self.CounterTop = box(pos = (self.Pos), axis = (1,0,0), size = (self.Length, self.Width, self.Wood_Thickness), \
color = self.Wood_Color, material = self.Material, frame = self.Container)
self.DF = .27
self.DeskDrawers = box(pos = (self.Pos + vector(-self.Length*.5+self.Length*self.DF*.5+self.Length*.04,0,-Height/2.)), axis = (0,-1,0), size = (self.Width*.8,self.Length*self.DF,self.Height), \
color = self.Wood_Color, material = desktex, frame = self.Container)
self.Leg_Height = (self.Height - self.Wood_Thickness/2.)
self.Leg_Radius = Leg_Radius
self.Leg = cylinder(pos = (self.Pos + vector(self.Length*.4, 0, 0)), axis = (0,0,-self.Leg_Height),
radius = self.Leg_Radius, color = Leg_Color, frame = self.Container)
self.ObjectList = [self.CounterTop, self.DeskDrawers, self.Leg]
class Poster(Furniture):
def __init__(self, Room, Length, Height, posterstring, Width = 0.01, Position = [.05,.05,5]):
posterdata = materials.loadTGA(posterstring)
postertex = materials.texture(data = posterdata, mapping="sign")
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Sheet = box(axis=(1,0,0), pos = (self.Pos), size = (self.Width, self.Length, self.Height),
material = postertex, color = (1,1,1), frame = self.Container)
self.ObjectList = [self.Sheet]
class Drawers(Furniture):
def __init__(self, Room, Width=1.6, Length = 2.5, Height=2.33, Position = []):
drawersdata = materials.loadTGA("drawers")
drawerstex = materials.texture(data = drawersdata, mapping="sign")
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Body = box(axis=(1,0,0), pos = (self.Pos), size = (self.Width, self.Length, self.Height),
material = drawerstex, color = (1,.83,.38), frame = self.Container)
self.ObjectList = [self.Body]
class Table(Furniture):
def __init__(self, Room, Width=3,Length=3, Height=2.5, Material=materials.blazed, Wood_Thickness=.06, Position = [], Leg_Radius = 0.15,\
Wood_Color = (1,1,1), Leg_Color = (1,0,1)):
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Wood_Thickness = Wood_Thickness
self.X_Margin = Width/10. #Distance from leg center to edge
self.Y_Margin = Length/10. #Distance from leg center to edge
self.Leg_Radius = Leg_Radius
self.Wood_Color = Wood_Color
self.Leg_Color = Leg_Color
self.Material=Material
self.CounterTop = box(pos = (self.Pos), size = (self.Width, self.Length, self.Wood_Thickness), \
color = self.Wood_Color, material = self.Material, frame = self.Container)
#Dimensions for the table legs
self.Leg_Height = (self.Height - self.Wood_Thickness/2.)
# Indicated side for indicated dimension (Left side, X dimension = Left_X
self.Left_X = self.Pos[0] - (self.Width/2.) + self.X_Margin
self.Right_X = self.Pos[0] + (self.Width/2.) - self.X_Margin
self.Top_Y = self.Pos[1] + (self.Length/2.) - self.Y_Margin
self.Bottom_Y = self.Pos[1] - (self.Length/2.) + self.Y_Margin
self.legmaterial = self.Material
self.Leg1 = cylinder(pos = (self.Left_X, self.Top_Y, (self.Pos[2]-(self.Wood_Thickness/2.))), \
axis = (0,0,-self.Leg_Height), radius = self.Leg_Radius, material = self.legmaterial,
color = self.Leg_Color, frame = self.Container)
self.Leg2 = cylinder(pos = (self.Right_X, self.Top_Y, (self.Pos[2]-(self.Wood_Thickness/2.))), \
axis = (0,0,-self.Leg_Height), radius = self.Leg_Radius,
material = self.legmaterial,color = self.Leg_Color, frame = self.Container)
self.Leg3 = cylinder(pos = (self.Left_X, self.Bottom_Y, (self.Pos[2]-(self.Wood_Thickness/2.))), \
axis = (0,0,-self.Leg_Height), radius = self.Leg_Radius,
material = self.legmaterial,color = self.Leg_Color, frame = self.Container)
self.Leg4 = cylinder(pos = (self.Right_X, self.Bottom_Y, (self.Pos[2]-(self.Wood_Thickness/2.))), \
axis = (0,0,-self.Leg_Height), radius = self.Leg_Radius, material = self.legmaterial,
color = self.Leg_Color, frame = self.Container)
self.ObjectList = [self.CounterTop, self.Leg1, self.Leg2, self.Leg3, self.Leg4]
class Chair(Table):
def __init__(self,Room, Width=2, Length=2, Stool_Height=1.8, Material=materials.wood, Back_Height=2, Wood_Thickness=.1, Position = [],):
Table.__init__(self, Room, Width, Length, Stool_Height, Material, Wood_Thickness, Position)
self.Back_Height = Back_Height
self.Seat_Color = (255, 255, 0)
self.Back_Color = (0, 255, 255)
self.Leg_Color = (0, 0, 255)
self.Material=Material
Back_Y = self.Pos[1]+(self.Width/2.)-(self.Wood_Thickness/2.)
Back_Z = self.Pos[2]+(self.Back_Height/2.)+(self.Wood_Thickness/2)
self.Back = box(pos = (self.Pos[0], Back_Y, Back_Z),\
size = (self.Width, self.Wood_Thickness, self.Back_Height), material = self.Material, frame = self.Container)
self.ObjectList = self.ObjectList + [self.Back]
class Microwave(Furniture):
def __init__(self, Room, Length=1.8, Height=1, Width = 1, Position = []):
posterdata = materials.loadTGA("microwave")
postertex = materials.texture(data = posterdata, mapping="sign")
Furniture.__init__(self, Room, Width, Length, Height, Position)
self.Sheet = box(axis=(1,0,0), pos = (self.Pos), size = (self.Width, self.Length, self.Height),
material = postertex, color = (.05,.05,.05), frame = self.Container)
self.ObjectList = [self.Sheet]
class WallLight(Furniture):
def __init__(self, Room, Height = 1, Material=materials.shiny, Radius = .25, Position = []):
Furniture.__init__(self, Room, 1, 1, Height, Position)
self.Height = Height
self.Radius = Radius
self.LightHeight = Height*.9
self.BorderHeight = Height*.08
self.cr = shapes.circle(radius=self.Radius, np=64)
self.hole = Polygon( [(-self.Radius,self.Radius),(self.Radius,self.Radius),(self.Radius,self.Radius/4),(-self.Radius,self.Radius/4.)] )
self.Lamp = extrusion(pos=[(0,0,0),(0,0,self.LightHeight)], shape=self.cr-self.hole, color=(1,1,1),
material = materials.emissive, frame = self.Container)
self.TopBorder = extrusion(pos=[(0,0,self.LightHeight),(0,0,self.LightHeight+self.BorderHeight)], shape=self.cr-self.hole,
color=(0.5, 0.5, 0.5), material = Material, frame = self.Container)
self.BottomBorder = extrusion(pos=[(0,0,0),(0,0,-self.BorderHeight)], shape=self.cr-self.hole, color=(0.5, 0.5, 0.5),
material = Material, frame = self.Container)
self.Light = local_light(pos=(0,0,self.Height/2.), color=(.5,.5,.5),frame = self.Container)
self.Invis_Cylinder = cylinder(pos = (0,0,0), axis = (0,0, self.Height), radius = self.Radius,
opacity = 0.5, frame = self.Container)
self.ObjectList = [self.Light, self.Lamp, self.BottomBorder, self.TopBorder, self.Invis_Cylinder]
class Olin_Chair(Furniture):
def __init__(self, Room, Number_Of_Legs = 5, Starting_Leg_Width = 1.7/12, Ending_Leg_Width = 1.9/12,
Leg_Length = 1., Starting_Leg_Height = 1.4/12, Ending_Leg_Height = 2.2/12, Wheel_Width = 2.1/12,
Wheel_Radius = 1.1/12, Wheel_Margin = 0.25/12, Spindle_Bottom_Height = 5.7/12,
Spindle_Middle_Height = 1.1/12, Spindle_Top_Height = 5.3/12, Spindle_Bottom_Radius =1.4/12,
Spindle_Middle_Radius = 1.1/12, Spindle_Top_Radius = 0.55/12, Arm_Rail_Thickness = 1.5/12,
Arm_Rail_Width = 0.8/12, Arm_Rail_Offset = 2.3/12, Arm_X_Extend = 9./12,
Arm_Curve_Radius = 2./12, Arm_Y_Extend = 7.5/12, Arm_Rest_Width = 3.8/12,
Arm_Rest_Length = 10./12, Arm_Rest_Thickness = 1.2/12, Inner_Seat_Length = 13/12.,
Inner_Seat_Bulge_Length = 3./12, Inner_Seat_Hmax = 3./12, Inner_Seat_Hmin = 2./12,
Inner_Seat_Width= 1., Back_Seat_Height = 16./12, Back_Seat_Thickness = 1.5/12,
Back_Seat_Width = 17./12, Position = []):
Furniture.__init__(self, Room, 1,1,1, Position)
self.Number_Of_Legs = Number_Of_Legs
self.Starting_Leg_Width = Starting_Leg_Width
self.Ending_Leg_Width = Ending_Leg_Width
self.Leg_Length = Leg_Length
self.Starting_Leg_Height = Starting_Leg_Height
self.Ending_Leg_Height = Ending_Leg_Height
self.Wheel_Width = Wheel_Width
self.Wheel_Radius = Wheel_Radius
self.Wheel_Margin = Wheel_Margin
self.Spindle_Bottom_Height = Spindle_Bottom_Height
self.Spindle_Bottom_Radius = Spindle_Bottom_Radius
self.Spindle_Middle_Height = Spindle_Middle_Height
self.Spindle_Middle_Radius = Spindle_Middle_Radius
self.Spindle_Top_Height = Spindle_Top_Height
self.Spindle_Top_Radius = Spindle_Top_Radius
self. Arm_Rail_Thickness = Arm_Rail_Thickness
self.Arm_Rail_Width = Arm_Rail_Width
self.Arm_Rail_Offset = Arm_Rail_Offset
self.Arm_X_Extend = Arm_X_Extend
self.Arm_Curve_Radius = Arm_Curve_Radius
self.Arm_Y_Extend = Arm_Y_Extend
self.Arm_Rest_Width = Arm_Rest_Width
self.Arm_Rest_Length = Arm_Rest_Length
self.Arm_Rest_Thickness = Arm_Rest_Thickness
self.Inner_Seat_Length = Inner_Seat_Length
self.Inner_Seat_Bulge_Length = Inner_Seat_Bulge_Length
self.Inner_Seat_Hmax = Inner_Seat_Hmax
self.Inner_Seat_Hmin = Inner_Seat_Hmin
self.Inner_Seat_Width = Inner_Seat_Width
self.Back_Seat_Height = Back_Seat_Height
self.Back_Seat_Thickness = Back_Seat_Thickness
self.Back_Seat_Width = Back_Seat_Width
self.X_Scale = Ending_Leg_Width/Starting_Leg_Width
self.Y_Scale = Ending_Leg_Height/Starting_Leg_Height
self.Leg_Angle = (2*math.pi)/self.Number_Of_Legs
self.Spindle_Bottom = cylinder(pos = (0,0,0), axis = (0,0,self.Spindle_Bottom_Height),
radius = self.Spindle_Bottom_Radius,
material = materials.plastic,
color = (0.1,0.1,0.1), frame = self.Container)
self.Spindle_Middle = cylinder(pos = (0,0,self.Spindle_Bottom_Height),
axis = (0,0,self.Spindle_Middle_Height),
radius = self.Spindle_Middle_Radius,
material = materials.plastic,
color = (0.1,0.1,0.1), frame = self.Container)
self.Spindle_Top = cylinder(pos = (0,0,self.Spindle_Bottom_Height+self.Spindle_Middle_Height),
axis = (0,0,self.Spindle_Top_Height),
radius = self.Spindle_Top_Radius,
material = materials.chrome,
color = (0.9, 0.9, 0.9), frame = self.Container)
self.Rail_Shape = shapes.ellipse(width = self.Arm_Rail_Width,
height = self.Arm_Rail_Thickness)
self.Rail_Origin = vector(0, -self.Arm_Rail_Offset,
self.Spindle_Bottom_Height+self.Spindle_Middle_Height+
self.Spindle_Top_Height)
self.BoundingBoxBottom = cylinder(axis = (0,0,-2*self.Starting_Leg_Height-self.Wheel_Margin),
radius = self.Leg_Length+self.Wheel_Radius+self.Wheel_Margin,
visible = False)
self.Inner_Seat_Rectangle1 = shapes.rectangle(height = self.Inner_Seat_Length,
width = self.Inner_Seat_Hmin)
self.Inner_Seat_Circle1 = shapes.circle(radius = self.Inner_Seat_Bulge_Length,
pos = ((((self.Inner_Seat_Hmin/2)+(self.Inner_Seat_Hmax-
self.Inner_Seat_Hmin))-
self.Inner_Seat_Bulge_Length),
-((math.sqrt((self.Inner_Seat_Bulge_Length)**2-
(self.Inner_Seat_Hmax-(self.Inner_Seat_Hmin/2))**2
))+(self.Inner_Seat_Length/2))))
self.Inner_Seat_Chopping_Rectangle = shapes.rectangle(pos = (-((self.Inner_Seat_Hmin/2)+
self.Inner_Seat_Length), 0),
height = 2*self.Inner_Seat_Length,
width = 2*self.Inner_Seat_Length)
self.Remainder_Width = ((math.sqrt((self.Inner_Seat_Bulge_Length)**2-
(self.Inner_Seat_Hmax-(self.Inner_Seat_Hmin/2))**2)))
self.Inner_Seat_Rectangle2 = shapes.rectangle(width = (self.Inner_Seat_Hmax-self.Inner_Seat_Hmin),
height = (self.Inner_Seat_Length - self.Remainder_Width),
pos = ((self.Inner_Seat_Hmin/2.)+((self.Inner_Seat_Hmax-self.Inner_Seat_Hmin)/2)
, -(self.Remainder_Width/2.)))
self.Rectangle_Width = (self.Inner_Seat_Hmax-self.Inner_Seat_Hmin)
self.Rectangle_Height = (self.Inner_Seat_Length - self.Remainder_Width)
self.Radius_Numerator = sqrt(self.Rectangle_Width**2+self.Rectangle_Height**2)
self.Big_Circle_Radius = self.Radius_Numerator/(math.cos((math.pi/2)-math.atan(self.Rectangle_Height/
self.Rectangle_Width)))
self.Inner_Seat_Circle2 = shapes.circle(pos = ((self.Big_Circle_Radius),0),
radius = self.Big_Circle_Radius)
self.Inner_Seat_Shape = (((self.Inner_Seat_Rectangle1+self.Inner_Seat_Circle1)-self.Inner_Seat_Chopping_Rectangle)+
self.Inner_Seat_Rectangle2)-self.Inner_Seat_Circle2
self.Cushion_Start = vector(-self.Inner_Seat_Width/2., 0, self.Spindle_Bottom_Height+self.Spindle_Middle_Height+
self.Spindle_Top_Height+self.Inner_Seat_Hmin)
self.Cushion_End = self.Cushion_Start+vector(self.Inner_Seat_Width, 0 ,0)
self.Inner_Seat = extrusion(shape = self.Inner_Seat_Shape, pos = [(self.Cushion_Start), (self.Cushion_End)],
frame = self.Container, material = materials.wood)
self.Back_Shape = shapes.arc(radius = (12*self.Back_Seat_Height/math.pi), angle1 = -(5*math.pi)/8 , angle2 =-math.pi/2,
thickness = self.Back_Seat_Thickness)
self.Spindle_Height = (self.Spindle_Bottom_Height+self.Spindle_Middle_Height+
self.Spindle_Top_Height+self.Inner_Seat_Hmin)
self.Back_Path = [(-self.Back_Seat_Width/2, 13*self.Back_Seat_Height/math.pi, 2.75*self.Spindle_Height ),
(self.Back_Seat_Width/2, 13*self.Back_Seat_Height/math.pi, 2.75*self.Spindle_Height)]
self.Back = extrusion(shape = self.Back_Shape, pos = self.Back_Path, frame = self.Container, material = materials.wood)
self.ObjectList = [self.Spindle_Bottom, self.Spindle_Middle, self.Spindle_Top,self.BoundingBoxBottom,
self.Inner_Seat]
for x in range(0,2):
if x == 0:
multiplier = 1
elif x == 1:
multiplier = -1
self.ObjectList.append(extrusion(pos = [(self.Rail_Origin),
(self.Rail_Origin+(multiplier*self.Arm_X_Extend,0,0))],
shape = self.Rail_Shape,
material = materials.earth,
frame = self.Container))
self.ObjectList.append(cylinder(opacity = 0, pos = self.Rail_Origin,
axis = (multiplier*self.Arm_X_Extend,0,0),
radius = self.Arm_Rail_Width))
Next_Origin = vector((self.Rail_Origin+(multiplier*self.Arm_X_Extend,0,self.Arm_Curve_Radius)))
Curve_Path = paths.arc(pos = Next_Origin, radius = self.Arm_Curve_Radius,
angle1 = (math.pi/2)+(x*(math.pi/2)), angle2 = 0+(x*(math.pi/2)))
self.ObjectList.append(extrusion(pos= Curve_Path, shape = self.Rail_Shape,
frame = self.Container))
Next_Origin = Next_Origin + vector(multiplier*self.Arm_Curve_Radius, 0, 0)
self.ObjectList.append(extrusion(pos = [(Next_Origin), (Next_Origin+vector(0,0,self.Arm_Y_Extend))],
shape = self.Rail_Shape,
frame = self.Container))
Next_Origin = (Next_Origin+vector(0,0,self.Arm_Y_Extend))
self.Arm_Rest_Shape = shapes.ellipse(width = self.Arm_Rest_Width,
height = self. Arm_Rest_Length)
self.ObjectList.append(extrusion(pos = [(Next_Origin), (Next_Origin + vector(0,0, Arm_Rest_Thickness))],
shape = self.Arm_Rest_Shape, frame = self.Container))
Leg_Circle = shapes.circle(radius = self.Starting_Leg_Width/2.)
Leg_Square = shapes.rectangle(width = self.Starting_Leg_Width,
height = self.Starting_Leg_Height)
self.Leg_Shape = Leg_Circle&Leg_Square
for i in range(1, self.Number_Of_Legs+1):
Leg_End_Point = vector(self.Leg_Length*(math.sin(i*self.Leg_Angle)),
self.Leg_Length*(math.cos(i*self.Leg_Angle)),0)
self.ObjectList.append(extrusion(pos = [(0,0,0),
Leg_End_Point],
shape = self.Leg_Shape,
material = materials.rough,
color = (255,0,255),
xscale = [self.X_Scale, 1],
yscale = [self.Y_Scale,1],
frame = self.Container))
self.ObjectList.append(sphere(pos = Leg_End_Point, radius = self.Starting_Leg_Width/2.,
material = materials.rough, color = (255,0,255),
frame = self.Container))
Wheel_Housing_Shape = shapes.arc(radius = (self.Wheel_Radius+ self.Wheel_Margin),
angle1 = 0, angle2 = 2*pi)
Wheel_Offset = vector((self.Wheel_Width/2.)*(math.sin((i*self.Leg_Angle)-(math.pi/2))),
(self.Wheel_Width/2.)*(math.cos((i*self.Leg_Angle)-(math.pi/2))),)
Wheel_Housing_Drop = vector(0,0,-self.Starting_Leg_Height)
Wheel_Drop = vector(0,0,-self.Starting_Leg_Height - self.Wheel_Margin)
self.ObjectList.append(extrusion(pos = [(Leg_End_Point-Wheel_Offset+Wheel_Housing_Drop),
(Leg_End_Point+Wheel_Offset+Wheel_Housing_Drop)],
shape = Wheel_Housing_Shape, frame = self.Container))
self.ObjectList.append(cylinder(pos = (Leg_End_Point-Wheel_Offset+Wheel_Drop-(0.25*Wheel_Offset)),
axis =(2.5*Wheel_Offset),
radius = self.Wheel_Radius+self.Wheel_Margin,
material = materials.wood,
color = (0,0,0), frame = self.Container))
#room1 = LeftDormRoom()
#test1 = Refrigerator(room1)
#test2 = Desk(room1)
#global posterimage
#posterimage = "mhcposter" #right now the choices are mhcposter, metacubeposter and flowerposter
#test3 = Poster(room1, 3, 3)
#test4 = BookShelf(room1)
#test5 = Drawers(room1)
#test6 = Table(room1)
#test7 = Bed(room1)
#test8 = Chair(room1)
#test9 = Microwave(room1)
#test10 = Lamp(room1)
#test11 = Closet(room1)
#test12 = WallLight(room1)
#test13 = Olin_Chair(room1)
#while True:
# rate(20)