-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from kaveh808/Kaveh-devel
Kaveh devel
- Loading branch information
Showing
23 changed files
with
373 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(in-package #:kons-9) | ||
|
||
;;;; animation ================================================================= | ||
|
||
(defclass-kons-9 animation (scene-item) | ||
((shape nil) | ||
(shape-animator nil))) | ||
|
||
(defmethod setup-motion ((anim animation)) | ||
(when (motion anim) | ||
(setup-motion (motion anim)))) | ||
|
||
(defmethod update-motion ((anim animation) parent-absolute-timing) | ||
(when (motion anim) | ||
(update-motion (motion anim) parent-absolute-timing))) | ||
|
||
(defmethod add-animation-to-scene ((anim animation) group motion-group | ||
&key (mode :add-as-instance)) ; :add-as-duplicate | ||
(cond ((eq :add-as-instance mode) | ||
(let* ((instance-shape-group (make-group (list (shape anim)))) | ||
(anim-dup (duplicate (shape-animator anim))) | ||
(instance-motion-group (make-motion-group (list anim-dup)))) | ||
(setf (shape anim-dup) instance-shape-group) | ||
(setf (scene instance-motion-group) (scene anim-dup)) | ||
(add-child group instance-shape-group) | ||
(add-child motion-group instance-motion-group))) | ||
((eq :add-as-duplicate mode) | ||
(error "Not implemented")) | ||
(t | ||
(error "Unknown mode ~a" mode)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(in-package #:kons-9) | ||
|
||
;;; curve class ==================================================== | ||
|
||
;;; this shape is defined by an array of points (vertices) | ||
(defclass curve (point-cloud) | ||
((is-closed-curve? :accessor is-closed-curve? :initarg :is-closed-curve? :initform t))) | ||
|
||
(defun make-curve (points &optional (is-closed-curve? t)) | ||
(make-instance 'curve :points points :is-closed-curve? is-closed-curve?)) | ||
|
||
(defun curve-point-tangent (i points &optional (is-closed? nil)) | ||
(let ((len (length points)) | ||
i1 | ||
i2) | ||
(if (= len 2) | ||
(progn (setf i1 0) | ||
(setf i2 1)) | ||
(cond ((= i 0) (if is-closed? | ||
(progn (setf i1 (1- len)) | ||
(setf i2 1)) | ||
(progn (setf i1 0) | ||
(setf i2 1)))) | ||
((= i (1- len)) (if is-closed? | ||
(progn (setf i1 (- len 2)) | ||
(setf i2 0)) | ||
(progn (setf i1 (- len 3)) | ||
(setf i2 i)))) | ||
(t (progn (setf i1 (1- i)) | ||
(setf i2 (1+ i)))))) | ||
(p-normalize (p- (aref points i2) (aref points i1))))) | ||
|
||
(defun curve-tangents-aux (points &optional (is-closed? nil)) | ||
(let ((tangents (make-array (length points)))) | ||
(doarray (i p points) | ||
(declare (ignore p)) | ||
(setf (aref tangents i) (curve-point-tangent i points is-closed?))) | ||
tangents)) | ||
|
||
(defmethod curve-tangents ((curve curve)) | ||
(curve-tangents-aux (points curve) (is-closed-curve? curve))) | ||
|
||
;;; curve shape functions ---------------------------------------------------- | ||
|
||
(defun make-line-curve (p1 p2 num-segments) | ||
(make-curve (make-line-points p1 p2 num-segments) | ||
nil)) | ||
|
||
(defun make-rectangle-curve (width height &optional (num-segments 1)) | ||
(make-curve (make-rectangle-points width height num-segments))) | ||
|
||
(defun make-square-curve (side &optional (num-segments 1)) | ||
(make-curve (make-rectangle-points side side num-segments))) | ||
|
||
(defun make-circle-curve (diameter num-segments) | ||
(make-curve (make-circle-points diameter num-segments))) | ||
|
||
(defun make-arc-curve (diameter start-angle end-angle num-segments) | ||
(make-curve (make-arc-points diameter start-angle end-angle num-segments) | ||
nil)) | ||
|
||
(defun make-spiral-curve (start-diameter end-diameter length loops num-segments) | ||
(make-curve (make-spiral-points start-diameter end-diameter length loops num-segments) | ||
nil)) | ||
|
||
(defun make-sine-curve-curve (period frequency x-scale y-scale num-segments) | ||
(make-curve (make-sine-curve-points period frequency x-scale y-scale num-segments) | ||
nil)) | ||
|
||
#| | ||
(defun make-3-point-arc (p0 p1 p2 num-segments) | ||
...) | ||
|# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.