Author Topic: HOWTO: Animate the scale of a mesh in NWMax and have it work in-game  (Read 662 times)

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               "NWN can recognize position and rotation keys but not scale keys."

':whistle:'

'Posted

The above demo is mainly to show the effect and to show that the lighting and shadow system seem to treat the scaling as legit.  Unsurprisingly, the PWK doesn't expand and contract along with the mesh or anything else magical like that- this just scales meshes.

This is definitely not my discovery- I stumbled on a message of Kinaar Greycloak's in the Omnibus (see "scalekey") while looking for something else a few nights ago.  Tried what he suggested by hand, got it to work, was in the process of trying to modify NWMax to automate the technique so people could use it and...discovered that functionality to do just that had been quietly slipped into the scripts way back in Beta 6, back in 2004, and without any mention or fanfare that I could find.

'=]'

If you know what you're doing, here's the goods:
Scaling in NWN is uniform and so instead of a format which goes:
[TIME] [X] [Y] [Z]
It's much simpler, only requiring a time and a scale multiplier, like this:
[TIME] [SCALE]
This is accomplished in NWMax by animating scale keys on the Aurora Trimesh modifier's values, not actually scaling the object.  You will never see the object being scaled in GMax/3DS Max, only in-game.

Here's how to do it, from scratch, which even a beginner should be able to follow:
1. Make your Aurora base and give it a name (I like plc_a01)
2. Create a sphere or box or presumably whatever and attach it to the model base.  Add an Aurora Trimesh modifier to it.
3. Select the model base and go down to the "Animations on Model" section
- Make sure "default" animation name is selected
- Start Frame is 0
- End Frame is 100
- Anim Root is "plc_a01" (sans quotes, of course)
- Then click the Add button, which is just above the big Reset Zoom button
-> You should now see the new "default" anim show up in the "Animations on Model" list
4. Select the object you're going to animate the scale of.  You should see the Aurora Trimesh parameters listed.
5. Click the Key Filters... button and make sure that only Modifiers is ticked.  For what we're doing, this is all we'll need.
6. With the animation slider at frame 0, click the Auto Key button.  The trackbar will turn red.
7. Click the Key Icon button, which will lay down a default key for you at frame 0
8. Slide the trackbar to frame 50
9. On the modifier panel, which should already be up, locate the Scale Factor and increase it to, say, 1.6.  As soon as you click it some red brackets are going to surround the button and a key will have been laid down automatically at frame 50.
10. Turn off Auto Key
11. Move the slider to frame 100
12. On the timeline, locate the key at frame 0.  Select it.  Holding down the SHIFT key, drag it to frame 100.  You copied the frame at the beginning to the end this way.  Drag the slider back to 0.

Export your model with animations.  It'll start animating even in the toolset.  BTW, if you don't already know, plc_a01 is the Armoire placeable so you can search and find it to place.

NOTE: From Kinaar's post in the thread:

Kinaar Greycloak wrote...
There are always issues, of course, so here's what I've found.
- You can't change the placeable wok when scaling placeables so someone might be able to walk through the edges if you make it too big.
- You have to change the model structure for creatures so that you can also move the rootdummy position to match the scale, meaning that you have to have a different animation set for any creature you want to scale. Check the npc model in the demo for an example.
- Scaling creatures doesn't affect their appearance.2da values, of course, so things like weapon size, wings and tails, walk, run, and combat distances won't change and may make the model seem strange at extreme scales.
- Scaling dynamic models (like the PC races) doesn't work right. Everything will scale except the head. I tried a couple of different ways to do it, but neither the head nor a helmet will scale.


               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #1 on: November 04, 2012, 11:14:24 am »


               you monster you:D thats realy cool. I always wanted to have some spider eggs where something inside seems to move. Thanks for this:)
               
               

               
            

Legacy_Frimbleglim

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #2 on: November 04, 2012, 05:12:25 pm »


               Can you rescale the pc like this?  That could be fun.  ed. ah no you can't I see.
               
               

               


                     Modifié par Frimbleglim, 04 novembre 2012 - 05:14 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #3 on: November 04, 2012, 05:16:53 pm »


               Frimble, according to GreyCloak's comments above, he tried it but the PC head didn't scale with the rest of the body.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #4 on: November 04, 2012, 07:09:01 pm »


               <shaking his head...>

Most likely because the head (like a helmet) is applied like an effect, and the scale of the effect is taken from the models load value (static), not any scaled values.

Might be interesting to load an animation set onto the head part and put in some scale keys, though... Just for giggles ;-)

<...to clear the fog>
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #5 on: November 04, 2012, 07:16:28 pm »


               I think this is going to be most useful for doing simpler things like growing fruit, trees, plants, making placeables or parts of them change shape or VFX.  You could also go large and do something like Daern's Instant Fortress or Figurines of Wondrous Power (two suggestions by Rabbithail in Kinaar's thread), but that's not really my bag.

Speaking of VFX:
The mesh being scaled needn't be visible to have an impact on the scene, either.  You can, for instance, do some interesting things by attaching emitter assemblies (i.e. an emitter which is the child of a dummy) to the outside of a mesh, set the mesh not to render, but when you scale the invisible mesh the emitters go along for the ride.  

Like this:
'Posted

I like the idea of using these animated meshes as a rig.  Getting emitters to do things is easy.  Getting emitters to do things you want them to is often quite a bit more difficult, especially when it comes to the kind of movement I display in the video.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #6 on: November 04, 2012, 10:39:01 pm »


               Fooling with this some more, I had some problems getting a tree placeable to scale up.  I was putting the scale keys on the trunk to which the foliage (2 separate meshes) was attached.  For some reason, when I scaled it up the tree either the foliage didn't scale right or the trunk I'd placed they keys on didn't.  Something was off. 

