Outerra forum

Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => Topic started by: andfly on November 28, 2016, 07:19:49 pm

Title: Character Animation
Post by: andfly on November 28, 2016, 07:19:49 pm
Here is a fantastic new possible method of animation in the world Outerra !!!
(  New to me ... probably always existed! )

In all honesty, this discovery, it is not my doing.
Once again I have to thank KW71 (sooner or later I'll have to offer him at least a beer ...)
It was only because of his stubbornness and insistence that I was (almost) forced to perform tests that led me to discover this new method did not think possible!

In his opinion it was possible to animate a character (or a model in general) through moving the bones of her structure , if you use 3DS Max.
I had already tried, years ago (with the Orca), but I had not gotten results: so I had abandoned.
The cause of the failure was the use of software not designed for this purpose: the original Outerra importer from "collada" file and the "Blender" program of building models.

But if you use the Outerra FBX importer  and building the model with 3DS Max: then the file "PKG" contains the definition of the model bones and the connections of bones with assigned vertices.

At this point just set, in the script, the bones as a "joint" and apply the "rotate_joint" method.
The bones will move, and drag the vertices linked, redesigning and "stretching" the meches in the new location without interruption ... as within the 3D drawing program !!

Unfortunately Blender is not able to create a "FBX" file correctly interpretable by the importer of Outerra and it would seem mandatory to use 3DS Max ... but it's not true at all !
If you export your model, from Blender, in "DAE" and becomes "FBX" with an external converter, you can get a "good" file to the FBX importer of Outerra.
And this is a great opportunity because Blender is totally free and 3DS Max instead ...

I sketched in a short time, a model without too many demands for perfection only to concretely illustrate the method discovered.
https://drive.google.com/file/d/0B6114pZ3kPTgaGhVOEdHclNHZ0k/view?usp=sharing

and I made a short video :

https://youtu.be/wQXLVuRMVEY

At this point there are no more excuses ...
I expect, in a short time, an explosion of life in the world of Anteworld !!!
Title: Re: Character Animation
Post by: KW71 on November 28, 2016, 08:31:26 pm
No, no. Thanks for the credits but:

" If you export your model, from Blender, in "DAE" and becomes "FBX" with an external converter"


You found out that, not me...

"In his opinion it was possible to animate a character (or a model in general) through moving the bones of her structure , if you use 3DS Max."

And this are Angrypig's tips & indications

    I'm just a link... you're in one end, and Angrypig in the other, so... Kudos for both of you!    :)
Title: Re: Character Animation
Post by: Acetone on December 01, 2016, 02:42:03 am
Nice work!  :)
Title: Re: Character Animation
Post by: nothinglikethesun on December 01, 2016, 04:44:29 am
Here is a fantastic new possible method of animation in the world Outerra !!!
(  New to me ... probably always existed! )

In all honesty, this discovery, it is not my doing.
Once again I have to thank KW71 (sooner or later I'll have to offer him at least a beer ...)
It was only because of his stubbornness and insistence that I was (almost) forced to perform tests that led me to discover this new method did not think possible!

In his opinion it was possible to animate a character (or a model in general) through moving the bones of her structure , if you use 3DS Max.
I had already tried, years ago (with the Orca), but I had not gotten results: so I had abandoned.
The cause of the failure was the use of software not designed for this purpose: the original Outerra importer from "collada" file and the "Blender" program of building models.

But if you use the Outerra FBX importer  and building the model with 3DS Max: then the file "PKG" contains the definition of the model bones and the connections of bones with assigned vertices.

At this point just set, in the script, the bones as a "joint" and apply the "rotate_joint" method.
The bones will move, and drag the vertices linked, redesigning and "stretching" the meches in the new location without interruption ... as within the 3D drawing program !!

Unfortunately Blender is not able to create a "FBX" file correctly interpretable by the importer of Outerra and it would seem mandatory to use 3DS Max ... but it's not true at all !
If you export your model, from Blender, in "DAE" and becomes "FBX" with an external converter, you can get a "good" file to the FBX importer of Outerra.
And this is a great opportunity because Blender is totally free and 3DS Max instead ...

I sketched in a short time, a model without too many demands for perfection only to concretely illustrate the method discovered.
https://drive.google.com/file/d/0B6114pZ3kPTgaGhVOEdHclNHZ0k/view?usp=sharing

and I made a short video :

https://youtu.be/wQXLVuRMVEY

At this point there are no more excuses ...
I expect, in a short time, an explosion of life in the world of Anteworld !!!

Bravo!!! :-)
Title: Re: Character Animation
Post by: andfly on December 01, 2016, 01:16:59 pm
No, no. Thanks for the credits but: ......

I'm not used to free thanks ...

I confirm!
If it was not for your intuition and your concern, I would never have discovered this method!

But ... maybe I get it ... you do not like beer !!!

 ( This can be remedied in another way ... )

 :) :) :)       :) :) :)
Title: Re: Character Animation
Post by: andfly on December 01, 2016, 01:31:41 pm
Thanks Acetone!  :)

And thanks nothinglikethesun !  :)
Title: Re: Character Animation
Post by: nothinglikethesun on December 13, 2016, 09:59:38 am
:-)
Title: Re: Character Animation
Post by: jonslynn on January 23, 2017, 09:06:08 am
This is very interesting.  At first you make it sound like 3D Max only.  Then perhaps Blender?  But it needs to be a boned character I guess.  I will have to play around with this.

Thanks
Title: Re: Character Animation
Post by: jonslynn on January 23, 2017, 09:55:23 am
Wait?  So a vehicle java script does the animation?  I was confused but still interesting.  Just not the way I would import an fbx animation.  I can wait a few years for that I think.
Title: Re: Character Animation
Post by: andfly on January 25, 2017, 07:33:24 pm
This is very interesting.  At first you make it sound like 3D Max only.  Then perhaps Blender?  But it needs to be a boned character I guess.  I will have to play around with this.
When Developers have published the character of the mercenary (in 2014), exploring the related files folder and seeing a large number of "anim" files, I was convinced that all the movements were created prior in 3DS Max as "animation" and they were reproduced in outerra precisely as "concatenate animations" able to display all the character's situations (walking, running, twisting etc ...).
This belief was reinforced by the fact that, having tried to create a model, complete with armature, I could not move his bones with the usual script commands.
And also from the conviction that it would be burdensome for the computer (and also not easy to accomplish) the fact of writing and place, within Outerra, routines able to recalculate the meches deformed by movements.
Because of this conviction (not being able to create animation and not even knowing the method to reproduce them) in all models I've created so far, I had "cut" and "separate" parts to animate, and I had commanded the movement as you do move one aileron or rudder or a gear, with the difficulty of covering, in some way, the contact points between the various pieces and hide the empty spaces that were highlighted.

