Author Topic: Build animations  (Read 4590 times)

Mr War

  • Guest
Build animations
« on: 28 April 2011, 08:04:08 »
Hi, I have a mothership unit in my Martian mod which instead of building in the normal way, I want it to look like a space ship is landing by legs coming out the bottom etc. I have built a 30frame animation in blender which itself works fine in the game.

However, the animation loops during building.

HP =8000

Is there a way of either:
A) ensuring the animation takes the same time to run as the build does
B) setting the animation go only run once

?

Thanks in advance

TotalNoob

  • Guest
Re: Build animations
« Reply #1 on: 28 April 2011, 12:02:24 »
I think the easiest way would be to make every next frame to be displayed for every (since there are 30 frames overall) 3,33% of HP gained during building process. No idea if it is possible to do right now.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Build animations
« Reply #2 on: 28 April 2011, 19:53:41 »
But timing that would be impossible. If multiple workers construct, the animation speed is unchanged, yet will be done faster.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Gabbe

  • Guest
Re: Build animations
« Reply #3 on: 28 April 2011, 23:18:40 »
Titi did something with the egypts pyramid if i recall correctly..

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Build animations
« Reply #4 on: 29 April 2011, 00:23:26 »
The Egypt's pyramid building anim is the tech barrack's textured yellow...
Get the Vbros': Packs 1, 2, 3, 4, and 5!

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Build animations
« Reply #5 on: 29 April 2011, 05:09:14 »
ok, so how would this ideally work?

Then we fix the engine to support this...

Psychedelic_hands

  • Guest
Re: Build animations
« Reply #6 on: 29 April 2011, 05:59:50 »
Possible Work around 1:
Make your workers build something like a Landing zone first, then have that "morph " into the Mothership. That way you an time the Morph animation of the landing perfect.

Work around 2:
Make your Mothership have a Ship unit form, and get you workers/a building to produce the flying unit form of the ship and then you morph that down to where you would like.

 I am unsure of how the AI would like these, but they should work fine.
I would recommend number 1, as you seem to already have a sort of landing thing underneath  :thumbup:
« Last Edit: 29 April 2011, 06:03:32 by Psychedelic_hands »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Build animations
« Reply #7 on: 29 April 2011, 06:11:17 »
Possible Work around 1:
Make your workers build something like a Landing zone first, then have that "morph " into the Mothership. That way you an time the Morph animation of the landing perfect.

Work around 2:
Make your Mothership have a Ship unit form, and get you workers/a building to produce the flying unit form of the ship and then you morph that down to where you would like.
The AI could handle #1 perfectly fine, as the Behemoth and Thor units already are built as a building, then morphed into a unit. I don't see how #2 is any different from #1 though (or do I misunderstand?).

If you wanted to build something so the animation would span over the entire build period, you'd probably need a feature request for sure, because as I mentioned, variable building speeds, such as that from having multiple workers repair, would ruin the animation otherwise. This was a feature request in the past, presumably lost in the sands of time.

Worth noting that the elves faction did this with their tree-like buildings. Though, in that case, the trees built almost instantly, so there was no reason to use multiple workers. Still, it does illustrate how it can work.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Build animations
« Reply #8 on: 29 April 2011, 06:20:23 »
both approaches sound excellent!

You could imagine being given a landing-pad and workers, and the first thing is to morph the landing pad.  Or maybe as a strategy you decide to *immediately* at the start of the game move your workers elsewhere and get them to build a landing-pad, so that the enemy doesn't find you in a known position...
« Last Edit: 29 April 2011, 06:22:58 by will »

Psychedelic_hands

  • Guest
Re: Build animations
« Reply #9 on: 29 April 2011, 06:30:52 »
They're the same Engine-wise, but different Gameplay-wise. Though I think the AI will handle number 1 better.

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Build animations
« Reply #10 on: 29 April 2011, 06:48:18 »
I don't think stretching one animation out is the ideal solution, Omega has pointed out why already...

The work-around solutions, while novel, are ugly and again Omega has pointed out likely AI issues.

Multiple animations per skill has been discussed time and time again... for various purposes. Someone should actually do it someday I guess... (GAE can actually load multiple animations, but it only ever uses the first... not so useful).

The way I would do it if it were to be done now,
Code: [Select]
  <animations>
<animation condition="hp < 2000" path="construction_models/castle_construction_stage1.g3d" />
<animation condition="hp < 5000" path="construction_models/castle_construction_stage2.g3d" />
<animation condition="hp < 8000" path="construction_models/castle_construction_stage3.g3d" />
<animation condition="hp < 9000" path="construction_models/castle_construction_stage4.g3d" />
  </animations>

But I don't think this should be done now, or like that...

It should be done like this,
Code: [Select]
  <animations>
<animation name="build_stage1" path="construction_models/castle_construction_stage1.g3d" />
<animation name="build_stage2" path="construction_models/castle_construction_stage2.g3d" />
<animation name="build_stage3" path="construction_models/castle_construction_stage3.g3d" />
<animation name="build_stage4" path="construction_models/castle_construction_stage4.g3d" />
<select-anim-script>
<![CDATA[
if unit:hp < 2000 then
return "build_stage1";
elseif unit:hp < 5000 then
return "build_stage2";
elseif unit:hp < 8000 then
return "build_stage3";
end
return "build_stage4";
]]>
</select-anim-script>
  </animations>
Glest Advanced Engine - Code Monkey

Timeline | Downloads

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Build animations
« Reply #11 on: 29 April 2011, 07:40:48 »
By making the choice of animation based on hp, and several workers means the building builds faster, will it abruptly switch animations without finishing them smoothly?

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Build animations
« Reply #12 on: 29 April 2011, 09:06:33 »
By making the choice of animation based on hp, and several workers means the building builds faster, will it abruptly switch animations without finishing them smoothly?

