;4.207 assignment final assignment ;malevich's gota type architecton (arxload "geom3d") (command "osnap" "off") (command "ucs" "world") (command "-view" "_swiso") (command "-units" "2" "4" "" "" "" "") (command "-layer" "make" "red" "color" "red" "red" "") (command "-layer" "make" "white" "color" "white" "white" "") ;hat? T blue ;front? T yellow ; F white ;right side? T red ;left side? T green ;;;; Error found by TN and not handled yet is ;;; ("leftover_depth is " 0.0) ; error: divide by zero ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; nt definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;the vertical base piece ;all other elements radiate from this one (nt_def_type "verticalBase" 'verticalBase '( ("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 200) ("height" . 800) ("oldX" . 0) ("oldY" . 0) ("oldZ" . 0) ("front?" . 0) ("hat?" . 0)) ) (nt_add_seed_type "verticalBase") ;add 4 blocks to the vertical base (nt_def_type "verticalBase_subBlock" 'verticalBase_subBlock '(("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 200) ("height" . 400) ("front?" . 0) ("scaleFactor" . 0)) ) ;the type of block added to the verticalBase (nt_def_type "subBlock" 'subBlock '(("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 200) ("height" . 400) ("oldX" . 0) ("oldY" . 0) ("oldZ" . 0) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0)) ) (nt_def_type "sideBlock" 'sideBlock '(("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 300) ("height" . 400) ("oldX" . 0) ("oldY" . 0) ("oldZ" . 0) ("side" . 0) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0) ) ) (nt_def_type "subBlock_with_front" 'subBlock_with_front '( ("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 300) ("height" . 400) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0)) ) (nt_def_type "subBlock_with_right" 'subBlock_with_right '( ("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 300) ("height" . 400) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0)) ) (nt_def_type "subBlock_with_left" 'subBlock_with_left '( ("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 300) ("height" . 400) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0)) ) (nt_def_type "subBlock_with_hat" 'subBlock_with_hat '(("xo" . 0) ("yo" . 0) ("zo" . 0) ("width" . 200) ("depth" . 300) ("height" . 400) ("face" . 0) ("scaleFactor" . 0) ("leftover_width" . 0) ("leftover_depth" . 0) ("leftover_height" . 0) ("front?" . 0) ("side?" . 0) ("hat?" . 0) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; nt transformation definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (nt_def_trans '("verticalBase") "verticalBase_subBlock" 'add_subBlock nil 'replace) (nt_def_trans '("subBlock") "subBlock_with_front" 'add_front_to_subBlock nil 'replace) (nt_def_trans '("subBlock") "subBlock_with_right" 'add_sideBlock_to_subBlock nil 'replace) (nt_def_trans '("subBlock") "subBlock_with_left" 'add_sideBlock_to_subBlock nil 'replace) (nt_def_trans '("subBlock") "subBlock_with_hat" 'add_hat_to_subBlock nil 'replace) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; LISP definitions of pieces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun verticalBase (xo yo zo width depth height oldX oldY oldZ front? hat?) (command "ucs" "world") ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;;; (command "-layer" "make" "white" "color" "white" "white" "") (command "box" (list xo yo zo) "length" width depth height) (entlast) ) (defun subBlock (xo yo zo width depth height oldX oldY oldZ face scaleFactor leftover_width leftover_depth leftover_height front? side? hat?) (print "making the subblock") (print (list "hat" hat?)) ;;;;; tn-fix on 2005-05-12 (command "-layer" "make" "white" "color" "white" "white" "") (command "box" (list xo yo zo) "length" width depth height) ;;;**************** (if (= hat? 2) (command "ucs" "world")) (entlast) ) (defun sideBlock (xo yo zo width depth height oldX oldY oldZ side face scaleFactor leftover_width leftover_depth leftover_height front? side? hat?) (print "making the sideblock") (print (list "hat" hat?)) (command "-layer" "make" "white" "color" "white" "white" "") (command "box" (list xo yo zo) "length" width depth height) (command "ucs" "world") (entlast) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun add_subBlock (vBase_lst trans_lst / xo yo zo width depth height front? c_plist) (command "ucs" "world") (setq vBase_plist (nt_plist (car vBase_lst))) (setq xo (nt_val "xo" vBase_plist)) (setq yo (nt_val "yo" vBase_plist)) (setq zo (nt_val "zo" vBase_plist)) (setq width (nt_val "width" vBase_plist)) (setq height (nt_val "height" vBase_plist)) (setq depth (nt_val "depth" vBase_plist)) (setq front? (nt_val "front?" vBase_plist)) (setq c_plist (list (cons "xo" xo) (cons "yo" yo) (cons "zo" zo) (cons "width" width) (cons "height" height) (cons "depth" depth) (cons "front?" front?) (cons "scaleFactor" 0) ;all pieces can be scaled by same amount if desired, if nil pieces give sizes randomly ;(cons "scaleFactor" (/ (float 7) 10)) ) ) (list c_plist) ) (defun add_front_to_subBlock (s_plist trans_lst / xo yo zo width height depth leftover_width sblock_plist c_list) (command "ucs" "world") (setq sblock_plist (nt_plist (car s_plist))) (cond ((= 0 (nt_val "oldX" sblock_plist)) (setq xo (nt_val "xo" sblock_plist)) (setq yo (nt_val "yo" sblock_plist)) (setq zo (nt_val "zo" sblock_plist)) ) (T (setq xo (nt_val "oldX" sblock_plist)) (setq yo (nt_val "oldY" sblock_plist)) (setq zo (nt_val "oldZ" sblock_plist)) )) (setq width (nt_val "width" sblock_plist)) (setq height (nt_val "height" sblock_plist)) (setq depth (nt_val "depth" sblock_plist)) (setq face (nt_val "face" sblock_plist)) (setq scaleFactor (nt_val "scaleFactor" sblock_plist)) (setq leftover_width (nt_val "leftover_width" sblock_plist)) (setq leftover_depth (nt_val "leftover_depth" sblock_plist)) (setq leftover_height (nt_val "leftover_height" sblock_plist)) (setq front? (nt_val "front?" sblock_plist)) (setq side? (nt_val "side?" sblock_plist)) (setq hat? (nt_val "hat?" sblock_plist)) (if (= hat? 2) (setq hat 0)) (setq c_plist (list (cons "xo" xo) (cons "yo" yo) (cons "zo" zo) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" side?) (cons "hat?" hat?) ) ) (list nil c_plist) ) (defun add_sideBlock_to_subBlock (s_plist trans_lst / xo yo zo width height face depth leftover_width leftover_height sblock_plist c_list) (command "ucs" "world") (setq sblock_plist (nt_plist (car s_plist))) (cond ((= 0 (nt_val "oldX" sblock_plist)) (setq xo (nt_val "xo" sblock_plist)) (setq yo (nt_val "yo" sblock_plist)) (setq zo (nt_val "zo" sblock_plist)) ) (T (setq xo (nt_val "oldX" sblock_plist)) (setq yo (nt_val "oldY" sblock_plist)) (setq zo (nt_val "oldZ" sblock_plist)) )) (setq width (nt_val "width" sblock_plist)) (setq height (nt_val "height" sblock_plist)) (setq depth (nt_val "depth" sblock_plist)) (setq scaleFactor (nt_val "scaleFactor" sblock_plist)) (setq leftover_width (nt_val "leftover_width" sblock_plist)) (setq leftover_depth (nt_val "leftover_depth" sblock_plist)) (setq leftover_height (nt_val "leftover_height" sblock_plist)) (setq face (nt_val "face" sblock_plist)) (setq front? (nt_val "front?" sblock_plist)) (setq side? (nt_val "side?" sblock_plist)) (setq hat? (nt_val "hat?" sblock_plist)) (if (= hat? 2) (setq hat 0)) (setq c_plist (list (cons "xo" xo) (cons "yo" yo) (cons "zo" zo) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" side?) (cons "hat?" hat?) ) ) (list nil c_plist) ) (defun add_hat_to_subBlock (s_plist trans_lst / leftover_width leftover_depth leftover_height xo yo zo width height depth face scaleFactor front? side? hat? c_list) (command "ucs" world) (setq sblock_plist (nt_plist (car s_plist))) (cond ;((= 2 (nt_val "front?" sblock_plist)) ((= 0 (nt_val "oldX" sblock_plist)) (print "first round") (setq xo (nt_val "xo" sblock_plist)) (setq yo (nt_val "yo" sblock_plist)) (setq zo (nt_val "zo" sblock_plist)) ) (T (print "second round") (setq xo (nt_val "oldX" sblock_plist)) (setq yo (nt_val "oldY" sblock_plist)) (setq zo (nt_val "oldZ" sblock_plist)) )) (setq width (nt_val "width" sblock_plist)) (setq height (nt_val "height" sblock_plist)) (setq depth (nt_val "depth" sblock_plist)) (setq face (nt_val "face" sblock_plist)) (setq scaleFactor (nt_val "scaleFactor" sblock_plist)) (setq leftover_width (nt_val "leftover_width" sblock_plist)) (setq leftover_depth (nt_val "leftover_depth" sblock_plist)) (setq leftover_height (nt_val "leftover_height" sblock_plist)) (setq front? (nt_val "front?" sblock_plist)) (setq side? (nt_val "side?" sblock_plist)) (setq hat? (nt_val "hat?" sblock_plist)) (if (= hat? 2) (setq hat 0)) (setq c_plist (list (cons "xo" xo) (cons "yo" yo) (cons "zo" (+ zo height)) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" side?) (cons "hat?" hat?) ) ) (list nil c_plist) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun verticalBase_subBlock (xo yo zo width depth height front? scaleFactor / w h d a b c d h sBlocks new-w new-h new-d replaceBase) (cond ((= 1 front?) (print "verticalBase already has subBlocks") ) ((= 0 scaleFactor) ;figure some important things out...... (setq w1 (- 0 (rand 1 width))) (setq w2 (- 0 (rand 1 width))) (setq w3 (rand 1 width)) (setq w4 (rand 1 width)) (setq d (- 0 (rand 1 depth))) (setq h (rand 1 height)) (setq plist1 (list (cons "xo" (+ xo (- (/ width 2) (/ w1 2)))) ;centered on face of original (cons "yo" yo) (cons "zo" zo) (cons "width" w1) (cons "depth" d) (cons "height" h) (cons "face" 4) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs width) (abs w1)) 2)) (cons "leftover_depth" d) (cons "leftover_height" (- height h)) (cons "front?" 2) (cons "side?" 0) (cons "hat?" 0) ) ) (setq d (rand 1 depth)) (setq h (rand 1 height)) (setq plist2 (list (cons "xo" xo) (cons "yo" (+ (- (/ depth 2) (/ d 2)) yo)) (cons "zo" zo) (cons "width" w2) (cons "depth" d) (cons "height" h) (cons "face" 1) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs depth) (abs d)) 2)) (cons "leftover_depth" d) (cons "leftover_height" (- height h)) (cons "front?" 2) (cons "side?" 0) (cons "hat?" 0) ) ) (setq d (rand 1 depth)) (setq h (rand 1 height)) (setq plist3 (list (cons "xo" (+ (- (/ width 2) (/ w3 2)) xo)) (cons "yo" (+ depth yo)) (cons "zo" zo) (cons "width" w3) (cons "depth" d) (cons "height" h) (cons "face" 2) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs width) (abs w3)) 2)) (cons "leftover_depth" d) (cons "leftover_height" (- height h)) (cons "front?" 2) (cons "side?" 0) (cons "hat?" 0) ) ) (setq d (- 0 (rand 1 depth))) (setq h (rand 1 height)) (setq plist4 (list (cons "xo" (+ width xo)) (cons "yo" (+ yo (- (/ depth 2) (/ d 2)))) (cons "zo" zo) (cons "width" w4) (cons "depth" d) (cons "height" h) (cons "face" 3) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs depth) (abs d)) 2)) ;use if put something on top (cons "leftover_depth" d) ;use if put something on top (cons "leftover_height" (- height h)) (cons "front?" 2) (cons "side?" 0) (cons "hat?" 0) ) ) ) (t (setq w (- 0 (* scaleFactor width))) (setq d (* scaleFactor depth)) (setq h (* scaleFactor height)) (setq plist1 (list (cons "xo" (+ xo (- (/ width 2) (/ w 2)))) ;centered on face of original (cons "yo" yo) (cons "zo" zo) (cons "width" w) (cons "depth" (- 0 (* scaleFactor depth))) (cons "height" h) (cons "face" 4) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (abs (- width w)) 2)) (cons "leftover_height" (- height h)) (cons "front?" 0) ) ) (setq plist2 (list (cons "xo" xo) ;want to center eventually (cons "yo" (+ (- (/ depth 2) (/ d 2)) yo)) (cons "zo" zo) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "face" 1) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (abs (- depth d)) 2)) (cons "leftover_height" (- height h)) (cons "front?" 0) ) ) (setq w (* scaleFactor width)) (setq plist3 (list (cons "xo" (+ (- (/ width 2) (/ w 2)) xo)) (cons "yo" (+ depth yo)) (cons "zo" zo) (cons "width" w) (cons "depth" (* scaleFactor depth)) (cons "height" h) (cons "face" 3) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (abs (- width w)) 2)) (cons "leftover_height" (- height h)) (cons "front?" 0) ) ) (setq d (- 0 (* scaleFactor depth))) (setq plist4 (list (cons "xo" (+ width xo)) ;want to center eventually (cons "yo" (+ yo (- (/ depth 2) (/ d 2)))) (cons "zo" zo) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "face" 2) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (abs (- depth d)) 2)) (cons "leftover_height" (- height h)) (cons "front?" 0) ) ) ) ) ;replace the base so it won't get more subBlocks (setq replaceBase (list "verticalBase" nil (list (cons "xo" xo) (cons "yo" yo) (cons "zo" zo) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "front?" 1) (cons "hat?" 0) ) ) ) (cond ((= 0 front?) (setq c1 (list "subBlock" nil plist1)) (setq c2 (list "subBlock" nil plist2)) (setq c3 (list "subBlock" nil plist3)) (setq c4 (list "subBlock" nil plist4)) (nt_composit (list replaceBase c1 c2 c3 c4)) ) (T (nt_composit (list replaceBase)) ) ) ) (defun subBlock_with_front (xo yo zo width depth height face scaleFactor leftover_width leftover_depth leftover_height front? side? hat? / new_width new_depth old face xoN) (command "ucs" "world") ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;;; (setq width (abs width)) ;cheating time, are we straight off the orig sublock? (if (= 2 front?) (cond ((or (= face 1) (= face 3)) (setq w (abs depth)) (setq depth (abs width)) (setq width w) ) (t (setq width (abs width)) (setq depth (abs depth)) ) ) ) (cond ((= face 1) (print "left face, 1") (command "ucs" "new" "3point" (list (- xo depth) yo zo) (list (- xo depth) (+ width yo) zo) (list (- xo (* 2 depth)) (+ yo width) zo) ) ) ((= face 3) (print "right face, 3") (command "ucs" "new" "3point" (list (+ xo depth) yo zo) (list (+ xo depth) (- yo width) zo) (list (+ xo (* 2 depth)) (- yo width) zo) ) ) ((= face 2) (print "face 2") (command "ucs" "new" "3point" (list xo (+ depth yo) zo) (list (+ xo width) (+ depth yo) zo) (list (+ xo width) (+ yo depth depth) zo) ) ) (t (print "face 4") (command "ucs" "new" "3point" (list xo (- yo depth) zo) (list (- xo width) (- yo depth) zo) (list (- xo width) (- yo (* 2 depth)) zo) ) ) ) (setq old (trans (list 0 0 0) 1 0)) (setq height (abs height)) (cond ((= 1 front?) (print "subBlock already has subBlocks")) ((= 0 leftover_depth) ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;; (print "leftover_depth is zero!!") (getint "pausing!!!!!!!!!!!!!!!") ) ((= 0 scaleFactor) (setq w (rand 1 width)) (print (list "leftover_depth is " leftover_depth)) (setq d (rand 1 leftover_depth)) (if (= w width) (setq xoN 0) (setq xoN (- (/ width 2) (/ (abs w) 2))) ) (setq old (trans (list xoN 0 0) 1 0)) (setq h (rand 1 height)) (print (list "old" old)) (setq plist1 (list (cons "xo" xoN) (cons "yo" 0) (cons "zo" 0) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs width) w) 2)) (cons "leftover_depth" (- leftover_depth d)) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0) ) ) ) (t (setq new_width (fix width)) (setq d (* scaleFactor leftover_depth)) (setq xoN (- (/ new_width 2) (/ (* scaleFactor new_width) 2))) (setq old (trans (list xoN 0 0) 1 0)) (setq plist1 (list (cons "xo" xoN) (cons "yo" 0) (cons "zo" 0) (cons "width" (* scaleFactor width)) (cons "depth" d) (cons "height" (* scaleFactor height)) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- new_width (* scaleFactor new_width)) 2)) (cons "leftover_depth" (- leftover_depth d)) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0) ) ) ) ) ;replace the subBlock so it won't get another front block (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" (- 0 depth)) (cons "zo" 0) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" 1) (cons "side?" side?) (cons "hat?" hat?) ) ) ) (cond ((= 0 leftover_depth) (nt_composit (list replaceSub))) ((or (= 0 front?) (= 2 front?)) (setq c1 (list "subBlock" nil plist1)) (nt_composit (list replaceSub c1))) (T (nt_composit (list replaceSub))) ) ) (defun subBlock_with_right (xo yo zo width depth height face scaleFactor leftover_width leftover_depth leftover_height front? side? hat? / new_width new_depth w) (command "ucs" "world") ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;;; (setq width (abs width)) ;cheating time, are we straight off the orig sublock? (if (= 2 front?) (cond ((or (= face 1) (= face 3)) (setq w (abs depth)) (setq depth (abs width)) (setq width w) ) (t (setq width (abs width)) (setq depth (abs depth)) ) ) ) ;set the ucs (cond ((= face 1) (print "left face, 1") (command "ucs" "new" "3point" (list xo yo zo) (list xo (+ yo depth) zo) (list (- xo width) (+ yo depth) zo) ) (setq new_width (abs width)) (setq new_depth (abs depth)) ) ((= face 3) (print "right face, 3") (command "ucs" "new" "3point" (list xo yo zo) (list xo (- yo depth) zo) (list (+ xo width) (- yo depth) zo) ) (setq new_width (abs width)) (setq new_depth (abs depth)) ) ((= face 2) (print "face 2") (command "ucs" "new" "3point" (list xo yo zo) (list (+ xo width) yo zo) (list (+ xo width) (+ yo depth) zo) ) (setq new_width (abs width)) (setq new_depth (abs depth)) ) (t (command "ucs" "new" "3point" (list xo yo zo) (list (- xo width) yo zo) (list (- xo width) (- yo depth) zo) ) (setq new_width (abs width)) (setq new_depth (abs depth)) ) ) (setq old (trans (list 0 0 0) 1 0)) (cond ;still space to have side piece? ((and (not (< leftover_width 1)) (not (= 1 side?))) (cond ((= 0 scaleFactor) (setq w (rand 1 (fix leftover_width))) (setq d (rand 1 (fix new_depth))) (setq h (rand 1 (fix height))) (setq plist1 (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" (- 0 w)) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "side" 1) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (- leftover_width w)) (cons "leftover_depth" (- (abs new_depth) (abs d))) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0)))) (t (setq w (* scaleFactor leftover_width)) (setq d (* scaleFactor new_depth)) (setq h (* scaleFactor height)) (setq plist1 (list (cons "xo" 0) ;centered on face of original (cons "yo" 0) (cons "zo" 0) (cons "width" (- 0 w)) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "side" 1) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (- leftover_width w)) (cons "leftover_depth" (- (abs new_depth) (abs d))) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0)))) ) (if (= front? 2) (setq f? 0) (setq f? front?)) (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" f?) (cons "side?" 1) (cons "hat?" hat?)))) (setq c1 (list "sideBlock" nil plist1)) (nt_composit (list replaceSub c1)) ) (t (print "no space for sideBlock") (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" 1) (cons "hat?" hat?) ) ) ) (nt_composit (list replaceSub)) ) ) ) (defun subBlock_with_left (xo yo zo width depth height face scaleFactor leftover_width leftover_depth leftover_height front? side? hat? / new_width new_depth w width-x) (command "ucs" "world") ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;;; ;cheating time, are we straight off the orig sublock? (if (= 2 front?) (cond ((or (= face 1) (= face 3)) (setq w (abs depth)) (setq depth (abs width)) (setq width w) ) (t (setq width (abs width)) (setq depth (abs depth)) ) ) ) ;set the ucs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (print (list "look here!!!!!!" xo yo zo width depth front?)) (cond ((= face 1) (print "left face, 1") (setq width-x (abs width)) ;;;;;;;;changed by TN (command "ucs" "new" "3point" (list xo (+ yo width-x) zo) (list xo (+ yo (* 2 width-x)) zo) (list (- xo depth) (+ yo (* 2 width-x)) zo) ) (setq new_width (abs width-x)) (setq new_depth (abs depth)) ) ((= face 3) (print "right face, 3") (setq width-x (abs width)) ;;;;;;;;changed by TN (command "ucs" "new" "3point" (list xo (- yo width-x) zo) (list xo (- yo (* 2 width-x)) zo) (list (+ xo depth) (- yo (* 2 width-x)) zo) ) (setq new_width (abs width-x)) (setq new_depth (abs depth)) ) ((= face 2) (print "face 2") (setq width-x (abs width)) ;;;;;;;;changed by TN (command "ucs" "new" "3point" (list (+ width-x xo) yo zo) (list (+ xo (* 2 width-x)) yo zo) (list (+ xo (* 2 width-x)) (+ yo depth) zo) ) (setq new_width (abs width-x)) (setq new_depth (abs depth)) ) (t (print "face t") (setq width-x (abs width)) ;;;;;;;;changed by TN (command "ucs" "new" "3point" (list (- xo width-x) yo zo) (list (- xo (* 2 width-x)) yo zo) (list (- xo (* 2 width-x)) (- yo depth) zo) ) (setq new_width (abs width)) (setq new_depth (abs depth)) ) ) (setq old (trans (list 0 0 0) 1 0)) (cond ;still space to have side piece? ((and (not (< leftover_width 1)) (not (= 2 side?))) (cond ((= 0 scaleFactor) (setq w (rand 1 (fix (abs leftover_width)))) (setq d (rand 1 (fix new_depth))) (setq h (rand 1 (fix height))) (setq plist1 (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "side" 2) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (- leftover_width w)) (cons "leftover_depth" (- (abs new_depth) (abs d))) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0) ) ) ) (t (setq w (* scaleFactor leftover_width)) (setq d (* scaleFactor new_depth)) (setq h (* scaleFactor height)) (setq plist1 (list (cons "xo" 0) ;centered on face of original (cons "yo" 0) (cons "zo" 0) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "side" 2) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (- leftover_width w)) (cons "leftover_depth" (- (abs new_depth) (abs d))) (cons "leftover_height" (- height h)) (cons "front?" 0) (cons "side?" 0) (cons "hat?" 0) ) ) ) ) (if (= front? 2) (setq f? 0) (setq f? front?)) (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" (- 0 new_width)) (cons "depth" new_depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" f?) (cons "side?" 2) (cons "hat?" hat?) ) ) ) (setq c1 (list "sideBlock" nil plist1)) (nt_composit (list replaceSub c1)) ) (t (print "no space for sideblock (tn-fix)") (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" 0) (cons "width" (- 0 new_width)) (cons "depth" new_depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" zo) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" 2) (cons "hat?" hat?) ) ) ) (nt_composit (list replaceSub)) ) ) ) (defun subBlock_with_hat (xo yo zo width depth height face scaleFactor leftover_width leftover_depth leftover_height front? side? hat? / h d w leftover_depth new_width new_depth old face xoN) (command "ucs" "world") ;;;;;;;;;;;;; tn-fix on 2005-05-12 ;;;;;;;;;;;;;;;;;;;; (print (list "height" height "depth" depth "width" width)) (setq width (abs width)) ; (setq depth (abs depth)) ;cheating time, are we straight off the orig sublock? (if (= 2 front?) (cond ((or (= face 1) (= face 3)) (print "front = 2") (setq w (abs depth)) (setq depth (abs width)) (setq width w) ) (t (print "front = 2") (setq width (abs width)) (setq depth (abs depth)) ) ) ) (print (list "height" height "depth" depth "width" width)) ;set the ucs (cond ((= face 1) (print "left face, 1") (print (list (list xo yo zo) (list xo (+ width yo) zo) (list (- xo depth) (+ yo width) zo))) (command "ucs" "new" "3point" (list xo yo zo) (list xo (+ width yo) zo) (list (- xo depth) (+ yo width) zo) ) ) ((= face 3) (print "right face, 3") (command "ucs" "new" "3point" (list xo yo zo) (list xo (- yo width) zo) (list (+ xo depth) (- yo width) zo) ) ) ((= face 2) (print "face 2") (command "ucs" "new" "3point" (list xo yo zo) (list (+ xo width) yo zo) (list (+ xo width) (+ yo depth) zo) ) ) (t (print "face 4") (command "ucs" "new" "3point" (list xo yo zo) (list (- xo width) yo zo) (list (- xo width) (- yo depth) zo) ) ) ) (setq old (trans (list 0 0 0) 1 0)) (print (list "old" old "xo yo zo" xo yo zo)) (cond ((= 1 hat?) (print "subBlock already has hat") (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" (- 0 height)) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" (- zo height)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" front?) (cons "side?" side?) (cons "hat?" hat?) ) ) ) (nt_composit (list replaceSub)) ) ((not (< leftover_height 1)) (cond ((= 0 scaleFactor) (print "ok") (setq w (rand 1 (fix width))) (setq d (rand 1 (fix depth))) (setq h (rand 1 (fix leftover_height))) (setq xoN (- (/ width 2) (/ w 2))) (setq old (trans (list xoN 0 0) 1 0)) (setq plist1 (list (cons "xo" xoN) (cons "yo" 0) (cons "zo" 0) (cons "width" w) (cons "depth" d) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs width) (abs w)) 2)) (cons "leftover_depth" (- depth d)) (cons "leftover_height" (- leftover_height h)) (cons "front?" 0) (cons "side?" 0) ;trick here, need to call ucs after make hat piece (cons "hat?" 2) ) ) ) (t (setq xoN (- (/ width 2) (/ (* scaleFactor width) 2))) (setq old (trans (list xoN 0 0) 1 0)) (setq h (* scaleFactor leftover_height)) (setq plist1 (list (cons "xo" xoN) ;centered on face of original (cons "yo" 0) (cons "zo" 0) (cons "width" (* scaleFactor width)) (cons "depth" (* scaleFactor depth)) (cons "height" h) (cons "oldX" (nth 0 old)) (cons "oldY" (nth 1 old)) (cons "oldZ" (nth 2 old)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" (/ (- (abs width) (* scaleFactor width)) 2)) (cons "leftover_depth" (- depth (* scaleFactor depth))) (cons "leftover_height" (- leftover_height h)) (cons "front?" 0) (cons "side?" 0) ;trick here, need to call ucs after make hat piece (cons "hat?" 2) ) ) ) ) (if (= front? 2) (setq f? 0) (setq f? front?)) (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" (- 0 height)) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" (- zo height)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" f?) (cons "side?" side?) (cons "hat?" 1) ) ) ) (setq c1 (list "subBlock" nil plist1)) (nt_composit (list replaceSub c1)) ) (t (if (= front? 2) (setq f? 0) (setq f? front?)) (setq replaceSub (list "subBlock" nil (list (cons "xo" 0) (cons "yo" 0) (cons "zo" (- 0 height)) (cons "width" width) (cons "depth" depth) (cons "height" height) (cons "oldX" xo) (cons "oldY" yo) (cons "oldZ" (- zo height)) (cons "face" face) (cons "scaleFactor" scaleFactor) (cons "leftover_width" leftover_width) (cons "leftover_depth" leftover_depth) (cons "leftover_height" leftover_height) (cons "front?" f?) (cons "side?" side?) (cons "hat?" hat?) ) ) ) (nt_composit (list replaceSub)) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;helper functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;random numbers generator from 4.207 website (defun rand16 ( / s ) ; when this is used for the first time, initialize the seed ; from the system clock. (if (null *SeedRand*) (progn (setq s (getvar "date")) (setq *SeedRand* (fix (* 86400 (- s (fix s))))) ) ; progn ) ; if ; To generate a psudo-sandom number sequence ; I use the routine described in Kernighan and Ritchie's ; "C Programming Language" second edition, p46 (setq *SeedRand* (+ (* *SeedRand* 1103515245) 12345)) ; trim off the bits left of the 16th bits (logand (/ *SeedRand* 65536) 32767) ) (defun rand (min max / r16 range quotient remainder result) (setq min (fix min)) (setq max (fix max)) (setq r16 (rand16)) ; random number smaller than 32678 (setq range (+ 1 (- max min))) ; number of integers to be produced (setq quotient (/ r16 range)) ; result in non-neg. integer (setq remainder (- r16 (* quotient range))) (setq result (+ min remainder)) result ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; added by TN for view setup 10.06.2005 (command "vports" "single") (command "vpoint" '(-3 -4 5)) (command "box" (list 36 456 0) (list 672 912 240)) (setq zzzzz (entlast)) (command "zoom" "all") (command "pan" '(0 0 0) '(600 500 0)) (command "vports" 2 "") (command "vpoint" '(0 0 1)) (command "zoom" ".5x") (command "pan" '(0 0 0) '(100 0 0)) (command "erase" zzzzz "") (command "shademode" "2D") (command "cvport" 3) ; hope this number does not change... (command "shademode" "g")