The discovery of which I speak in this topic, that is, you can control the movements of the bones, it was a great surprise especially for me!

He also caused a large (and further) sense of admiration for cameni, angrypig & co, for the demonstrated ability to insert these routines into the engine without weighing on performance.

A little difficulties arise from the fact that the "FBX" file must meet stricter standards that (at least in my experience as an amateur) not always Blender is capable of producing.
I do not know, at this point, if it comes from a lack of Blender or my inability to build a model with a "well-made armature", but this can be considered irrelevant because there is a way to make sure that the model is "properly interpreted" for Outerra.
Simply export from Blender in "DAE" or "FBX" and carry out a further conversion with the "Autoesk Official converter in the FBX " ( http://www.softpedia.com/get/Multimedia/Graphic/Image-Convertors/Autodesk-FBX-Converter.shtml ).
After this conversion the "FBX" file is correctly interpreted by Outerra SURELY!

(Or use 3DSMax .... and every problem is already solved immediately)

Wait?  So a vehicle java script does the animation?  I was confused but still interesting.  Just not the way I would import an fbx animation.  I can wait a few years for that I think.
The result is this:
If you build a model that respects the parameters of a "FBX" file as if it were produced by 3DS Max,and it imports it to the FBX importer Outerra, you can control the movements of the bones of his armature (with the commands of the javascript file) getting extremely natural and realistic movements as if it reproduce an animation.
The huge advantage is that by using the script, ANY movement is possible without the requirement to develop a special animation !!!
Title: Re: Character Animation
Post by: jonslynn on January 25, 2017, 08:03:48 pm
That is all nice but I do not know java scripting very well.  Seems like it would take a long time to get anything to work right.  I have not had much spare time to play with Outerra but this really caught my attention.  I don't use Blender much.  I have used 3D Max and the FBX converter way more.  I know the software and get what you are saying but my lack of Java script is a crutch.  Thanks for the reply.
Title: Re: Character Animation
Post by: patmarrnc on November 15, 2017, 02:51:26 pm
wow! thanks for sharing this!  It reinforces my desire to learn more about how to use outerra's power

(is there a tutorial or document that goes into more detail about how to animate imported objects? )
Title: Re: Character Animation
Post by: andfly on November 15, 2017, 06:03:53 pm
It's been a while since I wrote this post and ... something new I've learned!
The most important novelty is that you no longer need to go through Autodesk's FBX converter to get an animated model.
(maybe it was not necessary even before ... but the models I had built, probably because of my inexperience, were not imported correctly by the Outerra FBX importer and the passage through the Autodesk converter was able to fix the errors and produced a file that could be correctly interpreted ...)
However, just export from Blender in FBX format and use the Outerra FBX importer to get a perfectly animated model.
If, then, in the Blender environment, you build an animation, it will be recognized by the importer of Outerra and correctly inserted in the folder of the model files.
(If you use 3DS Max, the result should be even more secure!)

Explaining the  mechanisms capable of moving the meches of a model and its bones is beyond my dialectical skills because I'm not a full time programmer, I might use improper or even incorrect terms: all I know by studying it ( and copying) the javascript files of the users who made their models available before me.
However, is ABSOLUTELY NECESSARY (and is the best tutorial possible) first of all, read the WIKI information in this forum explaining a great deal of the commands that can be used for land, sea or air vehicles.

Use animations created in Blender and import them into Outerra as "anim" files (work done automatically by the Outerra FBX importer) is even easier!
I learned by browsing in the "hero.js" file, which has long been included in the "scripts" folder of the program.
For simplicity, I recommend downloading the Forgotten Island model (https://forum.outerra.com/index.php?topic=3746.0).
Among the animals present in this environment is a "Baby Brachiosaurus".
The javascript file that controls this model, excluding the sound setting, only contains the commands to execute its animation defined in the "Action.anim" file.
You can copy everything by specifying the name of your ".anim" file and you will get a safe working ...

Good work and, above all, good fun!  :)
Title: Re: Character Animation
Post by: patmarrnc on November 20, 2017, 11:33:16 pm
do you (or anyone else) know if FBX animations created in the POSER program would work in the same way?  I ask because my interest in Outerra is related more to animation/film making than it is to gaming.

There is a lot of overlap between 3d animation and gaming, and whether the developers realize it or not, the current state of outerra is very close to being a universal set for animators.

If animators can create characters and movements in other software, then import FBX + ANIM it to Outerra and get it to work in this environment (with reasonable ease defined by a comprehensive set of instructions) I think a whole new demographic would become interested. I also think animators would be willing to pay a lot more than you are currently asking for your alpha license. Just sayin'.

With no changes at all, it is already possible to use green screen footage to merge characters with Outerra backgrounds in a video editor... but there is something to be gained by filming everything in the same 3d environment.

In reading andfly's post it seems that what I want is already possible. The remaining task is to discover how to import and use the animations.

Any help or insights that others may have to offer will be greatly appreciated.
Title: Re: Character Animation
Post by: andfly on November 21, 2017, 12:40:50 pm
I do not know the POSER program, but if the animations are plugged into an FBX file, they should work the same way as if they were built with any other program.
In the Autodesk Converter I was talking about before:
(http://www.softpedia.com/get/Multimedia/Graphic/Image-Convertors/Autodesk-FBX-Converter.shtml)
there is a possibility to use an "FBX Viewer".
Upload the FBX file to this Viewer and try to get it started ...
If it works right away it should be OK for import, otherwise try to use the converter: you should get a working file ...

P.S.
I read the last edit of your speech and ... talk about animation films.
I do not think Outerra is naturally prepared for this purpose.
I managed to import animations of a limited number of frames, (150-200), beyond that number import was not successful ...
I do not know if for my fault or if there is a set limit.
I think Outerra's goal is to have short animations of a character that "concatenate" to see its various actions (running, walking, jumping, twisting, etc.).
By commanding the execution of these animations (appropriately and managed by a program), you should be able to highlight all the possible movements of a character ...
It's just my personal opinion ... I have no official news to confirm or deny it!  :(
Title: Re: Character Animation
Post by: patmarrnc on November 22, 2017, 11:38:20 pm
Thanks Andfly, for sharing the results of your experiments with character animation. Also, thanks for your gracious willingness to help others. I agree that studying existing scripts and props is probably the best way to learn. But I find that there is always a dead end, a missing bit of information that stops  me cold.

For example, in studying the files related to the mercenary... I see all of the anim files, but I don't see any clue about how to activate them.  (update: aha! the scripts are in another folder! OK, one more piece to the puzzle found...)

I just downloaded your dancing girl, your swimming fish, and your island so I can try to understand what you've done in each case. Thanks again for making the results of your labor available to others. You are a good person, and I appreciate that.

Title: Re: Character Animation
Post by: andfly on November 23, 2017, 04:48:31 am
 :) :) :)
