Browse Source

Got simple skeletal animation hooked up

Still a lot more to do, but it's a good checkpoint.

* Rigged monkey for test animation
* Update Ogre for my pull request to fix Release Samples build
* Note that this commit also requires
https://github.com/OGRECave/ogre-next/pull/181 , which fixes animation
in my current setup
pitch-detection
Macoy Madson 10 months ago
parent
commit
586a79f4e2
  1. 2
      .gitignore
  2. 2
      Dependencies/ogre-next
  3. 2
      Dependencies/ogre-next-deps
  4. 25
      src/Ogre.cake
  5. BIN
      test/assets/Monkey.blend
  6. 9
      test/src/VocalGame.cake

2
.gitignore

@ -61,4 +61,6 @@ test/Loader
# These should be stored in assets/, then converted by the build system
test/data/Models/*.mesh.xml
test/data/Models/*.skeleton.xml
test/data/Models/*.skeleton
test/data/Materials/Textures/*.dds

2
Dependencies/ogre-next

@ -1 +1 @@
Subproject commit 12c3b3b50ff970e920a6cf506becf226977992b8
Subproject commit fd1bfe96efd77135c4f10f2bb2af8bc1cbe72b51

2
Dependencies/ogre-next-deps

@ -1 +1 @@
Subproject commit 43363bea749e33b78e5394c92d1fe2ebd2edbceb
Subproject commit 993c8bad1767f2b1613c9c60f3da870f45b60806

25
src/Ogre.cake

@ -14,7 +14,9 @@
"OgreMeshManager2.h"
"OgreRoot.h"
"OgreSceneManager.h"
"OgreWindowEventUtilities.h")
"OgreWindowEventUtilities.h"
"Animation/OgreSkeletonInstance.h"
"Animation/OgreSkeletonAnimation.h")
;; Use Ogre's GLX window
;; TODO: convert these functions to cakelisp eventually
@ -43,7 +45,8 @@
(forward-declare
(namespace Ogre
(class Item)
(class SceneNode)))
(class SceneNode)
(class SkeletonAnimation)))
;; The client of this API should not need access the internals of this structure
(defstruct mesh-handle
@ -52,6 +55,8 @@
(defstruct scene-node
node (* (in Ogre SceneNode)))
(def-type-alias-global OgreAnimationHandle (* (in Ogre SkeletonAnimation)))
;; If you get "cannot find serializer" you need to change which of these functions you use
(defun ogre-load-mesh-from-v1 (name (* (const char)) &return mesh-handle)
(var scene-manager (* (in Ogre SceneManager)) (ogre-get-scene-manager))
@ -124,6 +129,22 @@
(set (field new-scene-node node) scene-node)))
(return new-scene-node))
(defun ogre-attach-animation (mesh mesh-handle
skeleton-name (* (const char))
animation-name (* (const char))
&return OgreAnimationHandle)
(var skeleton (* (in Ogre SkeletonInstance))
(on-call-ptr (field mesh mesh-item) getSkeletonInstance))
(on-call-ptr skeleton addAnimationsFromSkeleton skeleton-name
(in Ogre ResourceGroupManager AUTODETECT_RESOURCE_GROUP_NAME))
(var animation (* (in Ogre SkeletonAnimation))
(on-call-ptr skeleton getAnimation animation-name))
(on-call-ptr animation setEnabled true)
(return animation))
(defun ogre-animation-add-time (animation OgreAnimationHandle delta-time float)
(on-call-ptr animation addTime delta-time))
(defun ogre-node-set-position (node (* scene-node) x float y float z float)
(on-call-ptr (path node > node) setPosition x y z))

BIN
test/assets/Monkey.blend

Binary file not shown.

9
test/src/VocalGame.cake

@ -280,6 +280,7 @@
(var monkey-mesh mesh-handle)
(var monkey-node scene-node)
(var monkey-anim-handle OgreAnimationHandle)
(var g-light-node scene-node)
(var reload-sentinel int 2)
@ -306,8 +307,11 @@
(unless (ogre-initialize-sdl)
(return 1))
(set monkey-mesh (ogre-load-mesh "Suzanne.mesh"))
(set monkey-mesh (ogre-load-mesh "Monkey_Mesh.mesh"))
(set monkey-node (ogre-node-from-item monkey-mesh))
;; TODO: How to change this animation's name?
(set monkey-anim-handle
(ogre-attach-animation monkey-mesh "Monkey_Mesh.skeleton" "my_animation")) ;; Monkey_RaiseChin
(set g-light-node (ogre-create-light))
@ -485,6 +489,8 @@
(vec3-add tracker-position audio-pos)))
(ogre-node-set-position (addr monkey-node) (vec-xyz final-pos))
(ogre-animation-add-time monkey-anim-handle delta-time)
(set last-frame-perf-count (SDL_GetPerformanceCounter))
(unless (ogre-render-frame)
@ -581,7 +587,6 @@
(free (type-cast model-output-dir (* void))))
;; TODO: Convert this to non-sequential to convert in parallel
(scope ;; Textures
(var texture-assets ([] (* (const char))) (array "Monkey_Texture"))
(var texture-process-results (<> std::vector int))

Loading…
Cancel
Save