Yeah, this solution is fundamentally different from how the OP wanted this done... and not particularly compatible, you would need fairly static models (or 'fully' static) that could play looping until replaced by the next stage.

To do what the OP wanted, or similar with multiple g3d anims, would be something completely different to how it is done now... it could be done, but I'd prefer a solution not so wildly different to how anims currently play (and not needing lots of 'special case' code).
Glest Advanced Engine - Code Monkey

Timeline | Downloads

Mr War

  • Guest
Re: Build animations
« Reply #13 on: 29 April 2011, 14:02:30 »
Build animations loop but die animations do not. By default that's good. But couldn't there just be an XML tag to set a build ( or move or attack) animation to not loop?

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Build animations
« Reply #14 on: 30 April 2011, 01:56:15 »
@Silnarm: If you make a complex animation and use enough frames, drawing it out is no problem. The engine just needs to calculate the animation speed to match the building speed.
Egypt Remastered!

Proof: Owner of glest@mail.com

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Build animations
« Reply #15 on: 30 April 2011, 02:56:54 »
Upon further review this actually seems a good idea (also, I was tinkering, and found a clean(ish) way to do it), the same sort of thing could be done with produce/upgrade skills and some nice animations using this method would be cool (probably more so be-built, but it could be added for produce/etc easily if anyone wants it).

Done in GAE, beta1 will be released shortly.
It's just 'straight' tied to the hp atm, so if the under construction building gets attacked, the animation will go backwards! will fix this before 0.4 proper.

in the be-built (or build-self) skill node,
Code: [Select]
    <anim-stretch value="true" />
Glest Advanced Engine - Code Monkey

Timeline | Downloads

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Build animations
« Reply #16 on: 30 April 2011, 03:02:31 »
Upon further review this actually seems a good idea (also, I was tinkering, and found a clean(ish) way to do it), the same sort of thing could be done with produce/upgrade skills and some nice animations using this method would be cool (probably more so be-built, but it could be added for produce/etc easily if anyone wants it).

Done in GAE, beta1 will be released shortly.
It's just 'straight' tied to the hp atm, so if the under construction building gets attacked, the animation will go backwards! will fix this before 0.4 proper.

in the be-built (or build-self) skill node,
Code: [Select]
    <anim-stretch value="true" />

YEA!
I think a good fixing rule is that no building animation may play backwards.
Egypt Remastered!

Proof: Owner of glest@mail.com

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Build animations
« Reply #17 on: 30 April 2011, 10:52:15 »
Brilliant!

I guess Mr War doesn't build from git - how far away is a release with this in?

And can we get this into MG before the merge too?  Or is the merge so close as to not slow the active modders down?

I think a good fixing rule is that no building animation may play backwards.

I think that going backwards or otherwise ought to be specified in the xml

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Build animations
« Reply #18 on: 30 April 2011, 13:26:23 »
Quote
Quote from: -Archmage- on April 29, 2011, 22:02:31
I think a good fixing rule is that no building animation may play backwards.

I think that going backwards or otherwise ought to be specified in the xml

Yea why not! :thumbup:
Egypt Remastered!

Proof: Owner of glest@mail.com

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Build animations
« Reply #19 on: 30 April 2011, 16:03:07 »
Just a quick reminder, this is the MegaGlest related part of the forums. ;)
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Build animations
« Reply #20 on: 30 April 2011, 17:28:08 »
@tomreyn:  true but interisting nevertheless :)

About the problem itself, what about an animation progress based on the construction progress? I don't think this is too hard to do.
Problems that you might face:

When a building which is in state of building is attacked by another unit its animation might plyed back reversed ;). How to handle this?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Build animations
« Reply #21 on: 30 April 2011, 20:44:46 »
Imagine a build animation of a balloon or airship - it migbt be showing inflation, and going backwards if hp is falling would be a good thing.

So make it go backwards if hp drops is good, and perhaps in other circumstances it sohuld freeze until hp recovers.  Settable in ini

Bug I can't think that a looping animation is ever preferable, but sametime maybe that is a safe default for compatibility.

We want MG to do hp-related build animation speed so Mr War can use it immediately there is a release supporting it!

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Build animations
« Reply #22 on: 30 April 2011, 23:51:39 »
So make it go backwards if hp drops is good, and perhaps in other circumstances it sohuld freeze until hp recovers.  Settable in ini
I assume you mean the XML, not the INI?

Bug I can't think that a looping animation is ever preferable, but sametime maybe that is a safe default for compatibility.
An example that requires looping: UNATF's Heli's animation, naturally, is spinning very fast, and in order to do this without making the unit itself hyper fast, it goes through multiple animation cycles in the time it takes to perform one action, despite the animation itself being only one full spin of the blade.

We want MG to do hp-related build animation speed so Mr War can use it immediately there is a release supporting it!
Bearing in mind we should be preparing for the merger. If we keep adding features, we'll never get anything done. :-X
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Build animations
« Reply #23 on: 1 May 2011, 03:54:05 »
When a building which is in state of building is attacked by another unit its animation might plyed back reversed ;). How to handle this?

I was thinking use Unit::progress2, 'sync' with hp in Unit::repair() if hp > progress2.
Then animProgress is just progress2 / max_hp for the "stall instead of go backwards" version, and hp / max_hp for the version that will back up.

Bearing in mind we should be preparing for the merger. If we keep adding features, we'll never get anything done. :-X

True, but this was very easy to add in the end, I'll hook it up in MG too.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

 

anything