Title: Re: Character Animation
Post by: patmarrnc on November 25, 2017, 01:06:47 pm
I found the answer to my own question about Poser:
Yes, when an FBX made in Poser which is saved with animation is imported into Outerra, the .ANIM file is created. Now that I know how to do that much, I will redirect my learning curve to understanding how to call the ANIM files from a script. Fortunately, there are a bunch of scripts to study.

My achilles heel is in having no understanding of javascript at all.  I think once I wrap my brain around the way keystrokes are being collected and processed to call anim files and rotate joints I'll be on my way.  So much to learn, so few brain cells.
Title: Re: Character Animation
Post by: andfly on November 26, 2017, 06:55:56 pm
Some brief clarifications ...

The mercenary's character does not have a script.
I think it's programmed by a code section embedded in the engine.
In fact ... if you define "character" any other model, at the time of "spawn" appears the mercenary in its place!

The "script" folder holds a couple of old files (leftovers of old versions of Outerra) that I believe have been left to cause the curiosity of the modders and concern some untreated topics in the WIKI, including animation.

Unfortunately, there is not a " bunch of scripts to study " that contain  commands to use "anim" files.
For what I know there are only BRACHIOSAURUS AGONY, BABY BRACHIOSAURUS, MEGALODON and ALIEN PALM of the "Forgot Island" package.

Do not confuse Java with Javascript. They are very different things!
Javascript language is very simple, at least for basic use.
With a simple web search you can find a handful of manuals to download for free, even in Pdf.
I learned so!

regards,   ;)
Title: Re: Character Animation
Post by: patmarrnc on November 26, 2017, 07:15:26 pm
thanks for the clarification, Andfly. I appreciate your help.
Title: Re: Character Animation
Post by: fly77 on October 06, 2018, 03:54:30 pm
Interesting. I have tried to use the javascript to control movements of a character and while it works I found it is quite difficult to "mathematically program" complex movements . eg. a character that rides and steers a bicycle by using joint rotations/positioning. I feel moving bones "by hand" to the correct position in blender should be easier. 
So I wondered how can one instead create an animation in blender and then import it into outerra. I tried with a simple blender file ( a cylinder having 3 bones along its axis), creating 3 keyframes in the blender timeline (60 frames long) acting on the bones in pose-mode. Then exporting as fbx and importing into outerra as fbx..however outerra allways crashes and only makes a objectdef and a mtl file, no pkg or animation file. What is the correct procedure ?
below are the blender fbx export settings (default) and the outerra fbx import screen as well as the log file of errors. By the way in blender the rotational transformation coordinates of keyframes are set by default as quaternion WXYZ. Don't know if this has any importance.

Code: [Select]
[1006/224315:INFO:package_explorer.html?name=package%20inspector(379)] File dialog loaded...
21:43:19.808 FATAL: (c4e) [1006/224319:INFO:package_explorer.html?name=package%20inspector(382)] dir: H:/blender-workfolder/, file: test.fbx, path: H:/blender-workfolder/test.fbx
21:43:19.826 INFO: [fbx_importer] Creating FBX importer..
21:43:25.390 FATAL: (c4e) [1006/224325:INFO:package_explorer.html?name=package%20inspector(229)] on_node_selected
21:43:25.390 FATAL: (c4e) [1006/224325:INFO:package_explorer.html?name=package%20inspector(231)] on_node_selected e.ctrlKey = false is_bone = false
21:43:28.253 FATAL: (c4e) [1006/224328:INFO:package_explorer.html?name=package%20inspector(229)] on_node_selected
21:43:28.253 FATAL: (c4e) [1006/224328:INFO:package_explorer.html?name=package%20inspector(231)] on_node_selected e.ctrlKey = false is_bone = false
21:43:43.446 WARNING: Widget "_blank" name already exists! (generating new name"name_003")
21:43:43.499 FATAL: (c4e) [1006/224343:INFO:package_explorer.html?name=package%20inspector(412)] FBX log is loaded...


Title: Re: Character Animation
Post by: patmarrnc on October 06, 2018, 08:03:44 pm
A while ago I made a car with driver and "sort of" animated the driver. To some extent his hands follow the steering wheel when the car turns. Likewise I made a little space ship with pilot and a motorboat with driver, all of which are minimally animated. When I'm at my other computer, I'll put them on dropbox for anybody who wants to see how it works.

I should mention, none of these are Poser animations. I just separated any parts that need to move (like the arms and head) and declared them to be joints during the import process (after the usual positioning of the rotation points in Blender before exporting.) Here is one video  showing how the porsche looks with a driver:

https://www.youtube.com/watch?v=wPOpY0wzB14&t=9s

Update:
here's a link to a dropbox folder that has a few OTX files I used for animations.  Everything here is offered "AS-IS", there are many problems with the models, but for my purpose of using them as props in animation they worked "well enough"
 
https://www.dropbox.com/sh/vm5o2k9ie6fh1bf/AACL15mZ6Pb-D6gd6DMHdHSPa?dl=0

The cartoon copter and space scooter are not programmed to take off from a runway. For my purposes, I just spawned them high in the sky then shot my footage as they glided back to earth.

The boat  worked well in the old Outerra, but after the latest version it tends to rise and fall too much, sometimes coming out of the water and sometimes going under water. I'm not a javascript programmer, I just blindly tweak other people's code until it works or breaks.  This boat is somewhere in between.

