Shop Forum More Submit  Join Login
About Deviant Core Member Cary SemarMale/United States Group :iconthemoviesgroup: TheMoviesGroup
 
Recent Activity
Deviant for 4 Years
3 Month Core Membership
Statistics 107 Deviations 195 Comments 3,269 Pageviews

Favourites

No Favourites yet.

Groups

Activity


If you want to modify an animation and create a new animation, one of the first things you need to do is select a "target file" to import into blender and edit to create the desired animation.   There are thousands of files to choose from and it might be helpful if you could preview a candidate before choosing it.  That is what "animation analyzer" is for.  It doesn't work for all files, but it does work for an awful lot of them.   If you would like to try this tool, you can download the blend from my dropbox that is all set up, but  you will need to customize it a little bit before you run it.

It shouldn't be hard.  When you open the blend, you will see three different 3d views on the left where the animation will play.  On the lower right is a text window with the animation analyzer script.  To use it on your system, you will need to set the path variables for you mesh files and animation files.  These variables are defined on lines 16 and 17.

16: mesh_files = 'path to your game mesh files'  
17: anm_files = 'path to your game anm files'

Change what is there match your configuration, save the blend, and you are good to go.

Not all meshes or prop types are supported, but it is easy to extend.  To add a prop, goto line 49, add a comma, and on the next line add the prop group name (e.g. gun_ca_) and corresponding mesh name for that prop (e.g. 'p_gun_ak47.msh') following the format of the lines above.  The last entry should not have a comma at the end, to satisfy python's syntax.

Warning:  If the animation is very long, it can take quite awhile to load.  After viewing one animation, you can restart the script and load another, but eventually may experience a blender crash.  Every time you run the program, it clears memory by creating a new scene and deleting the old scene.  This frees up some memory, but there is a lot of garbage hanging around that could cause you to run out of memory.  I worked on the problem and at this point I have been able to run the script 10 times in a row without crashing, but I do not know what the limit is. 

If it does crash, just reload the blend and keep going.

Here is an example of the script in action:

Note:  This script requires the modular version of msh_import to be placed in the blender scripts folder and if you do not have it you can download the latest tm_gui package at lefty2000.com/TheMoviesGame and extract it from the zip.



While going through the animation files, I ran across an armature with 7 bones which is required for the animation file called "actor_check_lines.anm" and requires the mesh "p_script.msh."  Although this animation appears in the game,  while an actor is waiting on the set, it is not required in the production movies.  Still, it might prove useful to someone creating a new scene and a new animation, so I have added support for this bone animated prop to the bonelist module.  You can download this updated script at the link.   To get this version, follow the link and in the aside headed "Latest Downloads," right click on the link "bonelist.py (3/16/2019)" and save the python file in your blender scripts folder.  This will allow you to load animation files which require this prop.

Also, I have uploaded patches for the standalone module anm_import.py, which is used by tm_gui, and I have updated the importanm(6.1).py which is the stand alone version of the import anm script.  This patch adds a Blender.Scene.GetCurrent().update() to fix the problem with props not moving when you first import an animation with static animations.  To get these updates, redownload the impexpanm6.1.zip file, extract anm_import.py and importanm(6.1).py from the package, and place them in your blender scripts folder.

I have added a new category in aside called "Resources" where I will post helpful information.  Currently, one item is listed which is a catalog of all the animation files in the game with useful information about the animation.  I find it useful to consult this list before attempting to load an unfamiliar animation because it tells you how many armatures are needed and what kind of props are required.  Only the basic anm files from the PAK are included in this list.

Please let me know if you have any problems accessing these downloads, installing them,or using them.

Thanks,
Lefty


If you have used any of the anm import scripts published so far, you may have noticed that when a prop animation is imported, the prop will not move when you play the scene.
You have to do something weird like save and reload the file, or you can delete something from the scene in the outliner.  I found the solution to this problem is to add a line to the python import_anm script to force an update to the scene.

To fix this problem in the import anm scripts, add the following to the code just before the script exits:
  Blender.Scene.GetCurrent().update()

This will cause the current scene to update and the props will move okay.  I will fix this in future updates to the animation import scripts.
I ran into a snag developing the FLM file loader related to the limitations of the existing anm_import script.  One problem was animation files that contain more than one animation. I didn't see a way to make sure the right animation data was going to the right actor.  So I decided to focus on the problem of animation files with more than one animation.  These files are like little scenes in themselves and the old animation import scripts did not know how to use the origin and destination data.

The animation header contains a matrix that defines the "origin" of the animation and that matrix represents the origin of the first bone animation in the file, with respect to the external world.  If there is a second animation, there will be a second origin matrix, but this matrix is defined with respect to the first origin, not with respect to the external world.  So, you can get the orientation and location of the first bone animation from the first origin matrix (call it O1), but if there is a second origin (O2), the orientation of the second bone animation in world space is give by: O2*O1.