Instead of sorting it out (I suspected there was some pivot issue), it occurred to me that I could attempt to put scale keys on the actual model base (because that pivot is always going to be at 0,0,0).

It worked.  '<img'>

If you'd like to experiment with this, here's what you do:
Simply place an Aurora Trimesh modifier on the model base.  It will sit above the model base modifier, which is fine.  You may click on the model base modifier in order to make sure you're in the right animation frame range but when you are laying down keys I believe it's very important that you always have the Aurora Trimesh modifier above it selected.  I am not sure if this is important or not, but I was simlpy too lazy to plug in the animroot when creating my animations on the model base.  Either NWMax fixed that for me on exit (don't recall any notifications though) or they simply didn't get put on there.  Whether that's important or not, I don't know yet but I include it for consideration.

Here's the animated tree growth and I have to say I'm really happy with how this looks.  As luck would have it, the canopy on the small version was about the same size as the trunk on the large version so PWK-wise, everything still makes "sense" to the player as they're walking around it.
'Posted

Feeling a little dizzy from putting a trimesh modifer and keys on a model base and having it work, I chose to double down on the dirty and put some open-ended scale keys on a custom looping animation for the flying kobold from StoneMonkey's flying NPC's & phenotypes pack.

What are "Open-ended keys" and why are they 'dirty'?:
Key frames should normally exist like bookends for a given animation.  One at the beginning, one at the end and of course some number of animation keyframes in between.  Although there's a sanity check in NWMax which will usually complain about you not having these bookends, it is possible to include open-ended keys in an animation.  Instead of the animation being a "closed loop" where you go from a neutral state into an animation and back to that neutral state, open-ended keys leave settings changed.  This is normally not advisable for animations involving things like position and rotation but...in this case we're talking about settings on the Aurora Trimesh modifier, which makes leaving those keys open-ended a bit more tempting.
'Posted

Things to notice: Obviously any 2DA information is not being scaled.  Neither is the weapon or the wings- which is as one would predict.  Notice also the height change as (presumably) the rootdummy scales.  I included this video not as an example of something people should do, but more as as a "If you do this, this is what it actually looks like" kind of thing.  I also expected more stuff to fly apart as a result of this process, honestly, and was really surprised when it didn't.  One last thing specific to this process: Since this open-ended key has changed a value on a loaded model, if another player were to enter the scene it's very likely that they would not see the scaled creature.  They might see the creature as it was before scaling.  I can't be 100% sure about this but it seemed a prudent warning to include.

This should NOT be an issue with the method on the placeable tree because its scale is relegated to a clearly defined ("activated") animation state.
               
               

               
            

Legacy_KlatchainCoffee

  • Sr. Member
  • ****
  • Posts: 372
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #7 on: November 05, 2012, 10:11:18 am »


               Wow! This is really amazing and has many potential applications: plant/crop growing, season change, balloon inflation, explosions and other expanding light effects, various effects with perspective. For example ships appearing on the horizon and then increasing in size as they sail towards you.

Is there a way to control how quickly this happens?
               
               

               
            

Legacy_Frimbleglim

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #8 on: November 05, 2012, 11:28:13 am »


               Presumably you could use this to create huge monsters?  As it doesn't require haks this could slightly extend the standard pallet.  I'm thinking quite basic here but a bear the size of a dragon should be possible and should make players stop in their tracks for a moment.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #9 on: November 05, 2012, 01:19:20 pm »


                @Frimble...or Spriggans!

The trick would be handling the 2DA related stuff - attack distance, personal space etc...

Perhaps for a spriggan you could have a grows large animation, then at the end of the animation, swap the creature's appearance type with the large version via script. So you would still need the two appearance types (big and small), but the animation would be a huge improvement over appearance changing alone.

It would be important to have the timing of the growing animation down perfectly so that the appearance swap could be implemented at just the right moment.

Incidentally I tried something like this with mixed results by using the tail model and the invisible scaleable model, then running a script that changed the appearance type to different size multipliers. I also changed the tail appearance at some points. This was a spell that transformed a polymorphed villain back into its goblin form. In testing it looked good. The creature appeared to be changing in size and alternating between human and goblinoid features. But on game day, much of the affect was lost in client side lag. All those appearance changes and tail changes in rapid succession wimply went unrendered.

I think a single animation, and one appearance swap would be more effective.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #10 on: November 05, 2012, 04:14:31 pm »


               

henesua wrote...
I think a single animation, and one appearance swap would be more effective.

Yeah, based on what I know at this time, that's the way I think you can squeeze the most out of this for creatures.  Having that visual bridge where you actually see the creature growing smoothly sells the effect enough so that when the swap happens it's (hopefully) not that big a deal.  I went back and looked at the flying kobold and he's definitely animating while he's scaling, so that could work in favor of a smooth transition.  As opposed to a T-pose or a arms and legs together and down "frozen" position, anyway.
               
               

               


                     Modifié par OldTimeRadio, 05 novembre 2012 - 04:14 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #11 on: November 19, 2012, 10:00:56 pm »


               Very interesting '<img'>  do you want me to add this to the tutorials? and if so what do you want it under model or animation or what?
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #12 on: November 19, 2012, 11:36:44 pm »


               

ShadowM wrote...
Very interesting '<img'>  do you want me to add this to the tutorials? and if so what do you want it under model or animation or what?

Yes please.  Um...I suppose animation?  Good point.  Yeah, animation I guess.  Your call if necessary.  '<img'>

Thanks again!
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
HOWTO: Animate the scale of a mesh in NWMax and have it work in-game
« Reply #13 on: November 20, 2012, 03:07:48 am »


               ok done '<img'> np