/// <summary> /// Applies the initial Joint Transformation to the passed Vertex /// </summary> /// <param name="index">Index of the current Joint withi itÄs parent</param> /// <param name="v">The Vertex you want to Transform</param> /// <returns>Transformed Vertex</returns> protected Vector3f Transform(int index, Vector3f v) { //no Parent -> no Transform if (parent == null) { return(v); } //Hashtable map = parent.LoadJointRelationMap(); //TransformNode tn = AssignedTransformNode(index); //Get the Transformation Hirarchy VectorTransformations t = new VectorTransformations(); t.Add(parent.Model.Transformations[index]); /* * while (index>=0) * { * t.Add(parent.Model.Transformations[index]); * if (map.ContainsKey(index)) index = (int)map[index]; * else index = -1; * }*/ //Apply Transformations for (int i = t.Count - 1; i >= 0; i--) { v = t[i].Transform(v); } return(v); }
/// <summary> /// Walks the parent Hirarchy to calculate the absolute POsition for thsi Bone /// </summary> /// <param name="bs">List of known Bones</param> /// <param name="b">The bone you want o get the Absolute position for</param> /// <param name="v">The offset for the calculation</param> /// <param name="eo">ElementOrder we want to use</param> VectorTransformations GetAbsoluteTransformation(ICresChildren node, VectorTransformations v) { if (v == null) { v = new VectorTransformations(); } if (node == null) { return(v); } if (node.StoredTransformNode == null) { return(v); } if (seenbones.Contains(node.Index)) { return(v); } seenbones.Add(node.Index); /*v.Rotation = node.StoredTransformNode.Rotation * v.Rotation; * v.Rotation.MakeUnitQuaternion(); * * v.Translation = * node.StoredTransformNode.Rotation.Rotate(v.Translation + node.StoredTransformNode.Translation); */ v.Add(node.StoredTransformNode.Transformation); v = GetAbsoluteTransformation(node.GetFirstParent(), v); return(v); }
/// <summary> /// Returns the effective Transformation, that is described by the CresHirarchy /// </summary> /// <returns></returns> public VectorTransformation GetEffectiveTransformation() { VectorTransformations list = GetHirarchyTransformations(); VectorTransformation v = new VectorTransformation(); #if DEBUG System.IO.StreamWriter sw = System.IO.File.CreateText(@"G:\effect.txt"); #endif try { #if DEBUG sw.WriteLine("-----------------------------------"); sw.WriteLine(" " + v.ToString()); #endif VectorTransformation l = null; for (int i = list.Length - 1; i >= 0; i--) { VectorTransformation t = list[i]; t.Rotation.MakeUnitQuaternion(); v.Rotation = v.Rotation * t.Rotation; v.Translation = t.Rotation.Rotate((v.Translation)) - t.Rotation.Rotate((t.Translation)); //v.Rotation.MakeUnitQuaternion(); #if DEBUG sw.WriteLine("++++" + t.ToString() + " " + t.Name); sw.WriteLine(" " + v.ToString()); #endif l = t; } } finally { #if DEBUG sw.Close(); sw.Dispose(); sw = null; #endif } return(v); }
/// <summary> /// Constructor /// </summary> public GmdcModel(GeometryDataContainer parent) : base(parent) { transforms = new VectorTransformations(); names = new GmdcNamePairs(); subset = new GmdcJoint(parent); }