/// <summary> /// Executes the command. /// Gets a number of segments and divides all selected line elements in equal length segments. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { List <Item> selection = services.GetSelection(); if (selection.Count == 0) { return; } List <LineElement> lineList = new List <LineElement>(); foreach (Item item in selection) { if (item != null && item is LineElement) { lineList.Add((LineElement)item); } } if (lineList.Count == 0) { lineList.Add(services.GetLine()); } int parts = (int)services.GetSingle(Culture.Get("getSplitParts") + " [2-100]"); parts = (parts < 2) ? 2 : (parts > 100) ? 100 : parts; foreach (LineElement line in lineList) { Joint ji = line.I; Joint jj = line.J; Joint last = jj; Microsoft.DirectX.Vector3 v = new Microsoft.DirectX.Vector3(jj.X - ji.X, jj.Y - ji.Y, jj.Z - ji.Z); v.Multiply(1.0f / parts); if (parts > 1 && v.LengthSq() > 0) { LineElement newLine = line; for (int i = 0; i < parts - 1; i++) { jj = new Joint(ji.X + v.X, ji.Y + v.Y, ji.Z + v.Z); services.Model.JointList.Add(jj); newLine = Split(newLine, jj, services.Model); services.Model.LineList.Add(newLine); ji = jj; } } } }
private void TestMagnitude(Vector3 v1, Vector3 v2, DXVec3 dx1, DXVec3 dx2) { Magnitudes = new float[4]; Magnitudes[0] = v1.Magnitude(); Magnitudes[1] = v2.Magnitude(); Magnitudes[2] = dx1.Length(); Magnitudes[3] = dx2.Length(); MagnitudesSq = new float[4]; MagnitudesSq[0] = v1.MagnitudeS(); MagnitudesSq[1] = v2.MagnitudeS(); MagnitudesSq[2] = dx1.LengthSq(); MagnitudesSq[3] = dx2.LengthSq(); }
/// <summary> /// Executes the command. /// Gets a number of segments and divides all selected line elements in equal length segments. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { List<Item> selection = services.GetSelection(); if (selection.Count == 0) return; List<LineElement> lineList = new List<LineElement>(); foreach (Item item in selection) if (item != null && item is LineElement) lineList.Add((LineElement)item); if (lineList.Count == 0) lineList.Add(services.GetLine()); int parts = (int)services.GetSingle(Culture.Get("getSplitParts") + " [2-100]"); parts = (parts < 2) ? 2 : (parts > 100) ? 100 : parts; foreach (LineElement line in lineList) { Joint ji = line.I; Joint jj = line.J; Joint last = jj; Microsoft.DirectX.Vector3 v = new Microsoft.DirectX.Vector3(jj.X - ji.X, jj.Y - ji.Y, jj.Z - ji.Z); v.Multiply(1.0f / parts); if (parts > 1 && v.LengthSq() > 0) { LineElement newLine = line; for (int i = 0; i < parts - 1; i++) { jj = new Joint(ji.X + v.X, ji.Y + v.Y, ji.Z + v.Z); services.Model.JointList.Add(jj); newLine = Split(newLine, jj, services.Model); services.Model.LineList.Add(newLine); ji = jj; } } } }