|
The following example shows how to perform free-form deformations on a simple face.
|
|
|
Scheme Example
|
|
|
; Make a test face
|
|
(define my_dsmodel ( ds:test-face 6 6 36 36 0))
|
|
;; my_dsmodel
|
|
|
; Show the load and constraints
|
|
( ds:set-draw-state my_dsmodel 1 (+ 4 8))
|
|
;; ()
|
|
|
; Make a spring and add it to the test-face
|
|
(define my_spring (ds:add-spring my_dsmodel 1
|
|
(par-pos 0.5 0.5) (position 10 10 15) 100))
|
|
;; my_spring
|
|
; Solve to see deformation effect
|
|
(ds:solve my_dsmodel)
|
|
;; ()
|
|
|
; Compress the spring and display
|
|
(ds:set-load-gain my_dsmodel my_spring 1000 #t)
|
|
;; 4
|
|
(ds:solve my_dsmodel)
|
|
;; ()
|
|
; The surface should just barely be deformed
|
|
; increasing the spring gain reduces the distance
|
|
; between the spring end points.
|
|
|
; Compress the spring and display
|
|
(ds:set-load-gain my_dsmodel my_spring 10000 #t)
|
|
;; 4
|
|
(ds:solve my_dsmodel)
|
|
;; ()
|
|
|
; Compress the spring and display
|
|
(ds:set-load-gain my_dsmodel my_spring 100000 #t)
|
|
;; 4
|
|
(ds:solve my_dsmodel)
|
|
;; ()
|
|
|
|
; The spring displaces the surface by larger
|
|
; ang larger amounts.
|
|
; Commit the changes back to the model so it can be saved.
|
|
(ds:commit my_dsmodel)
|
|
;; ()
|
|
; Save the results to an output file.
|
|
(part:save "tmpdmod1.sat")
|
|
;; #t
|
|
; When loading this part, the deformed surface can be
|
|
; seen by rendering it or turning on silhouette lines.
|
|
|
|
|
Figure 8-10. Free-Form Deformations on a Face
|