The porsche, speedboat, cartoon copter and space scooter all  have a driver who moves his head and arms somewhat when the vehicle turns. Scripts show how that minimal motion was accomplished.   The space scooter also has a very bright single headlight (L toggles off and on) so it can search the terrain for whatever life form the story requires.  Drivers are modelled in the style of characters used in the MUVIZU animation program.

The folder also includes a couple of log cabins, some park signs, a few tents, a picnic pavilion, several crude campers, a picnic table and some other accessories in case anybody wants to create a state park. 


There are also two stone bridges that have collision added so cars can drive across them and boats can go underneath them.  They work pretty well when you place them on a river that is the right width for the bridge.  The trick is to make a smooth transition between the road and the bridge. (otherwise the vehicle will stop when it hits the mismatch between the road and the bridge. )  The road editor can be used to align the height of the road with the height of the bridge.

Title: Re: Character Animation
Post by: fly77 on October 07, 2018, 03:42:07 am
Thanks a lot for the numerous models. A good source of inspiration as well. Your tutorial vidoes are great as they are very basic and getting the basics is the hardest part. I started modelling thanks to your video tutorials in fact. So if you ever find some new stuff to explain in a video I think it will be welcome by everybody. For the animations I have seen the video and the characters in the models. They are quite simple animations indeed. Unfortunately I require a more complex animation for my bicycle driver: feet should follow moving pedals exactly (or allmost) and hands the bike handlebar while steering. I got the pedals allmost right with some sin and cosine functions to calculate the thigh and shin angles in time except that sometimes they go out of sync . Hands following the steering bar is more complicated and I still don't give up but having experienced these difficulties I got interested in pre-baked animations made in blender. as the time evolution of the bones in blender through keyframes also follows some kind of mathematical function of time (e.g. linear variations of positions and rotations between keyframe bone coordinates) I'll try if I can use keyframe coordinate data from blender to define the time evolution of bone joints  in the javascript using some linear interpolation in between. If it works it should be easier to program complex animations using the javascript file but using coordinate info from a blender animation.
Title: Re: Character Animation
Post by: patmarrnc on October 07, 2018, 09:34:31 am
Andfly has shown that is it entirely possible to make complex animations entirely with javascript... but it isn't for the faint of heart.  The upshot of this approach is that it is entirely programmable

The other approach is to create keyframe style animations in another program like poser or blender, then bring the animation into Outerra. But the problem with ANIM file animations is that you would need a separate animation for pedalling, not pedalling, turning to the left, turning to the right, driving straight etc.  I could never solve the problem of swapping between different ANIM files to change the character's actions.  I know it is possible because the army character in Outerra uses a variety of different ANIM files for different actions. I never managed to figure out how the script made a different ANIM file the active animation. My scripts always played the first ANIM then exited the loop.

About a year ago I spent considerable time trying to figure out how to create keyframed animations that worked consistently. At the time I wrote down the steps, because I have a terrible memory.  If I can find my notebook I will post the step by step procedure for creating such animations and importing them into Outerra.  But be aware that what I have learned is not enough to animate a cyclist.  Maybe if some other people start working with keyframe style animations, one of us will crack the code and figure out how to use multiple ANIM files in the same model.
Title: Re: Character Animation
Post by: fly77 on October 07, 2018, 01:47:20 pm
Such a tutorial will be very useful to stimulate us to do more animation for outerra. What i am going to work on is to export only the animation F-curve data from blender and use them in "andfly style" javascript programmed animation. In this way the best of both worlds could be combined.
Title: Re: Character Animation
Post by: patmarrnc on October 07, 2018, 03:18:31 pm
Here are the notes I took when going thru the trial and error procedure of trying to make ANIM files work in Outerra:

1) use a keyframe based animation program to create a simple animation sequence. (I used Poser, but there are many such programs that work basically the same way. DAZ is a free one that also works, and I think Blender works too)

2) Export as DAE. This preserves the animation.

3) At this point you might be able to import directly into Outerra using the Collada importer... but I imported the collada file into Blender then exported as FBX so I could use the FBX importer. I don't remember if I had to declare anything as bones during the import process. I know this is necessary if you plan to rotate bones with JavaScript, but I don't remember doing this with Poser animations.  Such animations might include hundreds of tiny axial motions, and declaring each moving part would be confusing. I'm pretty sure I didn't declare bones. You might have to experiment with both approaches.

4) the ANIM file is created by Outerra during the import process.

5) of course, you need to recreate all of your textures in Outerra's preferred format


here's a link to an OTX of a deer with 3 different ANIM files used, but each one appears in the menu as a separate model. I never could make it programmable so the animations could be changed by keystrokes


https://www.dropbox.com/s/p8jnw7w6haa2vzr/DEER_DAE.patmarrnc.otx?dl=0

script shows how a single ANIM file can be activated. It would be great if somebody with more javascript knowledge could help us to create a way to swap an array of ANIM names in and out of activity programmatically. If we could solve this problem, it would be a breeze to create really complex and programmable animations in Outerra.  Based on the army character, I have to think it is already possible.


Title: Re: Character Animation
Post by: patmarrnc on October 07, 2018, 03:20:08 pm
Such a tutorial will be very useful to stimulate us to do more animation for outerra. What i am going to work on is to export only the animation F-curve data from blender and use them in "andfly style" javascript programmed animation. In this way the best of both worlds could be combined.

please share whatever you discover! What you are doing is very interesting!
Title: Re: Character Animation
Post by: fly77 on October 07, 2018, 06:07:09 pm
OK. For the moment I just now solved the error that outerra gave me when importing a blender animation. Instead of directly exporting the animation through blender as fbx I found that if I export it as collada (.dae) file and then use autodesk fbx converter http://download.autodesk.com/us/fbx/2013/FBXconverter/index.html?url=files/GUID-4EACEBC7-E3C5-491C-B516-54AEEEF08B7A.htm,topicNumber=d30e369 (http://download.autodesk.com/us/fbx/2013/FBXconverter/index.html?url=files/GUID-4EACEBC7-E3C5-491C-B516-54AEEEF08B7A.htm,topicNumber=d30e369) to convert it to fbx then outerra imports correctly the file creating a package .pkg and animation .anim file. Also I can spawn the animation using andfly's Brachio_anim.js script but if I try to add a second .anim file I can spawn either one or the other but I was not able so far to switch between the two as I lack understanding of the animation commands (apparently defined here     https://github.com/Outerra/anteworld/blob/master/include/ot/animation.h            and    here     https://github.com/Outerra/anteworld/blob/master/include/ot/animation_stack.h )
Title: Re: Character Animation
Post by: andfly on October 08, 2018, 12:14:27 pm
I am absolutely convinced that the use of pre-packaged animations in a graphics program (blender or 3ds Max) is much cheaper, in terms of speed of execution, rather than the definition of the bones of a model as a "joint" and the command of their movement with Javascript code.

