diff --git a/OpenSim/Region/Framework/Scenes/AvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs similarity index 98% rename from OpenSim/Region/Framework/Scenes/AvatarAnimations.cs rename to OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs index 72d599aa49..659c3a5c54 100644 --- a/OpenSim/Region/Framework/Scenes/AvatarAnimations.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs @@ -29,7 +29,7 @@ using System.Collections.Generic; using System.Xml; using OpenMetaverse; -namespace OpenSim.Region.Framework.Scenes +namespace OpenSim.Region.Framework.Scenes.Animation { public class AvatarAnimations { diff --git a/OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs similarity index 99% rename from OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs rename to OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs index 5f2eb0df1e..3afc87f4d4 100644 --- a/OpenSim/Region/Framework/Scenes/BinBVHAnimation.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs @@ -29,7 +29,7 @@ using System; using System.IO; using OpenMetaverse; -namespace OpenSim.Region.Framework.Scenes +namespace OpenSim.Region.Framework.Scenes.Animation { /// /// Written to decode and encode a binary animation asset. diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index d22e24a14f..cbe4118fd3 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -331,6 +332,65 @@ namespace OpenSim.Region.Framework.Scenes.Animation UUID[] objectIDs; m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); return animIDs; + } + + public BinBVHAnimation GenerateRandomAnimation() + { + int rnditerations = 3; + BinBVHAnimation anim = new BinBVHAnimation(); + List parts = new List(); + parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso"); + parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft"); + parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck"); + parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight"); + parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight"); + parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight"); + parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft"); + anim.HandPose = 1; + anim.InPoint = 0; + anim.OutPoint = (rnditerations * .10f); + anim.Priority = 7; + anim.Loop = false; + anim.Length = (rnditerations * .10f); + anim.ExpressionName = "afraid"; + anim.EaseInTime = 0; + anim.EaseOutTime = 0; + + string[] strjoints = parts.ToArray(); + anim.Joints = new binBVHJoint[strjoints.Length]; + for (int j = 0; j < strjoints.Length; j++) + { + anim.Joints[j] = new binBVHJoint(); + anim.Joints[j].Name = strjoints[j]; + anim.Joints[j].Priority = 7; + anim.Joints[j].positionkeys = new binBVHJointKey[rnditerations]; + anim.Joints[j].rotationkeys = new binBVHJointKey[rnditerations]; + Random rnd = new Random(); + for (int i = 0; i < rnditerations; i++) + { + anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); + anim.Joints[j].rotationkeys[i].time = (i*.10f); + anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1); + anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1); + anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1); + anim.Joints[j].positionkeys[i] = new binBVHJointKey(); + anim.Joints[j].positionkeys[i].time = (i*.10f); + anim.Joints[j].positionkeys[i].key_element.X = 0; + anim.Joints[j].positionkeys[i].key_element.Y = 0; + anim.Joints[j].positionkeys[i].key_element.Z = 0; + } + } + + AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); + Animasset.Data = anim.ToBytes(); + Animasset.Temporary = true; + Animasset.Local = true; + Animasset.Description = "dance"; + //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); + + m_scenePresence.Scene.AssetService.Store(Animasset); + AddAnimation(Animasset.FullID, m_scenePresence.UUID); + return anim; } /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 33c1932803..1917ec4632 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1871,65 +1871,6 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor.SetAlwaysRun = pSetAlwaysRun; } } - - public BinBVHAnimation GenerateRandomAnimation() - { - int rnditerations = 3; - BinBVHAnimation anim = new BinBVHAnimation(); - List parts = new List(); - parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso"); - parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft"); - parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck"); - parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight"); - parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight"); - parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight"); - parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft"); - anim.HandPose = 1; - anim.InPoint = 0; - anim.OutPoint = (rnditerations * .10f); - anim.Priority = 7; - anim.Loop = false; - anim.Length = (rnditerations * .10f); - anim.ExpressionName = "afraid"; - anim.EaseInTime = 0; - anim.EaseOutTime = 0; - - string[] strjoints = parts.ToArray(); - anim.Joints = new binBVHJoint[strjoints.Length]; - for (int j = 0; j < strjoints.Length; j++) - { - anim.Joints[j] = new binBVHJoint(); - anim.Joints[j].Name = strjoints[j]; - anim.Joints[j].Priority = 7; - anim.Joints[j].positionkeys = new binBVHJointKey[rnditerations]; - anim.Joints[j].rotationkeys = new binBVHJointKey[rnditerations]; - Random rnd = new Random(); - for (int i = 0; i < rnditerations; i++) - { - anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); - anim.Joints[j].rotationkeys[i].time = (i*.10f); - anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1); - anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1); - anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1); - anim.Joints[j].positionkeys[i] = new binBVHJointKey(); - anim.Joints[j].positionkeys[i].time = (i*.10f); - anim.Joints[j].positionkeys[i].key_element.X = 0; - anim.Joints[j].positionkeys[i].key_element.Y = 0; - anim.Joints[j].positionkeys[i].key_element.Z = 0; - } - } - - AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); - Animasset.Data = anim.ToBytes(); - Animasset.Temporary = true; - Animasset.Local = true; - Animasset.Description = "dance"; - //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); - - m_scene.AssetService.Store(Animasset); - Animator.AddAnimation(Animasset.FullID, UUID); - return anim; - } public void HandleStartAnim(IClientAPI remoteClient, UUID animID) {