private Vector3 getJointPos(Canguro.Model.Joint j, float[,] displacements, float scalefactor) { if (displacements == null) { return(j.Position); } else { int id = (int)j.Id; Vector3 deformation = new Vector3(displacements[id, 0], displacements[id, 1], displacements[id, 2]); return(j.Position + Vector3.Scale(deformation, scalefactor)); } }
/// <summary> /// This method requests a point and returns a joint. If a joint is found, the method gets it. If not, then creates one and if the created joint lies on a line, /// then the command splits the line and adds the new line to the newLines list. /// </summary> /// <param name="newLines"> List of new lines created by this method while creating new joints </param> /// <returns> The created or found joint </returns> public Model.Joint GetJoint(IList <Model.LineElement> newLines) { Model.Joint joint; Canguro.Controller.Snap.Magnet magnet = GetPoint(); if (magnet == null) { return(null); } if (magnet is Canguro.Controller.Snap.PointMagnet && ((Canguro.Controller.Snap.PointMagnet)magnet).Joint != null) { joint = ((Canguro.Controller.Snap.PointMagnet)magnet).Joint; } else { Microsoft.DirectX.Vector3 v = magnet.SnapPosition; joint = new Canguro.Model.Joint(v.X, v.Y, v.Z); Model.JointList.Add(joint); if (magnet is Canguro.Controller.Snap.PointMagnet) { Canguro.Controller.Snap.PointMagnet pmag = (Canguro.Controller.Snap.PointMagnet)magnet; if (pmag.RelatedMagnets != null && pmag.RelatedMagnets.Count > 0) { for (int i = 0; i < pmag.RelatedMagnets.Count; i++) { if (pmag.RelatedMagnets[i] is Canguro.Controller.Snap.LineMagnet && ((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line != null) { Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line, joint, Model); } } } } else if (magnet is Canguro.Controller.Snap.LineMagnet) { Canguro.Controller.Snap.LineMagnet lmag = (Canguro.Controller.Snap.LineMagnet)magnet; if (lmag.Line != null) { Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)magnet).Line, joint, Model); } } } SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(joint); return(joint); }
public PointMagnet(Canguro.Model.Joint joint) : this(joint.Position, PointMagnetType.EndPoint) { this.joint = joint; }
public PointMagnet(Vector3 pointInternational, PointMagnetType type) : base(pointInternational) { this.type = type; joint = null; }
/// <summary> /// This method requests a point and returns a joint. If a joint is found, the method gets it. If not, then creates one and if the created joint lies on a line, /// then the command splits the line and adds the new line to the newLines list. /// </summary> /// <param name="newLines"> List of new lines created by this method while creating new joints </param> /// <returns> The created or found joint </returns> public Model.Joint GetJoint(IList<Model.LineElement> newLines) { Model.Joint joint; Canguro.Controller.Snap.Magnet magnet = GetPoint(); if (magnet == null) return null; if (magnet is Canguro.Controller.Snap.PointMagnet && ((Canguro.Controller.Snap.PointMagnet)magnet).Joint != null) joint = ((Canguro.Controller.Snap.PointMagnet)magnet).Joint; else { Microsoft.DirectX.Vector3 v = magnet.SnapPosition; joint = new Canguro.Model.Joint(v.X, v.Y, v.Z); Model.JointList.Add(joint); if (magnet is Canguro.Controller.Snap.PointMagnet) { Canguro.Controller.Snap.PointMagnet pmag = (Canguro.Controller.Snap.PointMagnet)magnet; if (pmag.RelatedMagnets != null && pmag.RelatedMagnets.Count > 0) for (int i = 0; i < pmag.RelatedMagnets.Count; i++) if (pmag.RelatedMagnets[i] is Canguro.Controller.Snap.LineMagnet && ((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line != null) Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line, joint, Model); } else if (magnet is Canguro.Controller.Snap.LineMagnet) { Canguro.Controller.Snap.LineMagnet lmag = (Canguro.Controller.Snap.LineMagnet)magnet; if (lmag.Line != null) Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)magnet).Line, joint, Model); } } SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(joint); return joint; }