OSDN Git Service

Correctly apply multiple morphs with same id (on different meshes), correct bone...
authorRobin Cornelius <robin.cornelius@gmail.com>
Sun, 18 Mar 2012 17:37:05 +0000 (17:37 +0000)
committerRobin Cornelius <robin.cornelius@gmail.com>
Sun, 18 Mar 2012 17:37:05 +0000 (17:37 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@1213 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Rendering/RenderAvatar.cs
Radegast/GUI/Rendering/RenderSettings.cs
Radegast/GUI/Rendering/Rendering.cs

index c4f4981..68ac5f2 100644 (file)
@@ -678,15 +678,28 @@ namespace Radegast.Rendering
             }
 
             lindenMeshesLoaded = true;
-        }
+        }\r
+\r
\r
 
         public void applyMorph(Avatar av, int param, float weight)
-        {
+        {\r
             VisualParamEx vpx;
+
             if (VisualParamEx.allParams.TryGetValue(param, out vpx))
-            {
+            {\r
+                applyMorph(vpx, av, param, weight);\r
+\r
+                foreach (VisualParamEx cvpx in vpx.identicalIds)\r
+                {\r
+                    applyMorph(vpx, av, param, weight);\r
+                }
+            }
+        }
+
+        public void applyMorph(VisualParamEx vpx, Avatar av, int param, float weight)\r
+        {\r
 
-             
                 if (weight < 0)
                     weight = 0;
 
@@ -711,7 +724,7 @@ namespace Radegast.Rendering
                                 if (mesh.Name == "skirtMesh" && _showSkirt == false)
                                     return;
 
-                                mesh.morphmesh(morph, weight);
+                                mesh.morphmesh(morph, value);
 
                                 continue;
                             }
@@ -756,12 +769,12 @@ namespace Radegast.Rendering
                     {
                         //  scale="0 0 .3" />
                         //   value_min="-1"
-                        // value_max="1"
-
+                        // value_max="1"\r
+                      
                         foreach (KeyValuePair<string, BoneDeform> kvp in vpx.BoneDeforms)
-                        {
-                            skel.scalebone(kvp.Key, Vector3.One + (kvp.Value.scale *value));
-                            skel.offsetbone(kvp.Key, kvp.Value.offset * value);
+                        {\r
+                            skel.scalebone(kvp.Key, Vector3.One + (kvp.Value.scale * value));
+                          //  skel.offsetbone(kvp.Key, kvp.Value.offset * value);
                         }
                         return;
                     }
@@ -771,11 +784,7 @@ namespace Radegast.Rendering
                     }
                 }
 
-            }
-            else
-            {
-                Logger.Log("Invalid paramater " + param.ToString(), Helpers.LogLevel.Warning);
-            }
+
         }
 
         public void morph(Avatar av)