It seems to me that the animation contains (already calculated) the coordinates in which to show the model's meches and their appearance deformed by the movement, while the movement commands through the script call up routines in order to define the deformation of the meches in real time and therefore require more "work" from the GPU.

But ... getting "beautiful" animations is not as easy as it might seem ...
It is not enough to put one foot after another ... there is a small amount of refinement necessary to create a "realistic" movement that is discovered only when the first tests are started ...
To find out that, in the laboratories of software-house video games, and in film studios, it is preferable to record the movements of real actors in black suit  and white balls in the joints reveals the difficulty of this work.
Of course, our ambitions are amateur, so we suppose we managed to create enough animations for our purpose.
The next step is to import the animation into Outerra.

From my tests I think it is important that the model has a UNIQUE armature and that all the bones have a common origin (and they are all linked together).
It's also important that the animation stays within 200-250 frames (longer animations have always caused me a loading error).
By building the FBX (I have kept the default settings in Blender) you should get a file that can be successfully interpreted by the FBX importer of Outerra.
(An eventual passage in the "Autodesk Fbx Converter" can help).

Browsing through the "hero.js" file (program "script" folder) I learned the commands to insert one or more animations on the Outerra stack and execute them.
A rock that I could not overcome is the possibility to delete the stack to enter a new animation and continue to alternate the animations to get different and appropriate movements.
Perhaps a more in-depth study could solve even if ... at this point ... a little bit of indications from angrypig would definitely be more useful ...

Now, however, I would like to deepen the other animation system that can be used in Outerra: the definition of the bones of an armature as a "joint" and the command of movements using the "rotate_joint" and "move_joint" methods of the geomob.
I consider this system to be hugely broader than the use of pre-constructed animations.
Being amateurs, therefore unrelated to the need for professional speed performance, we can afford to explore the use of this method that offers us the ability to program every type of movement and adapt it to any kind of circumstances!
I imagine a program in which there is a function for each bone to move ... this function limits the movement of the bone within the physiological limits of the joint (as in reality) ... receives incoming values ​​(and is recalled) from the function of movement of the bone on which it depends ... possesses (possibly) a short neural sub-routine that refines, over time, the coefficients of the movement choosing the most efficient ones based on experience ...
All dreams, of course, easy to propose but much less easy to achieve, yet ... full of enormous charm.

But it is precisely the possibility that offers Outerra to be able to achieve something like this and the consideration of being able to "play" with these ideas without the apprehension of having to produce "professional results" that leads me to think that this method of "total programming" it would have to be explored and deepened more in the pre-constructed (more limiting) method of animations.
 ::)
Title: Re: Character Animation
Post by: patmarrnc on October 09, 2018, 09:47:06 am
well said, Andfly! 
Your animations are in a class by themselves! They are neither animation for the sake of a game or for the sake of video recording... your animations are like living art!  I can't even imagine how anyone could do what you have done with Outerra... but you keep doing it over and over!  Thanks for all the help you have freely given to other learners (like me)

As I see it, there are 3 uses for animation in Outerra:
1) The artistic background animations created by Andfly (totally programmed, but not necessarily controlled by the user)
2) Game play animation (totally controlled by key strokes)
3) Video animation (not controllable, but suitable for passing shots of multiple models that can be edited later into the scene you want)

type 3 is easily achieved with ANIM style animation. The magic is in the animation software, so this approach requires the least learning curve. It is also easy to create a separate model for each movement, record snippets of each animation, then assemble many animations into a single scene later in a video editor.  This is basically what I do. I'm not trying to make games or scripts with accurate audio. For my purposes it is much easier to add whatever audio I need in the video editor, where I have total control of it.

type 2 is harder because the user is responsible for creating every aspect of the animation, from model to script. But Most movement boils down to simple motion in one direction or the other... either linear or rotary motion. Once the user understands how to create and control simple movements (like a turning head or moving arm) then it boils down to constraining the movement and making it look more natural.

Type 1... pure magic! I am at a loss for words here, and I'm not the right person to offer an accurate evaluation of the skills required to do what Andfly does. The term "Renaissance Person" comes to mind, as the process is a mixture of art and science

Title: Re: Character Animation
Post by: andfly on October 10, 2018, 11:38:40 am
Well...
I thank you for the compliments even if they are definitely exaggerated.
If you want to see true magic you can re-watch this movie:
https://www.youtube.com/watch?v=PAuB-uomZcE

I certainly did not mean to denigrate or downplay the system of animations built with graphics programs.
They remain a wonderful method and the only one that can be implemented if you want to animate a large number of characters at the same time.
The possibility, then, to record even small clips and connect them in a video editor, makes it an affordable and highly satisfying tool.
The final effects are very pleasant ... and your works prove it.

I was just trying to underline how the direct programming method of movements can open even wider and more exciting perspectives.
It requires a little more of initial effort and a little "struggle" with trigonometry and rotations, but allows the total control of the models under all circumstances.
You can program individual movements, or entire sequences, with maximum freedom of action ...

it's not a small thing.
If we add that the action takes place in a realistic and beautiful environment like the world of Outerra ...
Well ... really 15 dollars well spent !!!    :D :D :D
Title: Re: Character Animation
Post by: patmarrnc on October 10, 2018, 12:54:19 pm
Well...
I thank you for the compliments even if they are definitely exaggerated.
we might have to agree to disagree on whether or not my observations about you are exaggerations.  I stand by my statements


Quote
If you want to see true magic you can re-watch this movie:
https://www.youtube.com/watch?v=PAuB-uomZcE
indeed, this is awesome... and a bit troubling to me, because if it is ever implemented, I'm guessing the stuff I am currently using will go away.  ;-(


