From fe296110d3a8ae742859c596a3bc4a4b2d6eba4e Mon Sep 17 00:00:00 2001 From: Kaveh Kardan <103860793+kaveh808@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:20:39 -1000 Subject: [PATCH 1/2] Update demo-isosurface.lisp Minor demo tweaks. --- test/demo-isosurface.lisp | 62 +++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/test/demo-isosurface.lisp b/test/demo-isosurface.lisp index 57e49f7..c4e96b3 100644 --- a/test/demo-isosurface.lisp +++ b/test/demo-isosurface.lisp @@ -218,7 +218,7 @@ Use a polyhedron as a curve source. :update-fn (lambda () (setf (threshold iso) (lerp (tween (current-frame *scene*) 0 60) - 10.0 80.0)) + 10.0 200.0)) (generate-isosurface iso))))) ) @@ -230,26 +230,62 @@ Use a particle system as a curve source. (format t " isosurface 10...~%") (finish-output) (with-clear-scene - (let ((p-sys (make-particle-system-from-point (p! 0 3 0) 10 (p! -.2 -.2 -.2) (p! .2 .2 .2) - 'particle - :update-angle (range-float (/ pi 8) (/ pi 16)) - :life-span 10))) + (let ((p-sys (make-particle-system-from-point (p! 0 0 0) 6 (p! -.2 .0 -.0) (p! .2 .0 .0) + 'dynamic-particle + :spawn-angle (range-float 10.0 5.0) + :update-angle (range-float 10.0 5.0) + :life-span 10 + :force-fields (list (make-instance 'constant-force-field + :force-vector (p! 0 .02 0)))))) ;; add particle system to scene as both a shape and a motion (add-shape *scene* p-sys) (add-motion *scene* p-sys) ;;; run animation - (update-scene *scene* 15) + (update-scene *scene* 30) ;;; create field and isosurface from particle paths (curves) (let* ((field (apply-field-function (make-scalar-field 40 40 40 - :bounds-lo (p! -3 0 -3) - :bounds-hi (p! 3 6 3)) + :bounds-lo (p! -7 -1 -7) + :bounds-hi (p! 7 11 7)) (curve-source-field-fn p-sys - (one-over-r-squared-value-fn 1.0 1.2)))) - (iso (generate-isosurface (make-instance 'isosurface :field field :threshold 100.0)))) + (one-over-r-squared-value-fn 1.0 1.0)))) + (iso (generate-isosurface (make-instance 'isosurface :field field :threshold 70.0)))) (add-shape *scene* iso)))) #| -(Demo 11 isosurface) signed distance functions ================================= +(Demo 11 isosurface) dynamic particle system with an attractor force field ======= + +Use a particle system as a curve source. +|# + +(format t " isosurface 11...~%") (finish-output) + +(with-clear-scene + (let ((p-sys (make-particle-system-from-point-source + (make-circle-curve 4 8) + nil +;; (lambda (v) (p:scale (p:normalize (p+ v (p-rand))) 0.4)) + 'dynamic-particle + :life-span -1 ;infinite life-span + :do-collisions? nil + :force-fields (list (make-instance 'attractor-force-field + :location (p! 0 0 0) + :magnitude 1.2))))) + (add-shape *scene* p-sys) + (add-motion *scene* p-sys) + ;;; run animation + (update-scene *scene* 60) + ;;; create field and isosurface from particle paths (curves) + (let* ((field (apply-field-function (make-scalar-field 40 40 40 + :bounds-lo (p! -15 -15 -8) + :bounds-hi (p! 15 15 8)) + (curve-source-field-fn p-sys + (one-over-r-squared-value-fn 1.0 1.0)))) + (iso (generate-isosurface (make-instance 'isosurface :field field :threshold 4.0)))) + (add-shape *scene* iso) + ))) + +#| +(Demo 12 isosurface) signed distance functions ================================= Use signed distance functions with APPLY-FIELD-FUNCTION to set the values of a SCALAR-FIELD. @@ -289,7 +325,7 @@ Comment in the desired function. ) #| -(Demo 12 isosurface) voxel grid ================================================ +(Demo 13 isosurface) voxel grid ================================================ Visualize an ISOSURFACE as a VOXEL-GRID-SHAPE. Note the isosurface does not need to be generated. @@ -305,7 +341,7 @@ need to be generated. ) #| -(Demo 13 isosurface) voxel grid, animating isosurface threshold ================ +(Demo 14 isosurface) voxel grid, animating isosurface threshold ================ Animate the threshold value of the ISOSURFACE and visualize as a VOXEL-GRID-SHAPE. Note the isosurface does not need to be generated. From 5efb243529e1da95eb54f1f5055bec4c8744b102 Mon Sep 17 00:00:00 2001 From: Kaveh Kardan <103860793+kaveh808@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:42:00 -1000 Subject: [PATCH 2/2] Fixed black uv-mesh bug Default point-colors was being set to black. --- src/plugins/uv-mesh.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/uv-mesh.lisp b/src/plugins/uv-mesh.lisp index 14aafa7..24e28de 100644 --- a/src/plugins/uv-mesh.lisp +++ b/src/plugins/uv-mesh.lisp @@ -65,7 +65,7 @@ (compute-polyhedron-mesh mesh) (compute-face-normals mesh) (compute-point-normals mesh) - (allocate-point-colors mesh) + (allocate-point-colors mesh (c! 1 1 1)) mesh) ;; (defun 2d-array-to-list (array)