Difference between revisions of "Animation Streamlined"

From Second Life Wiki
Jump to navigation Jump to search
m (more pics)
(Added a new section for Animesh!)
 
(36 intermediate revisions by 6 users not shown)
Line 6: Line 6:
What? Now you want their wings flapping and their legs moving?  
What? Now you want their wings flapping and their legs moving?  


===How do I choose?===
===What are my options?===


You've got some choices to make. All the methods described here involve tradeoffs, and no one method is best in all situations.  
You've got some choices to make. All the methods described here involve tradeoffs, and no one method is best in all situations.  


They work with pathfinding-enabled and non-pathfinding creations.
They work with [[Pathfinding|pathfinding-enabled]] and non-pathfinding creations.


====Method: Animated Textures====  
====Method: Animated Textures====  
{{Anchor|Method_Animation_texture}}


[[Image: Animated_hippofly.gif]]
[[Image: Animated_hippofly.gif]]


Use [[llSetTextureAnim|llSetTextureAnim]] and [[llSetLinkTextureAnim|llSetLinkTextureAnim]] with a texture to simulate movement.  
Animate 2D textures on a model to simulate movement.
 
Most of the time a framed texture is what you'd want, but for something like a millipede's legs you might want to use a tiling texture instead. Here's a 2x2 framed texture next to a picture of it [[Animation_Streamlined#Animation_texture|animated]].


Most of the time a framed texture is what you'd want, but for something like a millipede's legs you might want to use a tiling texture instead. (flat texture frame pics of Eyes blinking or bug wings)
[[Image: Eye Frame.jpg]] [[Image: Eye Frame.gif]]