Quote
I certainly did not mean to denigrate or downplay the system of animations built with graphics programs.
I didn't take it that way. My intent was to point out that Outerra can be used in more than one way with animation.  I mentioned this distinction because I think there is a tendency for people to get locked into one paradigm,and maybe see Outerra as "only" a game engine, where models have to be totally controllable with a game controller.  I know people who use it in other ways, and I think the user base might grow if the world sees it as a product that might be useful in more than one way.



Quote
I was just trying to underline how the direct programming method of movements can open even wider and more exciting perspectives.
It requires a little more of initial effort and a little "struggle" with trigonometry and rotations, but allows the total control of the models under all circumstances.
You can program individual movements, or entire sequences, with maximum freedom of action ...

it's not a small thing.
If we add that the action takes place in a realistic and beautiful environment like the world of Outerra ...
Well ... really 15 dollars well spent !!!    :D :D :D

indeed! I agree completely!

Title: Re: Character Animation
Post by: fly77 on October 18, 2018, 06:10:28 pm
I've got done my first character animation that  I made in blender of a guy waving his hand. I exported it as dae and then converted to fbx using autodesk fbx converter. Using the autodesk fbx viewer the animation seems fine, same as in blender. I can import it into outerra and run the anim file using the this.geom.animate() command as usual but the character gets totally distorted as soon as it starts to move, besides it being gigantic. (in blender he is just 2 blender units high). Bones in blender are all connected together. Any idea what could cause this problem ?   here is the blender file of the animated character  https://www.dropbox.com/s/638ctyij2k1t10u/PatrickBoned3-hi.blend?dl=0 (https://www.dropbox.com/s/638ctyij2k1t10u/PatrickBoned3-hi.blend?dl=0) and here the texture misisng in the  blend file.  https://www.dropbox.com/s/uezufvm9o2kmoh1/patrik_skin.jpg?dl=0 (https://www.dropbox.com/s/uezufvm9o2kmoh1/patrik_skin.jpg?dl=0)
Title: Re: Character Animation
Post by: patmarrnc on October 18, 2018, 10:55:42 pm
regarding the size: It's my understanding that there isn't a standard for size among modelling programs, so when moving models from one environment to another, you have to use trial and error to get the size right (resizing in Blender then reimporting into Outerra.)  Once you have it sized correctly, you can use the Blender file as a point of reference for sizing other models made in Blender. 

I've even noticed that when a program accepts more than one file format, the exact same model will be sized differently if imported as an OBJ or DAE or FBX. So I keep multiple reference files... one to size static models, and another one to size animated models

Also noticed that the same model will be a different size in Outerra if I use the Autodesk FBX converter to create my FBX, as opposed to exporting directly to FBX from Blender. 

regarding the distortion:
I've noticed similar distortion when exporting animations from DAZ, but I've never seen it in animations created by Poser.
Title: Re: Character Animation
Post by: fly77 on October 19, 2018, 08:53:25 am
Ok for size I can adjust the scale in blender beforehand or during fbx import in outerra. regarding distortions by looking closer using open3mod free model viewer I was able to verify that the animation is still OK after exporting from blender as dae. The problem arises when using autodesk fbx converter. The resulting fbx file viewed in fbx converter seems OK but when viewed in open3mod the fbx animation displays the same distortion issue as in outerra. Seems that fbx converter viewer  is "more tollerant" (or more "intelligent"?) than outerra and open3mod viewer. I'll try to figure out what's the cause.
Title: Re: Character Animation
Post by: KW71 on October 19, 2018, 09:44:14 am
Try exporting from Blender directly to .fbx selecting in "Version:" FBX 7.4 Binary, and controling the scale in the proper tab (usually 1 would work for binary;   for ASCII is 100)
Title: Re: Character Animation
Post by: fly77 on October 19, 2018, 10:51:03 am
That's what i tried initially but did not work as outerra crashes during import. Above is the blender file. Are you able to import blender animations into outerra?
Title: Re: Character Animation
Post by: KW71 on October 21, 2018, 02:44:32 pm
I haven't tried to import animations yet.
Title: Re: Character Animation
Post by: fly77 on October 21, 2018, 04:16:51 pm
in the meantime I also tried to export directly fbx animation files from blender using the 6.1 ASCII export option. While with the 7.4 binary export option I could not get any animation file import in outerra (outerra allways crashes during import) (on the other hand fbx 7.4 binary export works to import fbx of static objects into outerra) with the 6.1 ASCII fbx export I can get the animation loaded into outerra. As with the collada-> fbx-converter path however I get models that are scaled wrongly (now they are really tiny lilliputs as opposed to the giants I still have with the collada) and again i could not solve the character movement distortion issue. It seems to have to do with the way axis orientation are set up and/or exported but while I tried hard a lot of the possible combinations of x,y,z,-x,-y,-z up/down front/back during the fbx eport stage I am not there yet to have a correct animation. Probably I made mistakes as the possible combination of axis orientations and/or model orientations are too many and the most obvious ones do not seem to give good results unfortunately. I'll continue insisting as the distortions seem to have to do with the coordinate frame orientation. On the other hand to fix the scale problem I tried increasing the size of mesh in blender and fit a new skeleton to the upscaled rig. Seems that I can increase somewhat the size of the lilliput but not enough yet. The scale factor setting in both 6.1 fbx ASCII blender export and outerra import do not seem to have any effect..apparently. Lot's of combinations of parameters to try...but I won't give up
Title: Re: Character Animation
Post by: patmarrnc on October 22, 2018, 11:29:34 am
While trying to figure out what works, I tried a bunch of different procedures. It's been a while, so my memory is not clear about what worked and what didn't, but I do remember a couple of things.  Initially I used the Autodesk FBX exporter to create the final FBX. But in the end I was exporting from Blender.

However, I didn't create the animation in Blender (I created it in Poser, exported as DAE, then imported the DAE into Blender, then exported the final result to FBX)

Since you use Blender to create your animation, you might try adding an intermediate step of exporting your animation from Blender to Collada (DAE) to embed the animation into the file. Then import the DAE back into Blender in order to convert it to FBX

Also, take note of the export options. You might have to specify that you want to export animation (both times.. when exporting DAE and again when exporting FBX)

Also make sure to remove any cameras and lights from the model before exporting. I have had Outerra crash when trying to import models that still have lights or cameras embedded.

