|
| MAS ETH ARCH/CAAD - 2005/06 - STUDENT PAGES Master of Advanced Studies in Architecture, Specialization in Computer Aided Architectural Design | 065-0005/6 Supervision: Prof. Dr. Ludger Hovestadt, Philipp Schaerer Chair of CAAD, ETH Zurich assignmentpattern > > > sand | waves > > > final solutions 3Dexample Iexample IIexample IIIexample IVlaser cut model of example IVplug-inscriptPROCEDURE SandWaves3D; VAR DistPt1Set, DistPt2Set, DistPt3Set : INTEGER; AreaX1, AreaY1, AreaZ1 : REAL; SizeX, SizeY, SizeZ : REAL; density, intfer : REAL; Disturb1, Disturb2, Disturb3 : BOOLEAN; DistPtX1, DistPtY1, DistPtZ1 : REAL; DistPtX2, DistPtY2, DistPtZ2 : REAL; DistPtX3, DistPtY3, DistPtZ3 : REAL; Stone1Rad, Stone2Rad, Stone3Rad : REAL; Effect1, Effect2, Effect3 : REAL; BorderPoly, Stone1, Stone2, Stone3 : HANDLE; MaxArrayX, MaxArrayY, MaxArrayZ : LONGINT; ArrayPt : DYNARRAY[,] OF POINT3D; i, k, m : INTEGER; XTemp, YTemp, ZTemp, ZTemp1, ZTemp2, ZTemp3 : REAL; dist1, dist2, dist3 : REAL; DistField1, DistField2, DistField3 : REAL; BEGIN {######### SET AREA BY USER #########} AreaX1 := RealDialog('Please define cube to be filled! Set X value of starting point:','0.00'); AreaY1 := RealDialog('Please define cube to be filled! Set Y value of starting point:','0.00'); AreaZ1 := RealDialog('Please define cube to be filled! Set Z value of starting point:','0.00'); SizeX := RealDialog('Please define X-extension!','100.00'); WHILE (SizeX <= 0) DO BEGIN IF (SizeX <= 0) THEN AlrtDialog('Size has to be > 0! Set value again!'); SizeX := RealDialog('Please define X-extension!','100.00'); END; SizeY := RealDialog('Please define Y-extension!','100.00'); WHILE (SizeY <= 0) DO BEGIN IF (SizeY <= 0) THEN AlrtDialog('Size has to be > 0! Set value again!'); SizeY := RealDialog('Please define Y-extension!','100.00'); END; SizeZ := RealDialog('Please define Z-extension!','100.00'); WHILE (SizeZ <= 0) DO BEGIN IF (SizeZ <= 0) THEN AlrtDialog('Size has to be > 0! Set value again!'); SizeZ := RealDialog('Please define Z-extension!','100.00'); END; {######### DRAW BOUNDARY CUBE #########} PenFore(0,0,0); PenSize(35); FillPat(0); BeginXtrd(AreaZ1,AreaZ1 + SizeZ); Rect(AreaX1, AreaY1, AreaX1 + SizeX, AreaY1 + SizeY); EndXtrd; ReDrawAll; {######### SET OTHER PARAMETERS BY USER #########} density := RealDialog('Please choose density: (Values between 1 (dense) and 10 (loose) recommended!)','5'); intfer := RealDialog('Please set interference: (Values between 0 and 1 recommended!)','0.50'); {######### SET DISTURBANCE BALLS BY USER #########} Disturb1 := YNDialog('Do you wish to set disturbance balls?'); PenFore(30000,30000,30000); PenSize(7); FillPat(5); FillFore(0,0,0); FillBack(20000,20000,20000); {### FIRST DISTURBANCE BALL ###} IF Disturb1 = TRUE THEN BEGIN DistPtX1 := RealDialog('Set X value of first disturbance point:','10.00'); WHILE (DistPtX1 < AreaX1) OR (DistPtX1 > (AreaX1 + SizeX)) DO BEGIN IF (DistPtX1 < AreaX1) OR (DistPtX1 > (AreaX1 + SizeX)) THEN AlrtDialog('X value of first disturbance point is not in defined area! Set value again!'); DistPtX1 := RealDialog('Set X value of first disturbance point:','10.00'); END; DistPtY1 := RealDialog('Set Y value of first disturbance point:','10.00'); WHILE (DistPtY1 < AreaY1) OR (DistPtY1 > (AreaY1 + SizeY)) DO BEGIN IF (DistPtY1 < AreaY1) OR (DistPtY1 > (AreaY1 + SizeY)) THEN AlrtDialog('Y value of first disturbance point is not in defined area! Set value again!'); DistPtY1 := RealDialog('Set Y value of first disturbance point:','10.00'); END; DistPtZ1 := RealDialog('Set Z value of first disturbance point:','10.00'); WHILE (DistPtZ1 < AreaZ1) OR (DistPtZ1 > (AreaZ1 + SizeZ)) DO BEGIN IF (DistPtZ1 < AreaZ1) OR (DistPtZ1 > (AreaZ1 + SizeZ)) THEN AlrtDialog('Z value of first disturbance point is not in defined area! Set value again!'); DistPtZ1 := RealDialog('Set Z value of first disturbance point:','10.00'); END; Locus3D(DistPtX1,DistPtY1,DistPtZ1); ReDrawAll; Stone1Rad := RealDialog('Set size of first disturbance ball: (Values between 5 and 20 recommended!)','10.00'); Stone1 := CreateSphere(DistPtX1,DistPtY1,DistPtZ1,Stone1Rad); ReDrawAll; Effect1 := RealDialog('Set shifting effect of first disturbance ball: (Values between 2 and 5 recommended!)','3.00'); Disturb2 := YNDialog('Do you wish to set another disturbance ball?'); END; {### SECOND DISTURBANCE BALL ###} IF Disturb2 = TRUE THEN BEGIN DistPtX2 := RealDialog('Set X value of second disturbance point:','20.00'); WHILE (DistPtX2 < AreaX1) OR (DistPtX2 > (AreaX1 + SizeX)) DO BEGIN IF (DistPtX2 < AreaX1) OR (DistPtX2 > (AreaX1 + SizeX)) THEN AlrtDialog('X value of second disturbance pointis not in defined area! Set value again!'); DistPtX2 := RealDialog('Set X value of second disturbance point:','20.00'); END; DistPtY2 := RealDialog('Set Y value of second disturbance point:','20.00'); WHILE (DistPtY2 < AreaY1) OR (DistPtY2 > (AreaY1 + SizeY)) DO BEGIN IF (DistPtY2 < AreaY1) OR (DistPtY2 > (AreaY1 + SizeY)) THEN AlrtDialog('Y value of second disturbance pointis not in defined area! Set value again!'); DistPtY2 := RealDialog('Set Y value of second disturbance point:','20.00'); END; DistPtZ2 := RealDialog('Set Z value of second disturbance point:','20.00'); WHILE (DistPtZ2 < AreaZ1) OR (DistPtZ2 > (AreaZ1 + SizeZ)) DO BEGIN IF (DistPtZ2 < AreaZ1) OR (DistPtZ2 > (AreaZ1 + SizeZ)) THEN AlrtDialog('Z value of second disturbance point is not in defined area! Set value again!'); DistPtZ2 := RealDialog('Set Z value of second disturbance point:','20.00'); END; Locus3D(DistPtX2,DistPtY2,DistPtZ2); ReDrawAll; Stone2Rad := RealDialog('Set size of second disturbance ball: (Values between 5 and 20 recommended!)','10.00'); Stone2 := CreateSphere(DistPtX2,DistPtY2,DistPtZ2,Stone2Rad); ReDrawAll; Effect2 := RealDialog('Set shifting effect of second disturbance ball: (Values between 2 and 5 recommended!)','3.00'); Disturb3 := YNDialog('Do you wish to set another disturbance ball?'); END; {### THIRD DISTURBANCE BALL ###} IF Disturb3 = TRUE THEN BEGIN DistPtX3 := RealDialog('Set X value of third disturbance point:','30.00'); WHILE (DistPtX3 < AreaX1) OR (DistPtX3 > (AreaX1 + SizeX)) DO BEGIN IF (DistPtX3 < AreaX1) OR (DistPtX3 > (AreaX1 + SizeX)) THEN AlrtDialog('X value of third disturbance point is not in defined area! Set value again!'); DistPtX3 := RealDialog('Set X value of third disturbance point:','30.00'); END; DistPtY3 := RealDialog('Set Y value of third disturbance point:','30.00'); WHILE (DistPtY3 < AreaY1) OR (DistPtY3 > (AreaY1 + SizeY)) DO BEGIN IF (DistPtY3 < AreaY1) OR (DistPtY3 > (AreaY1 + SizeY)) THEN AlrtDialog('Y value of third disturbance point is not in defined area! Set value again!'); DistPtY3 := RealDialog('Set Y value of third disturbance point:','30.00'); END; DistPtZ3 := RealDialog('Set Z value of third disturbance point:','30.00'); WHILE (DistPtZ3 < AreaZ1) OR (DistPtZ3 > (AreaZ1 + SizeZ)) DO BEGIN IF (DistPtZ3 < AreaZ1) OR (DistPtZ3 > (AreaZ1 + SizeZ)) THEN AlrtDialog('Z value of third disturbance point is not in defined area! Set value again!'); DistPtZ3 := RealDialog('Set Z value of third disturbance point:','30.00'); END; Locus3D(DistPtX3,DistPtY3,DistPtZ3); ReDrawAll; Stone3Rad := RealDialog('Set size of third disturbance ball: (Values between 5 and 20 recommended!)','10.00'); Stone3 := CreateSphere(DistPtX3,DistPtY3,DistPtZ3,Stone3Rad); ReDrawAll; Effect3 := RealDialog('Set shifting effect of third disturbance ball: (Values between 2 and 5 recommended!)','3.00'); AlrtDialog('This should be enough - no more disturbance balls!'); END; IF Disturb1 = FALSE THEN AlrtDialog('What a shame! You miss the best part...'); {######### CREATE WAVES #########} {### ALLOCATE DYNARRAY ###} MaxArrayX := Trunc(SizeX / density); MaxArrayY := Trunc(SizeY / density); MaxArrayZ := Trunc(SizeZ / density); ALLOCATE ArrayPt[1..MaxArrayX,1..MaxArrayY]; {### FILL ARRAY WITH 3DPOINTS ###} FOR i := 1 TO MaxArrayZ DO BEGIN FOR k := 1 TO MaxArrayY DO BEGIN PenFore(40000,40000,40000); PenSize(140); FillPat(0); Smooth(2); OpenPoly; BeginPoly3D; FOR m := 1 TO MaxArrayX DO BEGIN XTemp := AreaX1 + (m*density) - (0.5 * density); YTemp := AreaY1 + (k*density) - (0.5 * density); ZTemp := AreaZ1 + (i*density) - (0.5 * density); {### CONSIDER DISTURBANCE POINTS ###} IF Disturb1 = TRUE THEN BEGIN {### DETERMINE DISTANCE TO DISTURBANCE POINT 1 ###} dist1 := sqrt(sqr(DistPtX1 - XTemp) + sqr(DistPtY1 - YTemp) + sqr(DistPtZ1 - ZTemp)); {### SHIFT POINTS OF POLY (DEPENDING ON DISTANCE TO DISTURBANCE POINT) ###} IF dist1 < (Effect1*Stone1Rad) THEN BEGIN DistField1 := Deg2Rad(180 / (Effect1*Stone1Rad / dist1)); IF ZTemp < DistPtZ1 THEN ZTemp1 := ZTemp - (0.55*Stone1Rad * (Cos(DistField1) + 1)); IF ZTemp = DistPtZ1 THEN ZTemp1 := ZTemp - (0.55*Stone1Rad * (Cos(DistField1) + 1)); IF ZTemp > DistPtZ1 THEN ZTemp1 := ZTemp + (0.55*Stone1Rad * (Cos(DistField1) + 1)); END; IF dist1 >= (Effect1*Stone1Rad) THEN ZTemp1 := ZTemp; END; IF Disturb1 = FALSE THEN ZTemp1 := ZTemp; IF Disturb2 = TRUE THEN BEGIN {### DETERMINE DISTANCE TO DISTURBANCE POINT 2 ###} dist2 := sqrt(sqr(DistPtX2 - XTemp) + sqr(DistPtY2 - YTemp) + sqr(DistPtZ2 - ZTemp1)); {### SHIFT POINTS OF POLY (DEPENDING ON DISTANCE TO DISTURBANCE POINT) ###} IF dist2 < (Effect2*Stone2Rad) THEN BEGIN DistField2 := Deg2Rad(180 / (Effect2*Stone2Rad / dist2)); IF ZTemp1 < DistPtZ2 THEN ZTemp2 := ZTemp1 - (0.55*Stone2Rad * (Cos(DistField2) + 1)); IF ZTemp1 = DistPtZ2 THEN ZTemp2 := ZTemp1 - (0.55*Stone2Rad * (Cos(DistField2) + 1)); IF ZTemp1 > DistPtZ2 THEN ZTemp2 := ZTemp1 + (0.55*Stone2Rad * (Cos(DistField2) + 1)); END; IF dist2 >= (Effect2*Stone2Rad) THEN ZTemp2 := ZTemp1; END; IF Disturb2 = FALSE THEN ZTemp2 := ZTemp1; IF Disturb3 = TRUE THEN BEGIN {### DETERMINE DISTANCE TO DISTURBANCE POINT 3 ###} dist3 := sqrt(sqr(DistPtX3 - XTemp) + sqr(DistPtY3 - YTemp) + sqr(DistPtZ3 - ZTemp2)); {### SHIFT POINTS OF POLY (DEPENDING ON DISTANCE TO DISTURBANCE POINT) ###} IF dist3 < (Effect3*Stone3Rad) THEN BEGIN DistField3 := Deg2Rad(180 / (Effect3*Stone3Rad / dist3)); IF ZTemp2 < DistPtZ3 THEN ZTemp3 := ZTemp2 - (0.55*Stone3Rad * (Cos(DistField3) + 1)); IF ZTemp2 = DistPtZ3 THEN ZTemp3 := ZTemp2 - (0.55*Stone3Rad * (Cos(DistField3) + 1)); IF ZTemp2 > DistPtZ3 THEN ZTemp3 := ZTemp2 + (0.55*Stone3Rad * (Cos(DistField3) + 1)); END; IF dist3 >= (Effect3*Stone3Rad) THEN ZTemp3 := ZTemp2; END; IF Disturb3 = FALSE THEN ZTemp3 := ZTemp2; {### GRID OF POINTS TO CREATE "WAVEPOLYS" ###} ArrayPt[m,k].x := XTemp; ArrayPt[m,k].y := YTemp + (intfer * (random-0.5) * density); ArrayPt[m,k].z := ZTemp3 + (intfer * (random-0.5) * density); Add3DPt(ArrayPt[m,k].x, ArrayPt[m,k].y, ArrayPt[m,k].z); END; EndPoly3D; ReDrawAll; END; END; DSelectAll; END; Run(SandWaves3D); -- NDSMartinTann - 03 Nov 2005
|
This website has been archived and is no longer maintained.