/// <summary> /// Replace an exiting bone with the passed one /// </summary> /// <param name="grps">List of all Imported Groups (needed to fix the UseBone Indices)</param> /// <param name="bns">List of all Bones</param> /// <param name="b"></param> /// <param name="index">The Number of the Bone that should be added</param> /// <returns>the real Bone Index</returns> protected virtual int ReplaceBone(ImportedGroups grps, ImportedBones bns, ImportedBone b, int index) { int nindex = b.TargetIndex; gmdc.Joints[nindex] = b.Bone; VectorTransformation t = new VectorTransformation(VectorTransformation.TransformOrder.RotateTranslate); gmdc.Model.Transformations[nindex] = t; //Change the TransformNode for the New Bone if (Options.UpdateCres) { if (gmdc.ParentResourceNode != null) { TransformNode tn = gmdc.Joints[nindex].AssignedTransformNode; tn.ObjectGraphNode.FileName = b.ImportedName; if (tn != null) { tn.Transformation = b.Transformation.Clone(); } } } return(nindex); }
/// <summary> /// Add the passed Bone to the Gmdc and Fix the UseBone Indices to apropriate Values /// </summary> /// <param name="grps">List of all Imported Groups (needed to fix the UseBone Indices)</param> /// <param name="bns">List of all Bones</param> /// <param name="b"></param> /// <param name="index">The Number of the Bone that should be added</param> /// <returns>the real Bone Index</returns> protected virtual int AddBone(ImportedGroups grps, ImportedBones bns, ImportedBone b, int index) { int nindex = gmdc.Joints.Length; gmdc.Joints.Add(b.Bone); VectorTransformation t = new VectorTransformation(VectorTransformation.TransformOrder.RotateTranslate); gmdc.Model.Transformations.Add(t); //Create a TransformNode for the New Bone if (Options.UpdateCres) { if ((gmdc.ParentResourceNode != null) && (IsLocalCres())) { TransformNode tn = new TransformNode(gmdc.ParentResourceNode.Parent); tn.ObjectGraphNode.FileName = b.ImportedName; tn.Transformation = b.Transformation.Clone(); tn.JointReference = nindex; gmdc.ParentResourceNode.Parent.Blocks = (SimPe.Interfaces.Scenegraph.IRcolBlock[])Helper.Add( gmdc.ParentResourceNode.Parent.Blocks, tn, typeof(SimPe.Interfaces.Scenegraph.IRcolBlock) ); } } return(nindex); }
/// <summary> /// Create a new Instance /// </summary> /// <param name="parent">The gmdc that should act as Parent</param> public ImportedBone(GeometryDataContainer parent) { bone = new GmdcJoint(parent); name = ""; parentname = ""; index = -1; action = GmdcImporterAction.Add; sourcepos = new VectorTransformation(SimPe.Geometry.VectorTransformation.TransformOrder.TranslateRotate); scale = (float)(1.0); }
public override void Dispose() { if (this.tTransformNode != null) { this.tTransformNode.Dispose(); } tTransformNode = null; ctn = null; ogn = null; items = null; trans = null; }
/// <summary> /// Constructor /// </summary> public TransformNode(Rcol parent) : base(parent) { ctn = new CompositionTreeNode(parent); ogn = new ObjectGraphNode(parent); items = new TransformNodeItems(); trans = new VectorTransformation(VectorTransformation.TransformOrder.TranslateRotate); version = 0x07; BlockID = 0x65246462; unknown = NO_JOINT; }
/// <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> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> public void Unserialize(System.IO.BinaryReader reader) { int count = reader.ReadInt32(); transforms.Clear(); for (int i = 0; i < count; i++) { VectorTransformation t = new VectorTransformation(VectorTransformation.TransformOrder.RotateTranslate); t.Unserialize(reader); transforms.Add(t); } count = reader.ReadInt32(); names.Clear(); for (int i = 0; i < count; i++) { GmdcNamePair p = new GmdcNamePair(); p.Unserialize(reader); names.Add(p); } subset.Unserialize(reader); }
/// <summary> /// Gets the transformed axis side vector, i.e. the vector that points out of the plane of the axis side. /// </summary> /// <param name="id">The axis identifier.</param> /// <param name="side">The side identifier.</param> /// <returns>The vector corresponding to the axis side.</returns> /// <exception cref="System.NotImplementedException"> /// </exception> private VectorD3D GetTransformedAxisSideVector(CSLineID id, CSAxisSide side) { return(VectorTransformation.Transform(GetUntransformedAxisSideVector(id, side))); }
/// <summary> /// Gets the axis line vector. This is a vector pointing from the origin to the axis line, when the layer is assumed to be a square of 2x2x2 size, centered at the origin. /// Thus the returned vector has one member set to zero, and the other two members set either to +1 or -1. /// </summary> /// <param name="id">The identifier.</param> /// <returns>Axis line vector (transformed, thus taking into account the properties for reversing and exchanging of axes).</returns> public VectorD3D GetTransformedAxisLineVector(CSLineID id) { return(VectorTransformation.Transform(GetUntransformedAxisLineVector(id))); }