O1 and O2 are 4x4 matrices.  The first 3 rows and columns give the rotation matrix for an object and the first 3 elements of the bottom row give the location of the object.  The last column contains 3 zeros and a 1.  The nice thing about this way of representing position and orientation is that you can multiply them together to compute the effect of a series of rotations and translations.  And the great thing about Blender Python is that it has math utilities to perform all these operations (most of them anyway).

The third piece of information in the anm file that I had not been using is the "destination" data.  The destination data is a position and an angle.  The angle is a rotation about the Z axis.  This allows the animator to apply a smooth linear movement to his animation as it plays.  You can use this information to construct a 4x4 matrix (call it D for destination) which describes the orientation and position of the animation at the last frame relative to it's position in the first frame.

So, if the first animated object is at O1 in frame 1, and the destination is D1, then the final orientation and position is give by D1*O1.  On the other hand, the second animation starts at O2*O1 and ends at D2*O2*O1.  At least, that is the way I think it works.

In order to test this theory, I wrote a script to load the file wes_horse_rider_mount.anm.  You start the script with an empty scene and it loads all the data into memory.  If there bone_count is 30, it imports woody and applies the bone animation data to woody's armature.  If the bone_count is 59, it imports a horse mesh and applies the bone animation data to its armature.  Woody is the first character to be loaded, so the origin data (O1) applied to the container empty (00.woody) and a key frame is set in frame 1.  The destination matrix (D1) is then constructed and the product D1*O1 is applied to the container empty at the end frame of the animation and a keyframe is set there.
The horse animation comes second, so the container empty for the horse (00.horse) is positioned to O2*O1 in frame 1 and key framed, and at the endframe it is positioned to D2*O2*O1 and key framed.  The interpolation mode is set to linear for all Ipos in the scene, to insure linear interpolation between the first and last keyframes.

Here is a video showing the results of a test run using the wes_horse_rider_mount animation file.



In order to make the behavior of animation import and export consistent between anmexport vers 6.1 (What You See is What you Get) and TMBlender GUI 4.1, I have updated the download package for  TM Gui 4.1.  The only change to this package is that the modules anm_import and anm_export have been replaced.  If you are currently using TM Gui 4.1, you do not need to install the entire package; all you have to do is extract the files anm_import.py and anm_export.py and drop them into the Blender Scripts folder.  The effect is to disable the control2_arm_l and control2_arm_r  location channels on import and export because the script does not handle them properly.

You can download the new package at Lefty's Movies Game Blog where you will find it listed in the side bar under "Latest Downloads."  Or you can just use this link: TM Blender GUI 4.1.

If the message: "TM GUI Ver. 4.1" appears in the gui window, you have the latest version of the GUI, notwithstanding the comments in the code itself, but you will still need to replace the anm_import and anm_export modules to have the most current version.

If you are now ready to install the TMBlender GUI for the first time, you are to be commended for your wisdom and patience, and if you have any difficulty, feel free to post any questions here or send them to me via personal message. 

Quotes:
Hippocrates: "Life is short,the art long, opportunity fleeting, experience treacherous, judgment difficult."

Alan Greenspan: "If I have made myself clear, then I have misspoke."

If you want to modify an animation and create a new animation, one of the first things you need to do is select a "target file" to import into blender and edit to create the desired animation.   There are thousands of files to choose from and it might be helpful if you could preview a candidate before choosing it.  That is what "animation analyzer" is for.  It doesn't work for all files, but it does work for an awful lot of them.   If you would like to try this tool, you can download the blend from my dropbox that is all set up, but  you will need to customize it a little bit before you run it.

It shouldn't be hard.  When you open the blend, you will see three different 3d views on the left where the animation will play.  On the lower right is a text window with the animation analyzer script.  To use it on your system, you will need to set the path variables for you mesh files and animation files.  These variables are defined on lines 16 and 17.

16: mesh_files = 'path to your game mesh files'  
17: anm_files = 'path to your game anm files'

Change what is there match your configuration, save the blend, and you are good to go.

Not all meshes or prop types are supported, but it is easy to extend.  To add a prop, goto line 49, add a comma, and on the next line add the prop group name (e.g. gun_ca_) and corresponding mesh name for that prop (e.g. 'p_gun_ak47.msh') following the format of the lines above.  The last entry should not have a comma at the end, to satisfy python's syntax.

Warning:  If the animation is very long, it can take quite awhile to load.  After viewing one animation, you can restart the script and load another, but eventually may experience a blender crash.  Every time you run the program, it clears memory by creating a new scene and deleting the old scene.  This frees up some memory, but there is a lot of garbage hanging around that could cause you to run out of memory.  I worked on the problem and at this point I have been able to run the script 10 times in a row without crashing, but I do not know what the limit is. 

If it does crash, just reload the blend and keep going.

Here is an example of the script in action:

Note:  This script requires the modular version of msh_import to be placed in the blender scripts folder and if you do not have it you can download the latest tm_gui package at lefty2000.com/TheMoviesGame and extract it from the zip.


deviantID

lefty2016's Profile Picture
lefty2016
Cary Semar
United States
Interests

Comments


Add a Comment:
 
:iconbeowulf71:
Beowulf71 Featured By Owner May 7, 2016  Hobbyist
Welcome to the group!
Reply