* This is very low server and viewer lag.
* This is very low server and viewer lag.
* This is 2D, so it's best for small or flat things.
* This is 2D, so it's best for small or flat things.
* SL won't allow you to upload a texture larger than 1024x1024 pixels so resolution may be an issue for textures with a lot of frames.
* Animated textures on a prim can be on one face, or all faces with one direction, so sometimes you have to break a moving section up. (point out Sylvan's flipped UV wheel trick here)


The hippo flies are an example of using model design and animated textures together. The model has several sets of wings. The different frames of the texture each have one pair of wings visible, so when animated the hippo flies seem to flap their wings. Mesh models don't look glitched like a sculpt does when a texture with transparency is applied.
The hippo flies are an example of using model design and animated textures together. The model has several sets of wings. The different frames of the texture each have one pair of wings visible, so when animated the hippo flies seem to flap their wings. Mesh models don't look glitched like a sculpt does when a texture with transparency is applied.


====Method: Flexible Prims====
====Method: Flexible Prims====
{{Anchor|Method_Animation_flexi}}
[[Image: Animated flexibird.gif|100px]]
[[Flex|Flexi]] can be used to simulate smooth movement. Sadly, I couldn't capture how smooth it looks using snapshots.


[[Image: Animated flexibird.gif|200px]]
This is the only option that can be done without scripts.


Flexi can be used to simulate smooth movement. Sadly, I couldn't capture how smooth it looks using snapshots.
Wings, tails, and hair are good candidates for this. Long flexi fur may be a lot simpler than animating legs!


* A large number of flexi prims in a scene can lag the viewer. Viewer graphic settings can impact how flexi prims are displayed.
* A large number of flexi prims in a scene can lag the viewer. Viewer graphic settings can impact how flexi prims are displayed.
* A flexi prim's values can be set in the edit window or changed via script using [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] and the [[PRIM_FLEXIBLE]] flag.
* A flexi prim's values can be set in the edit window or [[Animation_Streamlined#Animation_flexi|changed via script]].


====Method: Alpha Animation====
====Method: Alpha Animation====
{{Anchor|Method_Animation_alpha}}


[[Image: Animated_ray.gif|200px]]
[[Image: Animated_ray.gif|200px]]


Use [[llSetLinkAlpha|llSetLinkAlpha]] to change which pieces are visible at any one time to simulate movement.
Show different pieces of your model at different times to simulate movement.


Make several models of your creature in different poses. Link them together, usually at the torso. Alternate which model of the linkset is visible.
Make several models of your creature (or parts of your creature) in different poses. Join them into one linkset, usually at the torso. Alternate which parts of the linkset are [[Animation_Streamlined#Animation_alpha|visible via script]].


* Higher LI/prim count than other methods.  
* Higher LI/prim count than other methods.  
Line 48: Line 55:


====Method: Prim Movement====
====Method: Prim Movement====
{{Anchor|Method_Animation_moving}}


[[Image: Animated_bunny.gif|200px]]
[[Image: Animated_bunny.gif|200px]]


This method repositions and resizes pieces to simulate movement. (Pic: capybura? mopbeast with eyes that go big when it spots an avatar)
This method repositions and resizes pieces to simulate movement.


* Lower LI/prim count than alpha animation.
* Lower LI/prim count than alpha animation.
* It causes a fair bit of server lag. Use the Physics Type None setting on the child prims to reduce the server's script time. You can set this when building in the edit window or via script using [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with [[PRIM_PHYSICS_SHAPE_TYPE]] set to [[PRIM_PHYSICS_SHAPE_NONE]].
* This can look very smooth if the changes are fairly small.
* Moving prims that have a [[PRIM_PHYSICS_SHAPE_TYPE]] other than [[PRIM_PHYSICS_SHAPE_NONE]] can cause '''extreme''' server lag and physical collision issues (such a snagging the terrain or other objects).
* The viewer receives a message for each prim change.
* The viewer receives a message for each prim change.
* Using the edit window to resize a creature that uses prim movement can break the creature.
* Using the edit window to resize a creature that uses prim movement can break the creature.
* Use [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with the prim position, rotation, and size flags.
 
Click [[Animation_Streamlined#Animation_moving|here]] to learn more.


====Method: Sculpt Map Swap====
====Method: Sculpt Map Swap====
{{Anchor|Method_Animation_sculpt}}


[[Image: Animated flock.gif]]
[[Image: Animated flock.gif]][[Image: Animated_pigeon.gif]]


Swap the prim's sculpt map to simulate movement.
Swap the prim's sculpt map to simulate movement.


* Lower LI/prim count than alpha animation. Beware of LI when using sculpts!
* Lower LI/prim count than alpha animation. Beware of LI when using sculpts!
* It generates a LOT of viewer lag. The viewer receives a message for each prim change. The viewer recalculates the sculpt mesh with each change. The impact of the recalculating can be softened by having prims within loading range showing the same sculpt shapes. Consider hidden prims in your creature showing the next "frame" or having a flock out.
* It generates a LOT of viewer lag. The viewer receives a message for each prim change. The viewer recalculates the sculpt mesh with each change. Consider hidden prims in your creature showing the next "frame" or having a flock out.
* Use [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with the [[PRIM_TYPE_SCULPT]] flag to set a prim's sculpt map.
** The impact of the recalculating can be softened by having prims within loading range showing the same sculpt shapes
** If the sculpt map texture isn't currently in the scene, it may be removed from the viewer's cache, so it may be end up being sent to the viewer multiple times. The blue-outlined cube behind the pigeon has the sculpt map textures on its sides, so the viewer doesn't remove them from the cache while the bird is in sight.
* You can set the center of a sculpted prim when designing the sculpt map. You can't do the same with mesh. Sometimes clever placement of the center can save you from having to move or rotate a prim.
 
Click [[Animation_Streamlined#Animation_sculpt|here]] to learn more.
 
====Method: Animesh====
 
'''[[Animesh User Guide|Animesh]]''', or '''animated meshes''' is a technology introduced by Linden Lab in November 2018 to address most of the shortcomings of the above methods, and widen the range of possibilities, with next-to-zero impact to the region simulators, and a little impact on the viewer (but not overwhelmingly so).
 
Since Second Life was launched, we ''always'' had 'animated meshes'. The problem was that it was just ''one'' — namely, the standard avatar body mesh. Everything else was un-animate-able and mostly frozen in place, with the exception of flexiprims and Linden Trees. Thus the several methods described above to give a sense of movement to an object, each with its limitations.
 
With mesh replacing both sculpties and primitives, and becoming the ''de facto'' standard for content creation, animesh allows our meshed objects to be animated in the same way that avatars can be animated!
 
In particular, animesh allows:
* Using any standard mesh (within reasonable size limits and less than 100,000 triangles or so)
* A pseudo-skeleton, equivalent to the original standard avatar body, will be implied for that mesh, so the mesh can be properly rigged
* Animations are uploaded as BVH files for the original standard avatar and become assets exactly like avatar animations
* The mesh item, for all effects, is driven by an Animation Overrider
* Animations run on the viewer, not the simulator; this means that there is far less effort by the physics engine to track a moving, animated object. This is exactly how user avatar animations also work!
* Animesh can also be attached to user avatars, within limits; this allows animated pets perched on one's shoulder, for example
* There are special attachment points on user avatars using the [[Project Bento Resources and Information|Bento skeleton]] for wings, tail, etc. which can be "animeshed" in conjunction with the avatars themselves
 
[[Animesh]] has its own entire section here on the SL Wiki.
 
===How do I make it happen?===
 
====Physics Shape Type: None====
 
This value allows you to tell the physics engine to [[Physics_Optimization|ignore prims]] when it is doing calculations. Your creature will explore much more efficiently if there's no need to calculate whether each toenail might be colliding with that rock!
 
You can't set this to none on a root prim.
 
If you select an object and toggle it to none in the edit window, all the child prims will be set.
 
You can set this via script using [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with [[PRIM_PHYSICS_SHAPE_TYPE]] set to [[PRIM_PHYSICS_SHAPE_NONE]].
 
====Getting the link number====
 
A lot of the scripting calls used here expect you to have the link ID number.
 
What's a [[Link|linkset or link ID?]]
 
If you've got a choice between using the linkset calls or putting separate scripts in most of your creature's prims, go with fewer scripts. The number of [[Mesh/FAQ#Script_impact_on_LI|scripts in an object can affect LI]].
 
[[Image: Bunny_in_a_hat.png|right]]
 
You can find the absolute link ID of a prim in your linkset, but those numbers are only reliable until the next time you decide to add or remove a prim from your build. Naming the prims in your creature useful things like "leg" or "wing" things will prevent your scripts from breaking when you decide your bunny needs a top hat.
 
Code snippets for finding [[LinksetIndexing| link IDs via prim name]] can be found here.
 
====Animating a texture====
{{Anchor|Animation_texture}}
 
Use [[llSetTextureAnim|llSetTextureAnim]] and [[llSetLinkTextureAnim|llSetLinkTextureAnim]] with a texture to simulate movement.
 
SL won't allow you to upload a texture larger than 1024x1024 pixels so resolution may be an issue for textures with a lot of frames.
 
Animated textures on a prim can be on one face, or all faces with one direction. You also don't get to use offsets or flip. (point out Sylvan's flipped UV wheel trick here)
 
This [[AS_Texture_Animation|animated texture script]] could be used on a creature to make it blink.
 
====Setting flexible prim values====
{{Anchor|Animation_flexi}}
 
Use [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] and the [[PRIM_FLEXIBLE]] flag.
 
This [[AS_Flexi_Wing_Flap|flapping wings script]] could be used with a bird that has spread flexi wings.
 
====Setting alpha values====
{{Anchor|Animation_alpha}}
 
Use [[llSetLinkAlpha|llSetLinkAlpha]] to change which pieces are visible at any one time.
 
This [[AS_Alpha_Animation|alpha animation script]] could be used with a creature made up of differently posed mesh or sculpt models.
 
====Moving prims====
{{Anchor|Animation_moving}}
 
Use [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with the prim position, rotation, and size flags.
 
====Swapping sculpt maps====
{{Anchor|Animation_sculpt}}
 
Use [[LlSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] with the [[PRIM_TYPE_SCULPT]] flag to set a prim's sculpt map.
 
This [[AS_Sculpt_Map_Swap|sculpt map swap script]] could be used with a creature to change its body pose.
 
----
 
↩️ Back to [[Good Building Practices]]

Latest revision as of 09:30, 28 September 2024

Animating Streamlined

Your creations are on the move. Congratulations!

What? Now you want their wings flapping and their legs moving?

What are my options?

You've got some choices to make. All the methods described here involve tradeoffs, and no one method is best in all situations.

They work with pathfinding-enabled and non-pathfinding creations.

Method: Animated Textures

Animated hippofly.gif

Animate 2D textures on a model to simulate movement.

Most of the time a framed texture is what you'd want, but for something like a millipede's legs you might want to use a tiling texture instead. Here's a 2x2 framed texture next to a picture of it animated.

Eye Frame.jpg Eye Frame.gif

  • This is very low server and viewer lag.
  • This is 2D, so it's best for small or flat things.

The hippo flies are an example of using model design and animated textures together. The model has several sets of wings. The different frames of the texture each have one pair of wings visible, so when animated the hippo flies seem to flap their wings. Mesh models don't look glitched like a sculpt does when a texture with transparency is applied.

Method: Flexible Prims

Animated flexibird.gif

Flexi can be used to simulate smooth movement. Sadly, I couldn't capture how smooth it looks using snapshots.

This is the only option that can be done without scripts.

Wings, tails, and hair are good candidates for this. Long flexi fur may be a lot simpler than animating legs!

  • A large number of flexi prims in a scene can lag the viewer. Viewer graphic settings can impact how flexi prims are displayed.
  • A flexi prim's values can be set in the edit window or changed via script.

Method: Alpha Animation

Animated ray.gif

Show different pieces of your model at different times to simulate movement.

Make several models of your creature (or parts of your creature) in different poses. Join them into one linkset, usually at the torso. Alternate which parts of the linkset are visible via script.

  • Higher LI/prim count than other methods.
  • It induces less server lag than moving the prims, but the viewer receives a message for every alpha change.

Method: Prim Movement

Animated bunny.gif

This method repositions and resizes pieces to simulate movement.

  • Lower LI/prim count than alpha animation.
  • This can look very smooth if the changes are fairly small.
  • Moving prims that have a PRIM_PHYSICS_SHAPE_TYPE other than PRIM_PHYSICS_SHAPE_NONE can cause extreme server lag and physical collision issues (such a snagging the terrain or other objects).
  • The viewer receives a message for each prim change.
  • Using the edit window to resize a creature that uses prim movement can break the creature.

Click here to learn more.

Method: Sculpt Map Swap

Animated flock.gifAnimated pigeon.gif

Swap the prim's sculpt map to simulate movement.

  • Lower LI/prim count than alpha animation. Beware of LI when using sculpts!
  • It generates a LOT of viewer lag. The viewer receives a message for each prim change. The viewer recalculates the sculpt mesh with each change. Consider hidden prims in your creature showing the next "frame" or having a flock out.
    • The impact of the recalculating can be softened by having prims within loading range showing the same sculpt shapes
    • If the sculpt map texture isn't currently in the scene, it may be removed from the viewer's cache, so it may be end up being sent to the viewer multiple times. The blue-outlined cube behind the pigeon has the sculpt map textures on its sides, so the viewer doesn't remove them from the cache while the bird is in sight.
  • You can set the center of a sculpted prim when designing the sculpt map. You can't do the same with mesh. Sometimes clever placement of the center can save you from having to move or rotate a prim.

Click here to learn more.

Method: Animesh

Animesh, or animated meshes is a technology introduced by Linden Lab in November 2018 to address most of the shortcomings of the above methods, and widen the range of possibilities, with next-to-zero impact to the region simulators, and a little impact on the viewer (but not overwhelmingly so).

Since Second Life was launched, we always had 'animated meshes'. The problem was that it was just one — namely, the standard avatar body mesh. Everything else was un-animate-able and mostly frozen in place, with the exception of flexiprims and Linden Trees. Thus the several methods described above to give a sense of movement to an object, each with its limitations.

With mesh replacing both sculpties and primitives, and becoming the de facto standard for content creation, animesh allows our meshed objects to be animated in the same way that avatars can be animated!

In particular, animesh allows:

  • Using any standard mesh (within reasonable size limits and less than 100,000 triangles or so)
  • A pseudo-skeleton, equivalent to the original standard avatar body, will be implied for that mesh, so the mesh can be properly rigged
  • Animations are uploaded as BVH files for the original standard avatar and become assets exactly like avatar animations
  • The mesh item, for all effects, is driven by an Animation Overrider
  • Animations run on the viewer, not the simulator; this means that there is far less effort by the physics engine to track a moving, animated object. This is exactly how user avatar animations also work!
  • Animesh can also be attached to user avatars, within limits; this allows animated pets perched on one's shoulder, for example
  • There are special attachment points on user avatars using the Bento skeleton for wings, tail, etc. which can be "animeshed" in conjunction with the avatars themselves

Animesh has its own entire section here on the SL Wiki.

How do I make it happen?

Physics Shape Type: None

This value allows you to tell the physics engine to ignore prims when it is doing calculations. Your creature will explore much more efficiently if there's no need to calculate whether each toenail might be colliding with that rock!

You can't set this to none on a root prim.

If you select an object and toggle it to none in the edit window, all the child prims will be set.

You can set this via script using llSetLinkPrimitiveParamsFast with PRIM_PHYSICS_SHAPE_TYPE set to PRIM_PHYSICS_SHAPE_NONE.

Getting the link number

A lot of the scripting calls used here expect you to have the link ID number.

What's a linkset or link ID?

If you've got a choice between using the linkset calls or putting separate scripts in most of your creature's prims, go with fewer scripts. The number of scripts in an object can affect LI.

Bunny in a hat.png

You can find the absolute link ID of a prim in your linkset, but those numbers are only reliable until the next time you decide to add or remove a prim from your build. Naming the prims in your creature useful things like "leg" or "wing" things will prevent your scripts from breaking when you decide your bunny needs a top hat.

Code snippets for finding link IDs via prim name can be found here.

Animating a texture

Use llSetTextureAnim and llSetLinkTextureAnim with a texture to simulate movement.

SL won't allow you to upload a texture larger than 1024x1024 pixels so resolution may be an issue for textures with a lot of frames.

Animated textures on a prim can be on one face, or all faces with one direction. You also don't get to use offsets or flip. (point out Sylvan's flipped UV wheel trick here)

This animated texture script could be used on a creature to make it blink.

Setting flexible prim values

Use llSetLinkPrimitiveParamsFast and the PRIM_FLEXIBLE flag.

This flapping wings script could be used with a bird that has spread flexi wings.

Setting alpha values

Use llSetLinkAlpha to change which pieces are visible at any one time.

This alpha animation script could be used with a creature made up of differently posed mesh or sculpt models.

Moving prims

Use llSetLinkPrimitiveParamsFast with the prim position, rotation, and size flags.

Swapping sculpt maps

Use llSetLinkPrimitiveParamsFast with the PRIM_TYPE_SCULPT flag to set a prim's sculpt map.

This sculpt map swap script could be used with a creature to change its body pose.


↩️ Back to Good Building Practices