Title: Re: Character Animation
Post by: fly77 on October 22, 2018, 02:47:27 pm
Wow ! it works now ! Thanks patmarrnc ! It just took me 10 minutes now thanks to your useful suggestions !!...I had lost 3 days in trials before using the DAE and ASCII fbx export changing lots of coordinate system export and model orientations/scaling. For the moment I just used your suggestion to make a blender animation without cameras and lights and tried a "minimalist" fbx 7.4 binary export with the settings  shown in the attached image.  And voilà !  here from dropbox https://www.dropbox.com/s/1p3utoo23umf2ul/Patrick-hellow-world.mp4?dl=0 (https://www.dropbox.com/s/1p3utoo23umf2ul/Patrick-hellow-world.mp4?dl=0)
you have a video of patrick correctly sized by default saying "hello world" !  (the model is patrick downloaded from turbosquid https://www.turbosquid.com/3d-models/human-male-3d-model/504883 (https://www.turbosquid.com/3d-models/human-male-3d-model/504883); the blender simulation is just a rapidly drafted animation, no fancy model orientations..in blender the model stands upright along +z and front points towards the + y direction as this is needed for outerra vehicles.  )


Title: Re: Character Animation
Post by: patmarrnc on October 22, 2018, 03:56:35 pm
so in the end it was just the lights and cameras? That's good to know. It's easy for me to become "supertitious", carefully following every step in a procedure that worked, even though all of the steps in that procedure may not have contributed to the success.
Title: Re: Character Animation
Post by: fly77 on October 22, 2018, 08:19:54 pm
Finally I "cracked" the problem of activating different "pre-baked" animation files (.anim files) from within the javascript of outerra models, thanks to this outerra github webpage https://github.com/Outerra/anteworld/wiki/Animation-API
 (https://github.com/Outerra/anteworld/wiki/Animation-API)

It was then only a matter of adapting this to launch multiple animated actions. Below are the essential statements to be included in the javascript file.

As an example I used several test animation files that I had made in blender and imported into outerra (see above discussion...many thanks again to patmarrnc!! for speeding up this achievement).

I was able to activate them from within the javascript of a character using as a control variable the speed of the character motion (he is configured as a vehicle,using transparent/invisible wheels as for my bicycle).

It turned out that the animations could fit more or less to a character that does ice-skating (without skates so far !) by using a bad "walk-cycle" - good however for ice-skating !

Since I discovered this solution just few days ago I have not had the time yet to set up a better animation for demonstration. I am just beginning to learn blender in general and animating characters in particular.

Here is the otx file of the animated character for download from dropbox https://www.dropbox.com/s/92rmeqpr3ozkzm8/Patrick1.otx?dl=0 (https://www.dropbox.com/s/92rmeqpr3ozkzm8/Patrick1.otx?dl=0)
The blender file of the model can be downloaded from here https://www.turbosquid.com/3d-models/human-male-3d-model/504883 (https://www.turbosquid.com/3d-models/human-male-3d-model/504883)

He will appear as a vehicle "PatrickBoned3-hi" in the outerra menu. As usual for vehicles use "w" for moving forward, "s" for breaking, "a" and "d" for moving left and right. By using "v" you can switch between different camera views among which notably a "fly-by" mode that I developed (still to be optimized but promising). Also using the "+" and "-" on the numeric keyboard zoom in and out.

Enjoy ! and BUILD ON IT !

Here is a video of some action recorded on ice !

 https://vimeo.com/296526957 (https://vimeo.com/296526957)

Below are the essential javascript statements to activate different animations (.anim files) depending on a control variable. I chose the "h" key (horn action of vehicles) to switch between two different animations. By the way, by changing the speed3 and the limits for kmh for switching between different actions you can also make him walk normally instead of skating.

So now with these simple commands it becomes possible for us to develop animated characters performing many different complex actions either through keyboard control or controlled by in-game algoritms implemented in the model javascript (maybe walking, climbing, swimming, etc... automatically depending on the terrain properties).

Together with andfly's great approach we have now two ways to make complex programmable animations inside outerra !

There is really no more excuse now not to develop lots of animated characters for outerra ! Or allmost. The only limitation that I still see is that in any case so far we are limited to modify characters treated as vehicles so they will not be able to move as freely as we wish. The "real animated character" (with total freedom in all regards) as the outerra mercenary is defined as object with physics="character" not physics="vehicle" but for me at least it is unclear how and where the physics of the mercenary is defined and how we could mod it.

Code: [Select]
var _animation1,_animation2;

var flag=0;
var sincro=0;
var speed1=1;  //any positive float value
var speed2=1;  //any positive float value

//invoked only the first time the model is loaded, or upon reload
function init_chassis(){
...

   _act_horn = this.register_event("car/controls/horn", horn_action);
   
  ....
   
}


//invoked for each new instance of the vehicle
function init_vehicle()
{
...
this.geom = this.get_geomob(0);

_animation1 = this.geom.load_animation("Scene1.anim", "", 0);
_animation2 = this.geom.load_animation("Scene2.anim", "", 0);
...   
}



function horn_action(){
  if (flag==0){
     flag=1;         
  }else{                   
    flag=0;
  }             
}

//invoked when engine starts or stops
function engine(start){
...
}

//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering)
{
...
   
  sincro=sincro+dt;
 

  if (flag==0){
      this.geom.get_animation_stack().blend_animation(_animation1, 1, true, (speed1*sincro)%1);
      } else {
         this.geom.get_animation_stack().blend_animation(_animation2, 1, true, (speed2*sincro)%1);
  }
     
  this.geom.animate(); 

...

}









Title: Re: Character Animation
Post by: andfly on October 24, 2018, 11:15:32 am
Congratulations !!!

It was a bit of time that I did not explore the forum and today I found this good news.
I fully agree with what you say ...
There are no more excuses for which you can not see, soon, a significant increase in animated characters, in the world of Outerra, created by users and not only reserved for developers.
And then ...
Bringing in the forum the discussion on methods, attempts, failures, successes, discoveries and inventions is the most beautiful form of collaboration and mutual help to share a common passion.
I am sorry to have, at this moment, little time availability and not being able to be very useful ...
This is another reason why I am even more admired for the work and the results you have achieved.

Congratulations again!   :) :)
Title: Re: Character Animation
Post by: fly77 on October 24, 2018, 11:59:30 am
Thank you andfly for your kind appreciaction. Coming from you its a special honor as you are probably the one who gave us the most beautiful addons from which we still can learn a lot..i just need to find the time..but indeed exchanging models experiences and failures on the forum step by step we can progress together helping each other. Now there are so many  possibilies opened already that for sure i will try also a more polished model..still keeping it relatively simple though.
Title: Re: Character Animation
Post by: fly77 on November 10, 2018, 10:47:43 am
Finally I got my first animated character finished. He likes trekking around the outerra world and to have fun ! Here is a video showing some of the capabilities of my "wanderer".

