Difference between revisions of "Avatar deformation"
(Added some more info regarding rigged mesh deformers.) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{KBwarning| Choose the bones that you deform wisely, as you can inadvertently mess up a user's shape until they relog, and even the viewer's 'Undeform Avatar' feature will not fix this. See the [[Avatar deformation#Avoiding_bugs | Avoiding Bugs]] section below.}} | |||
== Avoiding bugs == | |||
Deformers in Second Life are essentially manipulating the positions of bones within an avatar's skeleton. While this is generally fairly safe, the '''position of some bones is affected by the shape sliders''', meaning any deformations applied to these bones will '''invalidate the user's shape''' and cannot be reset by either the deformer's creator (via another 'undeform' deformer), or the user themselves (via the viewer's 'Undeform Avatar' feature), and will only be reset when the user relogs when the deformer has been disabled or detached. | |||
As such, any bones that have their positions influenced by the shape sliders '''should not be deformed''' if it can be avoided. | |||
Note that you '''can''' deform the child of a bone affected by the shape sliders safely, just not that bone directly. | |||
'''For a full list of which bones with positions affected by the shape sliders, visit the [[Project Bento Skeleton Guide#Bones_Currently_Affected_By_Positional_Sliders | Project Bento Skeleton Guide]] page.''' | |||
''If you need to make deformations to a bone affected by the shape sliders, [[Avatar deformation#Method_2:_Rigged_Mesh | Method 2]] is the {{HoverText|safer|Meaning easily and non-destructively reversible.}} way to perform the deformation.'' | |||
== Methods == | == Methods == | ||
In Second Life, there are 2 ways you can deform an avatar, each with advantages and disadvantages: | In Second Life, there are 2 ways you can deform an avatar, each with advantages and disadvantages: | ||
Line 7: | Line 20: | ||
'''Advantages:''' | '''Advantages:''' | ||
:*Animations are generally easier for users to debug if something has gone awry, and the user can opt to force stop animations and undeform their avatar ''if needed''. | :*Animations are generally easier for users to debug if something has gone awry, and the user can opt to force stop animations and undeform their avatar {{HoverText|''if needed''|When your deformer is implemented correctly, this should never really be needed.}}. | ||
:*Animations can be triggered by scripts, therefore you can have a deformer be activated based on an action the avatar has taken, increasing immersiveness. | :*Animations can be triggered by scripts, therefore you can have a deformer be activated based on an action the avatar has taken, increasing immersiveness. | ||
:*Animations have a variable 'Ease In' time, meaning you can use a single animation to represent a change that happens over time. (E.g. an avatar eating a large burger, with a deformer and a long ease-in time to make their belly grow as they're eating) | :*Animations have a variable 'Ease In' time, meaning you can use a single animation to represent a change that happens over time. (E.g. an avatar eating a large burger, with a deformer and a long ease-in time to make their belly grow as they're eating) | ||
Line 14: | Line 27: | ||
:*When applying deformations to [[Mesh/Rigging Fitted Mesh#Collision_bones|collision volumes]], this will disable any effect that [https://wiki.firestormviewer.org/firestorm_avatar_physics Avatar Physics] may have on this bone. | :*When applying deformations to [[Mesh/Rigging Fitted Mesh#Collision_bones|collision volumes]], this will disable any effect that [https://wiki.firestormviewer.org/firestorm_avatar_physics Avatar Physics] may have on this bone. | ||
:*Deformations applied through animations are persistent, meaning that the deformation will remain even after the animation is stopped.'''*''' | :*Deformations applied through animations are persistent, meaning that the deformation will remain even after the animation is stopped.'''*''' | ||
{{hint | |||
|mode=warning | |||
|desc=The below instructions as part of this method are out-of-date, overcomplicated and {{HoverText|'unsafe'|Meaning that there's a risk that the avatar could be deformed in an undesired manner and cannot be non-destructively reversed.}}. These will be replaced when time allows. | |||
}} | |||
Taken from a Forum Post by Erluen Twin... | Taken from a Forum Post by Erluen Twin... | ||
Line 110: | Line 128: | ||
=== Method 2: Rigged Mesh === | === Method 2: Rigged Mesh === | ||
'''The below description uses nomenclature that may be specific to Blender, so your modelling program of choice may use different terminology, however the general process should be the same. | '''Advantages:''' | ||
:*When applying deformations to [[Mesh/Rigging Fitted Mesh#Collision_bones|collision volumes]], this method '''does not''' disable the effect of [https://wiki.firestormviewer.org/firestorm_avatar_physics Avatar Physics] may have on this bone. | |||
:*Deformations applied through Rigged Mesh are always temporary, and will be automatically reset when the item containing the deformer is detached. | |||
:*If needed, the influence of shape sliders on a bone can be locked out altogether by enabling "Lock scale if joint position is defined" in the mesh uploader. | |||
'''Disadvantages:''' | |||
:*Requires the use of an attachment point. (Note that deformers can be part of a linkset, so this can be mitigated somewhat, but regardless this still represents an increase to Avatar Complexity). | |||
:*Cannot be controlled by script. Only the user can control when a rigged mesh deformer is activated, by either attaching or detaching the item containing the deformer. | |||
{{KBnote | The below description uses nomenclature that may be specific to Blender, so your modelling program of choice may use different terminology, however the general process should be the same.}} | |||
Start with the [[Project Bento Resources and Information#Models_.26_Skeleton_Files_.2F_Test_Content | Bento reference skeleton]]. | |||
{{KBcaution | Make sure that the skeleton is orientated in such a way that the +X axis is forward, and the +Z axis is up. Make sure to apply any and all transforms you make before continuing.}} | |||
Create an object (e.g. a cube), and weight it to the bone(s) to be deformed. | |||
{{KBcaution | If you move the mesh, ensure to apply any transforms you make to avoid bugs. '''If you wish to do so, move the mesh now, as doing so later may cause unintended deformations.'''}} | |||
{{KBnote| Blender users: When parenting your new mesh to the armature (SL avatar skeleton), ensure to parent to '''Armature Deform''' ONLY. This is because any other method will include weight groups for all bones in the armature, which exceeds the skinned mesh bone limit.}} | |||
Move the bone. | Move the bone. | ||
Line 120: | Line 152: | ||
Apply the transform as the rest pose. | Apply the transform as the rest pose. | ||
Export DAE, making sure that all the appropriate settings are correct for export to SL. | Export to DAE, making sure that all the {{HoverText|appropriate settings are correct|🗸 Selection Only 🗸 Include Armatures 🗸 Export to SL / OpenSim ✗ Include Animation}} for export to SL. | ||
Go to the mesh model uploader in SL - select your model, and make sure to check "Include Joint Positions" under the Rigging tab. | Go to the mesh model uploader in SL - select your model, and make sure to check "Include Joint Positions" under the Rigging tab. | ||
Verify that the joints in question have received deforms, by checking if a numerical value has been provided under "Joint Position overrides for [bone]". | Verify that the joints in question have received deforms, by checking if a numerical value has been provided under "Joint Position overrides for [bone]". |
Latest revision as of 09:02, 16 December 2022
Warning: Choose the bones that you deform wisely, as you can inadvertently mess up a user's shape until they relog, and even the viewer's 'Undeform Avatar' feature will not fix this. See the Avoiding Bugs section below. |
Avoiding bugs
Deformers in Second Life are essentially manipulating the positions of bones within an avatar's skeleton. While this is generally fairly safe, the position of some bones is affected by the shape sliders, meaning any deformations applied to these bones will invalidate the user's shape and cannot be reset by either the deformer's creator (via another 'undeform' deformer), or the user themselves (via the viewer's 'Undeform Avatar' feature), and will only be reset when the user relogs when the deformer has been disabled or detached.
As such, any bones that have their positions influenced by the shape sliders should not be deformed if it can be avoided.
Note that you can deform the child of a bone affected by the shape sliders safely, just not that bone directly.
For a full list of which bones with positions affected by the shape sliders, visit the Project Bento Skeleton Guide page.
If you need to make deformations to a bone affected by the shape sliders, Method 2 is the safer way to perform the deformation.
Methods
In Second Life, there are 2 ways you can deform an avatar, each with advantages and disadvantages:
- By using an animation: This is generally the preferred way to do deformations, as should something go wrong, it's much easier for the user to debug and recover from.
- By using rigged mesh: Second Life allows you to upload rigged mesh with associated joint positions - This means that when an avatar equips a rigged mesh object that contains joint positions, their avatar will deform to meet the given positions.
Method 1: Animation
Advantages:
- Animations are generally easier for users to debug if something has gone awry, and the user can opt to force stop animations and undeform their avatar if needed.
- Animations can be triggered by scripts, therefore you can have a deformer be activated based on an action the avatar has taken, increasing immersiveness.
- Animations have a variable 'Ease In' time, meaning you can use a single animation to represent a change that happens over time. (E.g. an avatar eating a large burger, with a deformer and a long ease-in time to make their belly grow as they're eating)
- Deformations applied through animations are persistent, meaning that the deformation will remain even after the animation is stopped.*
Disadvantages:
- When applying deformations to collision volumes, this will disable any effect that Avatar Physics may have on this bone.
- Deformations applied through animations are persistent, meaning that the deformation will remain even after the animation is stopped.*
Warning! | |
The below instructions as part of this method are out-of-date, overcomplicated and 'unsafe'. These will be replaced when time allows. |
Taken from a Forum Post by Erluen Twin...
There seemed to be a need for a tutorial here, since I searched for this info and it was hard to find and piece together. I hope it hasnt been done already! This is how to stretch or shrink your avatar using animation files. This is most useful for making non-human avatars like dragons which have their shins much longer than their thighs, and their necks of course are in a very inconvenient place for a human avatar! Please correct me if Im wrong, but heres what I know:
To start, go to this page: [1] and download the zipped .bvh files. Open them as a TEXT DOCUMENT and have a look. Note especially the difference between TinyDeformForearmr and UnDeformForearmr. ("forearmr" means "right forearm")
The things to change are at the TOP and BOTTOM of the text file. The middle stuff should not be changed. At the top it says
>>.....HIERARCHY >>.....ROOT rForeArm >>.....{ >>............etc
You need to change the ROOT to whichever body joint you want to affect. ROOT rForearm will move the right elbow joint. It actually stretches the length of the upper arm. ROOT rHand will move the wrist join and will lengthen the forearm. Try to keep this in mind not to get confused!! You can't stretch the hand itself because there is no joint at the tips of the fingers, obviously.
Another way to keep it straight is to think of ROOT forearm as you grabbing the forearm with both hands and pulling it away from the body. the forearm wont stretch because your holding it, but the upper arm will stretch like rubber.
STEP 1: At ROOT lWhatever, delete "lWhatever" and type in "rForearm"
..................(eg ROOT rForeArm, ROOT Head, ROOT Chest) be careful of ..................capital letters.
STEP 2:'At the bottom, youll see this:
>> } >> MOTION >> Frames: 2 >> Frame Time: 0.033333 >> 0.000000 43.528519 0.000000 0.000000 0.000000 0.000000 0.000000 >> -0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 >> 0 >> 0 >> 0
Look at the 2nd row of numbers you.
-0.075000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ...first x....second y....third z ..\nevermind the rest of these zeros/
The first 3 numbers are the x, y, z coordinates, as far as I can tell.
So, the position of joint in space relative to parent joint is:
x -0.075000 (length/shorten - this is pretty short, almost 0 for tiny AV.) y 0.000000 (to the side of AV) z 0.000000 (forward of back of AV)
I THINK that if you decrease the x value, (make it a more negative number) the right limb will stretch, but you should test it. This is for the RIGHT arm and RIGHT leg only. For the LEFT arm and leg, IN-creasing the x value (more positive) will stretch the arm.
Always compare it to the UnDeform file. The unDeform files have the "normal" values for an avatar.
NORMAL values for Av:
Right side : neg value (eg -10.2 for right forearm) Left side : pos value (eg 10.2 for right forearm)
In layman's terms, the elbow is 10 units away from the shoulder. On the left side, its in the LEFT direction which is positive. On the RIGHT side it's 10 units in the right direction which is negative. One unit might be 1 inch, but it seems different for every body part so dont take it as a rule.
Side note: For some reason, the left forearm has 3 lines of numbers I assume the 3rd line is the one to change, since it has anx value of 10.12 - similar to right ForeArm
Now, for the right arm, making it more negative than the "Normal value" will stretch it. Since the Normal Value is -10.266 (10 units of length going right) , lets change that to -60.00. (60 units of length going right)
- Save the file as Deform_Right_Forearm.bvh (not .txt).
- Go into SL.
- Upload animation Deform_Right_Forearm.bvh
- Find it in inventory
- Play animation.
Viola - your right upper arm should be longer. about 6 times longer I think.
Stop Animation. Your arm will still be long. There are 2 ways to Normalize it.
- Upload UnDeformrForearm.bvh and play it.
- Relog.
Now you can deform any body part! There are 17 joints in all, so to deform every single aspect of your AV, you will need 17 animations.
I have a touch start script (with llRequestPermissions of course) which plays each animation in turn automatically. I have my deform button to contort me into a demonic bat-like creature, and an undeform button to go back to normal. It works very nicely.
One last hint: To save a few Lindens on uploading 100s of test animations, when you login to SL, press CTRL SHFT G. (or is it CTRL ALT G??) to get a pulldown menu of Grids. Then choose the 2nd grid Aditi where you can beta test all your animations for free. When you find the one perfect animation, you can log into SL proper (Grid named Agni) and upload for 10 lindens.
Now go deform yourself!!
Method 2: Rigged Mesh
Advantages:
- When applying deformations to collision volumes, this method does not disable the effect of Avatar Physics may have on this bone.
- Deformations applied through Rigged Mesh are always temporary, and will be automatically reset when the item containing the deformer is detached.
- If needed, the influence of shape sliders on a bone can be locked out altogether by enabling "Lock scale if joint position is defined" in the mesh uploader.
Disadvantages:
- Requires the use of an attachment point. (Note that deformers can be part of a linkset, so this can be mitigated somewhat, but regardless this still represents an increase to Avatar Complexity).
- Cannot be controlled by script. Only the user can control when a rigged mesh deformer is activated, by either attaching or detaching the item containing the deformer.
Note: The below description uses nomenclature that may be specific to Blender, so your modelling program of choice may use different terminology, however the general process should be the same. |
Start with the Bento reference skeleton.
Important: Make sure that the skeleton is orientated in such a way that the +X axis is forward, and the +Z axis is up. Make sure to apply any and all transforms you make before continuing. |
Create an object (e.g. a cube), and weight it to the bone(s) to be deformed.
Important: If you move the mesh, ensure to apply any transforms you make to avoid bugs. If you wish to do so, move the mesh now, as doing so later may cause unintended deformations. |
Note: Blender users: When parenting your new mesh to the armature (SL avatar skeleton), ensure to parent to Armature Deform ONLY. This is because any other method will include weight groups for all bones in the armature, which exceeds the skinned mesh bone limit. |
Move the bone.
Apply the transform as the rest pose.
Export to DAE, making sure that all the appropriate settings are correct for export to SL.
Go to the mesh model uploader in SL - select your model, and make sure to check "Include Joint Positions" under the Rigging tab.
Verify that the joints in question have received deforms, by checking if a numerical value has been provided under "Joint Position overrides for [bone]".