Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Is there a better/cleaner way to handle Mob model animations?
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
gummby8

Is there a better/cleaner way to handle Mob model animations?

By gummby8, October 20, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted October 20, 2017 (edited)

In the continued pursuit to become a better programer, this is half a question about knowing more about fancy tricks in java and half pertaining to Forge / MC

 

I have mob models that perform animations based on their AI. I use a sort of keyframe system to determine the position and rotation of the model parts. 

 

Since there is only 1 model for every instance of that monster, if I ever move a part in one animation, I have to specify how that part moves in every animation for that monster.

 

So now I have to specify an array of "KeyFrame" objects for each part. and then specify the position and rotation for each KeyFrame in the array

 

So for instance, If I have the head of the mob move during an animation it goes as follows

 

	static final KeyFrame[] KF_Howl_HEAD = new KeyFrame[4];

	//KeyFrame(int frame, float posX, float posY, float posZ, float rotX, float rotY, float rotZ)
    
	public void build_howl() {
    	KF_Howl_HEAD[0] = new KeyFrame(0, 0, 3, -45, -10, 0, 0);
    	KF_Howl_HEAD[1] = new KeyFrame(5, 0, 3, -45, -40, 0, 0);
    	KF_Howl_HEAD[2] = new KeyFrame(35, 0, 3, -45, -40, 0, 0);
    	KF_Howl_HEAD[3] = new KeyFrame(45, 0, 3, -45, -10, 0, 0);
	}

    public void howl(int frame, float partialTick){
    	ModelUtils.moveParts(frame, HEAD, KF_Howl_HEAD, partialTick);
	}

 

Now that is just to move the head. To have 1 animation that moves a dozen parts, it gets a pretty bulky initializing KeyFrame arrays for each part, for each animation and then building out each individual keyframe based on position and rotation.

Here is a model with 5 animations that ends up with more than 1000 lines of code

https://github.com/gummby8/ModularBosses/blob/104602a9d162ee8a14414be61f8ba3d46aee006b/main/java/com/Splosions/ModularBosses/client/models/entity/ModelGolem.javaL279

 

My question is, is this the cleanest way of doing this, or is there a more advanced/better way?

 

Thank you,

 

 

Edited October 20, 2017 by gummby8
  • Quote

Share this post


Link to post
Share on other sites

jabelar    591

jabelar

jabelar    591

  • Reality Controller
  • jabelar
  • Members
  • 591
  • 3266 posts
Posted October 20, 2017

I'm a big fan of keyframe method. That is basically the way movie animators have always done complex animations. I see a lot of people trying to use math because vanilla models use it, but that only works because the vanilla models are very simple (whole arm one block, etc.) and cyclical unrealistic movement is accepted.

 

I have a tutorial on complex entity animations and it is similar idea to yours (I use arrays for my keyframes). You might want to check out my tutorial here: http://jabelarminecraft.blogspot.com/p/introduction-first-of-all-to-understand.html

 

The most important thing is to make sure you have the child parent relationships set up properly. Then you can combine motions easily.

 

The only improvement I made was that you can also implement a "tweening" system. In other words, you can specify that you want to move between two key frames over a certain number of ticks, and the in-between angles are calculated for you. It is really easy to do this linearly (just divide the difference by number of ticks) but it can look a bit robotic so for even more realistic movement you can add some other tweening math to smooth out the transitions (basically a Bezier type fit).

 

If you perfect the tweening system, you can usually define complex animations with just a handful of key frames.

 

In the end though animation is painstaking work -- even the movie folks have to move each joint, each facial expression to really get it the way they want. At some point you simply have to define all the angles and positions and an array is as simple as it gets for that.

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • kdcswag
      Can't download forge (AdBlock Problem)

      By kdcswag · Posted 1 hour ago

      Are you even trying to fix the issue?
    • DaemonUmbra
      [solved]

      By DaemonUmbra · Posted 1 hour ago

      For future reference: 1.7.10 is no longer supported on this forum due to its age. Update to a modern version of Minecraft to receive support.
    • OdachiPlayz
      [solved]

      By OdachiPlayz · Posted 2 hours ago

      I DONT KNOW HOW TO DELETE THIS POST BUT IM DUMB AND SOLVED THE ISSUE MYSELF ADMINS PLEASE DELETE  
    • KingMax
      Endsieg WW2 - Server due to start very soon - Working guns and vehicles!

      By KingMax · Posted 2 hours ago

      Greetings Comrade/Captain/Hauptmann! Welcome to Europe's final theater of war, Scandinavia! Despite the fall of Berlin the third Reich continues to hold out in Norway and the surrounding areas, the war is not yet over. Ultimate Victory will require many more battles to be fought. Infrastructure will need to be built, tanks, planes and ships shall have to be designed and produced and factories will be needed to produce the weapons of war.Endsieg has a multitude of special mechanics found on almost no other MC servers: fully functional ground, air and sea vehicles, guns, factories and more!Will you fight for the Allies to liberate Norway from tyranny?Will you defend the Soviet motherland by finally defeating the fascist menace?Will you take up the mantle of saving the remains of the Third Reich?Will you preserve the territorial integrity of the Republic of Finland?Will you help the Kingdom of Sweden once again rise to prominence as a Baltic powerhouse?Due to launch in a short matter of days or weeks, join our discord!discord.gg/anp3BJQ
    • Crack3dC0d3
      [1.14.4] Multiple models on the same item.

      By Crack3dC0d3 · Posted 2 hours ago

      bump
  • Topics

    • kdcswag
      9
      Can't download forge (AdBlock Problem)

      By kdcswag
      Started December 1

    • OdachiPlayz
      1
      [solved]

      By OdachiPlayz
      Started 2 hours ago

    • KingMax
      0
      Endsieg WW2 - Server due to start very soon - Working guns and vehicles!

      By KingMax
      Started 2 hours ago

    • Crack3dC0d3
      4
      [1.14.4] Multiple models on the same item.

      By Crack3dC0d3
      Started December 2

    • snivinia
      2
      unable to connect to friend's modded server

      By snivinia
      Started 20 hours ago

  • Who's Online (See full list)

    • saxon564
    • coolsim
    • snivinia
    • CelloKit
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Is there a better/cleaner way to handle Mob model animations?
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community