@@ -808,7 +817,9 @@ namespace Radegast.Rendering
                     foreach (GLMesh mesh in _meshes.Values)
                     {
                       mesh.resetallmorphs();
-                    }
+                    }\r
+\r
+                    skel.resetbonescales();
 
                     foreach (byte vpvalue in av.VisualParameters)
                     {
@@ -902,8 +913,6 @@ namespace Radegast.Rendering
         public skeleton()
         {
 
-
-
             mBones = new Dictionary<string, Bone>();
 
             foreach (Bone src in Bone.mBones.Values)
@@ -960,6 +969,14 @@ namespace Radegast.Rendering
             mLeftEye = mBones["mEyeLeft"];
             mRightEye = mBones["mEyeRight"];
 
+        }\r
+\r
+        public void resetbonescales()\r
+        {\r
+            foreach (KeyValuePair<string,Bone> src in mBones)\r
+            {\r
+                src.Value.scale = new Vector3(1, 1, 1);\r
+            }\r
         }
 
         public void deformbone(string name, Vector3 pos, Quaternion rotation)
@@ -973,9 +990,11 @@ namespace Radegast.Rendering
 
         public void scalebone(string name, Vector3 scale)
         {
+
             Bone bone;
             if (mBones.TryGetValue(name, out bone))
-            {
+            {\r
+                Logger.Log(String.Format("scalebone() {0} {1}", name, scale.ToString()),Helpers.LogLevel.Info);
                 bone.scalebone(scale);
             }
         }
@@ -1421,8 +1440,8 @@ namespace Radegast.Rendering
 
         public void scalebone(Vector3 scale)
         {
-            //this.scale = Bone.mBones[name].orig_scale + scale;
-            this.scale = scale;
+         //  this.scale = Bone.mBones[name].orig_scale * scale;
+            this.scale *= scale;
             markdirty();
         }
 
@@ -1461,7 +1480,7 @@ namespace Radegast.Rendering
             {
                 Quaternion totalrot = getParentRot(); // we don't want this joints rotation included
                 Vector3 parento = parent.getOffset();
-                mTotalPos = parento + pos * scale * totalrot;
+                mTotalPos = parento + pos * parent.scale * totalrot;
                 Vector3 orig = getOrigOffset();
                 mDeltaPos = mTotalPos - orig;
 
@@ -1472,7 +1491,8 @@ namespace Radegast.Rendering
             else
             {
                 Vector3 orig = getOrigOffset();
-                mTotalPos = (pos * scale)+offset_pos;
+                //mTotalPos = (pos * scale)+offset_pos;\r
+                mTotalPos = (pos) + offset_pos;
                 mDeltaPos = mTotalPos - orig;
                 posdirty = false;
                 return mTotalPos;
@@ -1595,13 +1615,20 @@ namespace Radegast.Rendering
 
         static public Dictionary<int, VisualParamEx> allParams = new Dictionary<int, VisualParamEx>();
         static public Dictionary<int, VisualParamEx> deformParams = new Dictionary<int, VisualParamEx>();
-        static public Dictionary<int, VisualParamEx> morphParams = new Dictionary<int, VisualParamEx>();
+       
+        //static public Dictionary<int, VisualParamEx> morphParams = new Dictionary<int, VisualParamEx>();\r
+\r
+        //dirty use of string as indexer, we need to have an enum for meshes\r
+        static public Dictionary<string,Dictionary<int, VisualParamEx>> morphParams = new  Dictionary<string,Dictionary<int, VisualParamEx>>();
+
         static public Dictionary<int, VisualParamEx> drivenParams = new Dictionary<int, VisualParamEx>();
         static public SortedList tweakable_params = new SortedList();
 
         public Dictionary<string, BoneDeform> BoneDeforms = null;
         public Dictionary<string, VolumeDeform> VolumeDeforms = null;
-        public List<driven> childparams = null;
+        public List<driven> childparams = null;\r
+\r
+        public List<VisualParamEx> identicalIds = new List<VisualParamEx>();
 
         public string morphmesh = null;
 
@@ -1773,15 +1800,17 @@ namespace Radegast.Rendering
 
             //TODO other paramaters but these arew concerned with editing the GUI display so not too fussed at the moment
 
-            try
-            {
-                allParams.Add(ParamID, this);
+            if(allParams.ContainsKey(ParamID))
+            {\r
+                //Logger.Log("Duplicate VisualParam in allParams id " + ParamID.ToString(), Helpers.LogLevel.Info);\r
+                allParams[ParamID].identicalIds.Add(this);
             }
-            catch
+            else
             {
-                Logger.Log("Duplicate VisualParam in allParams id " + ParamID.ToString(), Helpers.LogLevel.Info);
+                allParams.Add(ParamID, this);
             }
 
+
             if (pt == ParamType.TYPE_BONEDEFORM)
             {
                 // If we are in the skeleton section then we also have bone deforms to parse
@@ -1801,14 +1830,23 @@ namespace Radegast.Rendering
                     ParseVolumeDeforms(node.ChildNodes[0].ChildNodes);
                 }
 
+                /*
                 try
-                {
-                    morphParams.Add(ParamID, this);
+                {\r
+                    if (!morphParams.ContainsKey(meshname))\r
+                    {\r
+                        morphParams.Add(meshname, new Dictionary<int, VisualParamEx>());\r
+                    }\r
+                    else\r
+                    {\r
+                        morphParams[meshname].Add(ParamID, this);\r
+                    }
                 }
                 catch
                 {
                     Logger.Log("Duplicate VisualParam in morphParams id " + ParamID.ToString(), Helpers.LogLevel.Info);
                 }
+                */
 
             }
 
index 30e4b59..f2451e4 100644 (file)
@@ -1,94 +1,94 @@
-// 
-// Radegast Metaverse Client
-// Copyright (c) 2009-2012, Radegast Development Team
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// 
-//     * Redistributions of source code must retain the above copyright notice,
-//       this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above copyright
-//       notice, this list of conditions and the following disclaimer in the
-//       documentation and/or other materials provided with the distribution.
-//     * Neither the name of the application "Radegast", nor the names of its
-//       contributors may be used to endorse or promote products derived from
-//       this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// $Id$
-//
-
-using System;
-using OpenMetaverse;
-using OpenMetaverse.Rendering;
-
-namespace Radegast.Rendering
-{
-    public static class RenderSettings
-    {
-        #region VBO support
-        public static bool UseVBO;
-        public static bool CoreVBOPresent;
-        public static bool ARBVBOPresent;
-        #endregion VBO support
-
-        #region Occlusion queries
-        /// <summary>Should we try to optimize by not drawing objects occluded behind other objects</summary>
-        public static bool OcclusionCullingEnabled;
-        public static bool CoreQuerySupported;
-        public static bool ARBQuerySupported;
-        #endregion Occlusion queries
-
-        public static bool HasMultiTexturing;
-        public static bool UseFBO;
-        public static bool HasMipmap;
-        public static bool HasShaders;
-        public static DetailLevel PrimRenderDetail = DetailLevel.High;
-        public static DetailLevel SculptRenderDetail = DetailLevel.High;
-        public static DetailLevel MeshRenderDetail = DetailLevel.Highest;
-        public static bool AllowQuickAndDirtyMeshing = true;
-        public static int MeshesPerFrame = 2;
-        public static int TexturesToDownloadPerFrame = 2;
-        /// <summary>Should we try to make sure that large prims that are > our draw distance are in view when we are standing on them</summary>
-        public static bool HeavierDistanceChecking = true;
-        /// <summary>Minimum time between rebuilding terrain mesh and texture</summary>
-        public static float MinimumTimeBetweenTerrainUpdated = 15f;
-        /// <summary>Are textures that don't have dimensions that are powers of two supported</summary>
-        public static bool TextureNonPowerOfTwoSupported;
-
-        /// <summary>
-        /// Render avatars
-        /// </summary>
-        public static bool AvatarRenderingEnabled = true;
-
-        /// <summary>
-        /// Render prims
-        /// </summary>
-        public static bool PrimitiveRenderingEnabled = true;
-
-        /// <summary>
-        /// Show avatar skeloton
-        /// </summary>
-        public static bool RenderAvatarSkeleton = false;
-
-        /// <summary>
-        /// Enable shader for shiny
-        /// </summary>
-        public static bool EnableShiny = false;
-
-        #region Water
-        public static bool WaterReflections = false;
-        #endregion Water
-    }
-}
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009-2012, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//     * Redistributions of source code must retain the above copyright notice,\r
+//       this list of conditions and the following disclaimer.\r
+//     * Redistributions in binary form must reproduce the above copyright\r
+//       notice, this list of conditions and the following disclaimer in the\r
+//       documentation and/or other materials provided with the distribution.\r
+//     * Neither the name of the application "Radegast", nor the names of its\r
+//       contributors may be used to endorse or promote products derived from\r
+//       this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id$\r
+//\r
+\r
+using System;\r
+using OpenMetaverse;\r
+using OpenMetaverse.Rendering;\r
+\r
+namespace Radegast.Rendering\r
+{\r
+    public static class RenderSettings\r
+    {\r
+        #region VBO support\r
+        public static bool UseVBO;\r
+        public static bool CoreVBOPresent;\r
+        public static bool ARBVBOPresent;\r
+        #endregion VBO support\r
+\r
+        #region Occlusion queries\r
+        /// <summary>Should we try to optimize by not drawing objects occluded behind other objects</summary>\r
+        public static bool OcclusionCullingEnabled;\r
+        public static bool CoreQuerySupported;\r
+        public static bool ARBQuerySupported;\r
+        #endregion Occlusion queries\r
+\r
+        public static bool HasMultiTexturing;\r
+        public static bool UseFBO;\r
+        public static bool HasMipmap;\r
+        public static bool HasShaders;\r
+        public static DetailLevel PrimRenderDetail = DetailLevel.High;\r
+        public static DetailLevel SculptRenderDetail = DetailLevel.High;\r
+        public static DetailLevel MeshRenderDetail = DetailLevel.Highest;\r
+        public static bool AllowQuickAndDirtyMeshing = true;\r
+        public static int MeshesPerFrame = 2;\r
+        public static int TexturesToDownloadPerFrame = 2;\r
+        /// <summary>Should we try to make sure that large prims that are > our draw distance are in view when we are standing on them</summary>\r
+        public static bool HeavierDistanceChecking = true;\r
+        /// <summary>Minimum time between rebuilding terrain mesh and texture</summary>\r
+        public static float MinimumTimeBetweenTerrainUpdated = 15f;\r
+        /// <summary>Are textures that don't have dimensions that are powers of two supported</summary>\r
+        public static bool TextureNonPowerOfTwoSupported;\r
+\r
+        /// <summary>\r
+        /// Render avatars\r
+        /// </summary>\r
+        public static bool AvatarRenderingEnabled = true;\r
+\r
+        /// <summary>\r
+        /// Render prims\r
+        /// </summary>\r
+        public static bool PrimitiveRenderingEnabled = true;\r
+\r
+        /// <summary>\r
+        /// Show avatar skeloton\r
+        /// </summary>\r
+        public static bool RenderAvatarSkeleton = true;\r
+\r
+        /// <summary>\r
+        /// Enable shader for shiny\r
+        /// </summary>\r
+        public static bool EnableShiny = false;\r
+\r
+        #region Water\r
+        public static bool WaterReflections = false;\r
+        #endregion Water\r
+    }\r
+}\r
index eb91d31..e817c90 100644 (file)
@@ -1193,10 +1193,11 @@ namespace Radegast.Rendering
                 return;\r
             }\r
 \r
-            foreach (VisualParamEx vpe in VisualParamEx.morphParams.Values)\r
-            {\r
-                comboBox_morph.Items.Add(vpe.Name);\r
-            }\r
+            //FIX ME\r
+            //foreach (VisualParamEx vpe in VisualParamEx.morphParams.Values)\r
+            //{\r
+            //    comboBox_morph.Items.Add(vpe.Name);\r
+            //}\r
 \r
             foreach (VisualParamEx vpe in VisualParamEx.drivenParams.Values)\r
             {\r
@@ -1642,6 +1643,7 @@ namespace Radegast.Rendering
                     Vector3 pos = av.avatar.Position;\r
 \r
                     Vector3 avataroffset = av.glavatar.skel.getOffset("mPelvis");\r
+                    avataroffset.X += 1.0f;\r
 \r
                     GL.MultMatrix(Math3D.CreateSRTMatrix(new Vector3(1, 1, 1), av.RenderRotation, av.RenderPosition - avataroffset * av.RenderRotation));\r
 \r
@@ -3521,15 +3523,17 @@ namespace Radegast.Rendering
             foreach (RenderAvatar av in Avatars.Values)\r
             {\r
                 int id = -1;\r
-                foreach (VisualParamEx vpe in VisualParamEx.morphParams.Values)\r
-                {\r
-                    if (vpe.Name == comboBox_morph.Text)\r
-                    {\r
-                        id = vpe.ParamID;\r
-                        break;\r
-                    }\r
+                \r
+                //foreach (VisualParamEx vpe in VisualParamEx.morphParams.Values)\r
+                //{\r
+                //    if (vpe.Name == comboBox_morph.Text)\r
+                //    {\r
+                //        id = vpe.ParamID;\r
+                //        break;\r
+                //    }\r
+                //\r
+                //}\r
 \r
-                }\r
                 av.glavatar.applyMorph(av.avatar, id, float.Parse(textBox_morphamount.Text));\r
 \r
                 foreach (GLMesh mesh in av.glavatar._meshes.Values)\r