Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

3 years ago
  1. package wow.doge.mygame
  2. import org.scalatest.funsuite.AnyFunSuite
  3. import com.jme3.anim.AnimClip
  4. import wow.doge.mygame.implicits._
  5. import wow.doge.mygame.utils.wrappers.jme.AssetManager
  6. import com.jme3.asset.DesktopAssetManager
  7. import com.jme3.scene.Spatial
  8. import monix.bio.UIO
  9. import scala.concurrent.duration._
  10. import com.jme3.scene.Node
  11. import com.jme3.anim.AnimComposer
  12. import com.jme3.anim.SkinningControl
  13. import com.jme3.anim.tween.action.BaseAction
  14. import com.jme3.anim.tween.Tweens
  15. import scala.jdk.javaapi.CollectionConverters._
  16. import com.jme3.anim.tween.Tween
  17. import com.jme3.anim.tween.action.ClipAction
  18. import cats.syntax.all._
  19. class AnimTest extends AnyFunSuite {
  20. import monix.execution.Scheduler.Implicits.global
  21. val assetManager = new AssetManager(new DesktopAssetManager(true))
  22. test("test 1") {
  23. println((for {
  24. _ <- UIO.unit
  25. model <- assetManager.loadModelAs[Node](
  26. os.rel / "Models" / "Oto" / "Oto.mesh.xml"
  27. )
  28. animcontrol <- UIO(model.getControlMaybe(classOf[AnimComposer]))
  29. skinningcontrol <- UIO(model.getControlMaybe(classOf[SkinningControl]))
  30. _ <- UIO(println(animcontrol))
  31. _ <- UIO(println(skinningcontrol))
  32. _ <- UIO {
  33. animcontrol.map { ac =>
  34. // ac.actionSequence()
  35. // ac.makeAction()
  36. // new BaseAction(Tweens.sequence())
  37. // ac.getAnimClips().a
  38. Option(ac.getAnimClip("hmm"))
  39. .map(clip => new ClipAction(clip))
  40. .map(Tweens.sequence(_))
  41. .foreach { t =>
  42. val actions = new BaseAction(t)
  43. ac.addAction("hmm", actions)
  44. }
  45. val names = List("Walk", "Jump")
  46. for {
  47. clips <- names.traverse(name =>
  48. Option(ac.getAnimClip(name)).map(clip => new ClipAction(clip))
  49. )
  50. tween <- Tweens.sequence(clips: _*).some
  51. actions <- new BaseAction(tween).some
  52. _ <- ac.addAction("Sequence 1", actions).some
  53. } yield ()
  54. ()
  55. }
  56. }
  57. } yield model).attempt.runSyncUnsafe(10.seconds))
  58. }
  59. }