https://vimeo.com/300040104

Download the self installing .otx file of the animated character from here:

https://www.dropbox.com/s/39xj6m2lrorekst/wanderer.otx?dl=0 (https://www.dropbox.com/s/39xj6m2lrorekst/wanderer.otx?dl=0)




Commands of the model:

The model will appear in the "vehicles" menu as it is based on a vehicle script.
key “W”    accelerate
Key “S”    break
Key “A”    turn left
Key “D”    turn right
Key "F"         jump
key “R”    toggle between forward/backward motion

key "L"         toggle between sit-down /get-up

Key “C”    change the "external camera" view mode
Key “V”    change the first person view camer amode
Keys "numpad +/-"    zoom in first person camera view modes


key“H”          toggle different colors of the head up display in one of the first person camera view modes


NOTES:

The physiology of the character is programmed in such a way as to require a short rest after having walked a certain distance or climbed uphill for an imposed altitude difference. The parameters are set at a distance of 1000 m and an altitude difference of 30 m after which the vigor of the character diminishes, requiring a period of rest of 20 seconds to resume the walk.
It is possible to change these characteristics of the character, as well as others - among which also the strength and the maximum speed attainable in sprinting - by opening the text file "wanderer.js" in the C: \ Users \ username \ Outerra \ packages \ fly77 \ wanderer folder
modifying the parameters indicated in the header section of this file.

HAVE FUN !
Title: Re: Character Animation
Post by: andfly on November 10, 2018, 11:50:14 am
Acc ....   :o

Very beautifull !!!    :D :D   8) 8)
Title: Re: Character Animation
Post by: fly77 on November 10, 2018, 12:24:20 pm
Thanks ! In making it I learned quite a lot. Certainly it is not perfect in several ways, but I'll keep that for the next character.
Title: Re: Character Animation
Post by: patmarrnc on November 10, 2018, 06:01:38 pm
very cool! Can't wait to DL it and study your script to see how you change ANIM files!
Title: Re: Character Animation
Post by: patmarrnc on November 10, 2018, 08:37:22 pm
I appreciate the way the people on this forum freely share their knowledge. I have a problem with stalling when I can't solve a key problem. Unless others who see the problem with new eyes get involved and solve the problem I can't understand, I am inclined to move on to a different hobby and never look back.

Thanks to Andfly for all the encouragement, advice and working scripts!

Thanks to Fly77 for figuring out how to use multiple ANIM files in the same script.

Thanks to the many people (too many to name) who shared their knowledge about how to create textures correctly and upload models and create vehicles and watercraft and flying machines.

And of course, thanks to Cameni et al whose vision and programming skill have created this amazing anteworld we know as Outerra.

What a great global community of clever people!

Summer has redirected my attention to home maintenance... but as winter approaches I hope to start contributing models.  In the works already is a modular castle building set. Here are some pictures of somebody else's castle so you can see how cool a castle looks on a hill overlooking a lake:




Title: Re: Character Animation
Post by: fly77 on November 18, 2018, 03:53:52 pm
cool ! do you plan to use collision boxes for it so that characters can actually walk inside and on top of it and climb stairways and towers and visit the rooms ? I am trying to learn my character walk stairs. If he could visit your castle it will starting to look like a game !
Title: Re: Character Animation
Post by: patmarrnc on November 19, 2018, 12:06:32 am
well... interesting question... my original plan was to just make the outside of the castle modules without making rooms inside.  In order to match the Outerra world scale these models are already pretty big, and I figure most people would probably just use them as background "fly-by" scenery.  However, I probably should at least add collision so characters can walk along the walls, stand in the archer turrets and on balconies etc.

For my purposes, I make a second version with collision that is used in my animation software, and when I need to have character interacting with the models I do it as close-ups in that environment. I just use the Outerra models to give the scenes a sense of scale in the real world. Any people in those scenes would be green screened onto a different layer.

If you downloaded that last batch of stuff I put on my dropbox, there was a log cabin that had an inside with furniture that can be seen through the windows. But until recently I didn't see much evidence that people were using characters in their world, so I didn't put collision so people could walk up the stairs, stand on the porch and go inside. Maybe I should go back and add collision to that cabin.

There were also 2 stone bridges in the campground models, and they both have collision. If you put them across a stream, cars can drive across and small boats can float through the opening under the bridges.  Using the models in that set (pavilions, tents, picnic tables, campers, park signs, bridges, cabins etc) you can make a pretty cool looking park in the mountains.
Title: Re: Character Animation
Post by: fly77 on November 19, 2018, 01:34:52 am
I liked very much your models..especially the bridge and the tutorial you made on it. As we are now able to make characters moving around the outerra world ..as vehicles for the moment...for stairs i think the simplest way is to add a sloped flat collision box "walking surface" as you did in your bridge (see the attached image..it works..of course). I will also try to make some buildings to test the idea of walking inside them. For this i first need to reduce the size of the characters collision box so that he can better walk through doors etc. I will post an updated version soon. By the way I guess you already know these instruction explaining how to add also spheres, cones, etc..as collision shapes https://github.com/Outerra/anteworld/wiki/Importer (https://github.com/Outerra/anteworld/wiki/Importer).
Title: Re: Character Animation
Post by: fly77 on November 19, 2018, 03:27:41 pm
below is a short video of a first trial for exploring building interiors using a basic house made in blender (adding collision boxes to each building element). So it seems possible to explore building interiors of custom made buildings
in outerra..Still needs some turning regarding the character..especially to turn in tight spaces..(for instance I don't know yet how to implement "strafe" for a vehicle.)

https://vimeo.com/301690939 (https://vimeo.com/301690939)