Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorials:advanced:cram-rigid-body [2022/07/11 13:05] – created vanessatutorials:advanced:cram-rigid-body [2022/07/11 13:16] (current) – small rigid-body update vanessa
Line 1: Line 1:
 ====== Adding a new rigid body to the world====== ====== Adding a new rigid body to the world======
  
-In cram/cram_3d_world/cram_bullet_reasoning/src/objects.lisp  +**In cram/cram_3d_world/cram_bullet_reasoning/src/objects.lisp:** 
- +               
-```lisp+<code lisp>
 (defmethod add-object ((world bt-world) (type (eql :liquid-minor)) name pose (defmethod add-object ((world bt-world) (type (eql :liquid-minor)) name pose
-                       &key (mass 0.00001) (radius 0.01) color) +                       &key (mass 0.00001) (radius 0.01) color)       
-  ;; (let ((compound-shape (make-instance 'compound-shape))) +                       
-  ;;   (dotimes (i 8) +
-  ;;     (add-child-shape +
-  ;;      compound-shape +
-  ;;       (cl-transforms:make-pose +
-  ;;         (cl-transforms:make-3d-vector 0 0 0) +
-  ;;         (cl-transforms:make-quaternion 0 0 0 1)) +
-  ;;        (make-instance 'colored-sphere-shape +
-  ;;                                    :radius radius :color '(1 0 0 0.5)))) +
-           +
-    ;; ;; Adds the basket to the specified world +
-    ;;   (make-item world name (list type) +
-    ;;              (list +
-    ;;               (make-instance 'rigid-body +
-    ;;                 :name name :mass mass :pose (ensure-pose pose) +
-    ;;                 :collision-shape compound-shape))))) +
-        +
   (make-item world name (list type)   (make-item world name (list type)
               (list               (list
                 (make-instance                 (make-instance
                     'rigid-body                     'rigid-body
-                  :name 'waterdrop1 :mass 0.00000000001 :pose (ensure-pose pose)+                  :name 'waterdrop :mass mass :pose (ensure-pose pose)
                   :collision-shape (make-instance 'colored-sphere-shape                   :collision-shape (make-instance 'colored-sphere-shape
                                      :radius radius :color color))                                      :radius radius :color color))
                 )))                 )))
-                ```+ 
 + 
 +</code> 
 +The type of this rigid body should be associated with liquid-minor, change this to your liking. 
 +The name should also be different in this example it is waterdrop. 
 +The collision shape is important for the whole shape of the new body. You can choose between the following: 
 +  
 +<code lisp> 
 +(defclass colored-cylinder-shape (cylinder-shape colored-shape-mixin) ()) 
 +(defclass colored-static-plane-shape (static-plane-shape colored-shape-mixin) ()) 
 +(defclass colored-sphere-shape (sphere-shape colored-shape-mixin) ()) 
 +(defclass colored-cone-shape (cone-shape colored-shape-mixin) ()) 
 +(defclass colored-compound-shape (compound-shape colored-shape-mixin) ()) 
 +(defclass colored-convex-hull-shape (convex-hull-shape colored-shape-mixin) ()) 
 +</code> 
 + 
 +Now you can spawn the rigid body as a new object in the bullet world via: 
 + 
 +<code lisp> 
 +(btr::add-object btr:*current-bullet-world* :liquid-minor name pose :color '(0 1 0 0.5)) 
 + </code>