public DbgPrimWireArrow(string name, Transform location, Color color) { Category = DbgPrimCategory.HkxBone; Transform = location; NameColor = color; Name = name; if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { Vector3 GetPoint(int segmentIndex, float radius, float depth) { float horizontalAngle = (1.0f * segmentIndex / Segments) * MathHelper.TwoPi; float x = (float)Math.Cos(horizontalAngle); float y = (float)Math.Sin(horizontalAngle); return(new Vector3(x * radius, y * radius, depth * Vector3.Forward.Z)); } AddLine(Vector3.Zero, Vector3.Up * OrientingSpinesLength); AddLine(Vector3.Zero, -Vector3.Right * OrientingSpinesLength * 0.5f); Vector3 tip = Vector3.Forward; for (int i = 0; i <= Segments; i++) { var ptBase = GetPoint(i, StemRadius, 0); var ptTipStartInner = GetPoint(i, StemRadius, 1 - TipLength); var ptTipStartOuter = GetPoint(i, TipRadius, 1 - TipLength); AddLine(ptBase, ptTipStartInner, color); AddLine(ptTipStartInner, ptTipStartOuter, color); AddLine(ptTipStartOuter, tip, color); // Connect this vertical spline to the previous one with horizontal lines. if (i > 0) { var prevPtBase = GetPoint(i - 1, StemRadius, 0); var prevPtTipStartInner = GetPoint(i - 1, StemRadius, 1 - TipLength); var prevPtTipStartOuter = GetPoint(i - 1, TipRadius, 1 - TipLength); AddLine(prevPtBase, ptBase, color); AddLine(prevPtTipStartInner, ptTipStartInner, color); AddLine(prevPtTipStartOuter, ptTipStartOuter, color); } } FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimWireCapsule_Middle() { if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { for (int i = 0; i < Segments; i++) { float horizontalAngle = (1.0f * i / Segments) * MathHelper.TwoPi; Vector3 a = new Vector3((float)Math.Cos(horizontalAngle), 0, (float)Math.Sin(horizontalAngle)); Vector3 b = new Vector3(a.X, 1, a.Z); AddLine(a, b, Color.White); } FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimWireBox(Transform location, Vector3 localMin, Vector3 localMax, Color color) { KeepBuffersAlive = true; Transform = location; NameColor = color; OverrideColor = color; LocalMin = localMin; LocalMax = localMax; if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { var min = -Vector3.One; var max = Vector3.One; // 3 Letters of below names: // [T]op/[B]ottom, [F]ront/[B]ack, [L]eft/[R]ight var tfl = new Vector3(min.X, max.Y, max.Z); var tfr = new Vector3(max.X, max.Y, max.Z); var bfr = new Vector3(max.X, min.Y, max.Z); var bfl = new Vector3(min.X, min.Y, max.Z); var tbl = new Vector3(min.X, max.Y, min.Z); var tbr = new Vector3(max.X, max.Y, min.Z); var bbr = new Vector3(max.X, min.Y, min.Z); var bbl = new Vector3(min.X, min.Y, min.Z); // Top Face AddLine(tfl, tfr); AddLine(tfr, tbr); AddLine(tbr, tbl); AddLine(tbl, tfl); // Bottom Face AddLine(bfl, bfr); AddLine(bfr, bbr); AddLine(bbr, bbl); AddLine(bbl, bfl); // Four Vertical Pillars AddLine(bfl, tfl); AddLine(bfr, tfr); AddLine(bbl, tbl); AddLine(bbr, tbr); FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimWireBone(string name, Transform location, Color color) { KeepBuffersAlive = true; Transform = location; NameColor = color; OverrideColor = color; Name = name; if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { Vector3 pt_start = Vector3.Zero; //Vector3 pt_cardinal1 = Vector3.Up * ThicknessRatio + Vector3.Right * ThicknessRatio; //Vector3 pt_cardinal2 = Vector3.Forward * ThicknessRatio + Vector3.Right * ThicknessRatio; //Vector3 pt_cardinal3 = Vector3.Down * ThicknessRatio + Vector3.Right * ThicknessRatio; //Vector3 pt_cardinal4 = Vector3.Backward * ThicknessRatio + Vector3.Right * ThicknessRatio; Vector3 pt_tip = Vector3.Right; ////Start to cardinals //AddLine(pt_start, pt_cardinal1); //AddLine(pt_start, pt_cardinal2); //AddLine(pt_start, pt_cardinal3); //AddLine(pt_start, pt_cardinal4); ////Cardinals to end //AddLine(pt_cardinal1, pt_tip); //AddLine(pt_cardinal2, pt_tip); //AddLine(pt_cardinal3, pt_tip); //AddLine(pt_cardinal4, pt_tip); ////Connecting the cardinals //AddLine(pt_cardinal1, pt_cardinal2); //AddLine(pt_cardinal2, pt_cardinal3); //AddLine(pt_cardinal3, pt_cardinal4); //AddLine(pt_cardinal4, pt_cardinal1); AddLine(pt_start, pt_tip); FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimWireSphere(Transform location, Color color) { KeepBuffersAlive = true; NameColor = color; Transform = location; if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { int numVerticalSegments = 11; int numSidesPerSegment = 12; float radius = 1; var topPoint = Vector3.Up * radius; var bottomPoint = Vector3.Down * radius; var points = new Vector3[numVerticalSegments, numSidesPerSegment]; for (int i = 0; i < numVerticalSegments; i++) { for (int j = 0; j < numSidesPerSegment; j++) { float horizontalAngle = (1.0f * j / numSidesPerSegment) * MathHelper.TwoPi; float verticalAngle = ((1.0f * (i + 1) / (numVerticalSegments + 1)) * MathHelper.Pi) - MathHelper.PiOver2; float altitude = (float)Math.Sin(verticalAngle); float horizontalDist = (float)Math.Cos(verticalAngle); points[i, j] = new Vector3((float)Math.Cos(horizontalAngle) * horizontalDist, altitude, (float)Math.Sin(horizontalAngle) * horizontalDist) * radius; } } for (int i = 0; i < numVerticalSegments; i++) { for (int j = 0; j < numSidesPerSegment; j++) { // On the bottom, we must connect each to the bottom point if (i == 0) { AddLine(points[i, j], bottomPoint, color); } // On the top, we must connect each point to the top // Note: this isn't "else if" because with 2 segments, // these are both true for the only ring if (i == numVerticalSegments - 1) { AddLine(points[i, j], topPoint, color); } // Make vertical lines that connect from this // horizontal ring to the one above // Since we are connecting // (current) -> (the one above current) // we dont need to do this for the very last one. if (i < numVerticalSegments - 1) { AddLine(points[i, j], points[i + 1, j], color); } // Make lines that connect points horizontally //---- if we reach end, we must wrap around, //---- otherwise, simply make line to next one if (j == numSidesPerSegment - 1) { AddLine(points[i, j], points[i, 0], color); } else { AddLine(points[i, j], points[i, j + 1], color); } } } FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimSolidArrow(string name, Transform location, Color color) { KeepBuffersAlive = true; //BackfaceCulling = false; Category = DbgPrimCategory.HkxBone; Transform = location; NameColor = color; Name = name; if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { Vector3 GetPoint(int segmentIndex, float radius, float depth) { float horizontalAngle = (1.0f * segmentIndex / Segments) * MathHelper.TwoPi; float x = (float)Math.Cos(horizontalAngle); float y = (float)Math.Sin(horizontalAngle); return(new Vector3(x * radius, y * radius, depth * Vector3.Forward.Z)); } Vector3 tip = Vector3.Forward; for (int i = 1; i <= Segments; i++) { var ptBase = GetPoint(i, StemRadius, 0); var prevPtBase = GetPoint(i - 1, StemRadius, 0); //Face: Part of Bottom AddTri(Vector3.Zero, prevPtBase, ptBase, color); } for (int i = 1; i <= Segments; i++) { var ptBase = GetPoint(i, StemRadius, 0); var ptTipStartInner = GetPoint(i, StemRadius, 1 - TipLength); var prevPtBase = GetPoint(i - 1, StemRadius, 0); var prevPtTipStartInner = GetPoint(i - 1, StemRadius, 1 - TipLength); // Face: Base to Tip Inner AddQuad(prevPtBase, prevPtTipStartInner, ptTipStartInner, ptBase, color); } for (int i = 1; i <= Segments; i++) { var ptTipStartInner = GetPoint(i, StemRadius, 1 - TipLength); var ptTipStartOuter = GetPoint(i, TipRadius, 1 - TipLength); var prevPtTipStartInner = GetPoint(i - 1, StemRadius, 1 - TipLength); var prevPtTipStartOuter = GetPoint(i - 1, TipRadius, 1 - TipLength); // Face: Tip Start Inner to Tip Start Outer AddQuad(prevPtTipStartInner, prevPtTipStartOuter, ptTipStartOuter, ptTipStartInner, color); } for (int i = 1; i <= Segments; i++) { var ptTipStartOuter = GetPoint(i, TipRadius, 1 - TipLength); var prevPtTipStartOuter = GetPoint(i - 1, TipRadius, 1 - TipLength); // Face: Tip Start to Tip AddTri(prevPtTipStartOuter, tip, ptTipStartOuter, color); } FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }
public DbgPrimWireCapsule_End() { //if (!(Segments >= 4)) // throw new ArgumentException($"Number of segments must be >= 4", nameof(Segments)); if (GeometryData != null) { SetBuffers(GeometryData.VertBuffer, GeometryData.IndexBuffer); } else { var topPoint = Vector3.Up * 1; var bottomPoint = Vector3.Down * 1; var points = new Vector3[Segments, Segments]; int verticalSegments = Segments / 2; for (int i = 0; i <= verticalSegments; i++) { for (int j = 0; j < Segments; j++) { float horizontalAngle = (1.0f * j / Segments) * MathHelper.TwoPi; float verticalAngle = ((1.0f * (i) / (verticalSegments)) * MathHelper.PiOver2); float altitude = (float)Math.Sin(verticalAngle); float horizontalDist = (float)Math.Cos(verticalAngle); points[i, j] = new Vector3((float)Math.Cos(horizontalAngle) * horizontalDist, altitude, (float)Math.Sin(horizontalAngle) * horizontalDist) * 1; } } for (int i = 0; i <= verticalSegments; i++) { for (int j = 0; j < Segments; j++) { //// On the bottom, we must connect each to the bottom point //if (i == 0) //{ // AddLine(points[i, j], bottomPoint, Color.White); //} // On the top, we must connect each point to the top // Note: this isn't "else if" because with 2 segments, // these are both true for the only ring if (i == Segments - 1) { AddLine(points[i, j], topPoint, Color.White); } // Make vertical lines that connect from this // horizontal ring to the one above // Since we are connecting // (current) -> (the one above current) // we dont need to do this for the very last one. if (i < Segments - 1) { AddLine(points[i, j], points[i + 1, j], Color.White); } // Make lines that connect points horizontally //---- if we reach end, we must wrap around, //---- otherwise, simply make line to next one if (j == Segments - 1) { AddLine(points[i, j], points[i, 0], Color.White); } else { AddLine(points[i, j], points[i, j + 1], Color.White); } } } FinalizeBuffers(true); GeometryData = new DbgPrimGeometryData() { VertBuffer = VertBuffer, IndexBuffer = IndexBuffer, }; } }