public void AddSelection( byte id, Vector3I p1, Vector3I p2, FastColour col ) { RemoveSelection( id ); SelectionBox selection = new SelectionBox( p1, p2, col ); selection.ID = id; selections.Add( selection ); }
public void Render(double delta) { if (!game.ShowAxisLines) { return; } if (vertices == null) { vertices = new VertexP3fC4b[12]; vb = game.Graphics.CreateDynamicVb(VertexFormat.P3fC4b, vertices.Length); } game.Graphics.Texturing = false; Vector3 P = game.LocalPlayer.Position; P.Y += 0.05f; int index = 0; SelectionBox.HorQuad(vertices, ref index, FastColour.Red.Pack(), P.X, P.Z - size, P.X + 3, P.Z + size, P.Y); SelectionBox.HorQuad(vertices, ref index, FastColour.Blue.Pack(), P.X - size, P.Z, P.X + size, P.Z + 3, P.Y); if (game.Camera.IsThirdPerson) { SelectionBox.VerQuad(vertices, ref index, FastColour.Green.Pack(), P.X - size, P.Y, P.Z + size, P.X + size, P.Y + 3, P.Z - size); } game.Graphics.SetBatchFormat(VertexFormat.P3fC4b); game.Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index); }
public void Render(double delta) { if (!game.ShowAxisLines || game.Graphics.LostContext) { return; } if (vertices == null) { vertices = new VertexP3fC4b[12]; ContextRecreated(); } game.Graphics.Texturing = false; Vector3 P = game.LocalPlayer.Position; P.Y += 0.05f; int index = 0; SelectionBox.HorQuad(vertices, ref index, PackedCol.Red, P.X, P.Z - size, P.X + 3, P.Z + size, P.Y); SelectionBox.HorQuad(vertices, ref index, PackedCol.Blue, P.X - size, P.Z, P.X + size, P.Z + 3, P.Y); if (game.Camera.IsThirdPerson) { SelectionBox.VerQuad(vertices, ref index, PackedCol.Green, P.X - size, P.Y, P.Z + size, P.X + size, P.Y + 3, P.Z - size); } game.Graphics.SetBatchFormat(VertexFormat.P3fC4b); game.Graphics.UpdateDynamicVb_IndexedTris(vb, vertices, index); }
public void AddSelection(byte id, Vector3I p1, Vector3I p2, FastColour col) { RemoveSelection(id); SelectionBox selection = new SelectionBox(p1, p2, col); selection.ID = id; selections.Add(selection); }
public void RemoveSelection(byte id) { for (int i = 0; i < selections.Count; i++) { SelectionBox sel = selections[i]; if (sel.ID == id) { selections.RemoveAt(i); break; } } }
public void Render(double delta) { if (selections.Count == 0 || game.Graphics.LostContext) { return; } // TODO: Proper selection box sorting. But this is very difficult because // we can have boxes within boxes, intersecting boxes, etc. Probably not worth it. Vector3 camPos = game.CurrentCameraPos; for (int i = 0; i < selections.Count; i++) { comparer.Intersect(selections[i], camPos); } selections.Sort(comparer); if (vertices == null) // lazy init as most servers don't use this. { vertices = new VertexP3fC4b[256 * VerticesCount]; lineVertices = new VertexP3fC4b[256 * LineVerticesCount]; ContextRecreated(); } int index = 0, lineIndex = 0; for (int i = 0; i < selections.Count; i++) { SelectionBox box = selections[i]; box.Render(delta, vertices, lineVertices, ref index, ref lineIndex); } IGraphicsApi gfx = game.Graphics; gfx.SetBatchFormat(VertexFormat.P3fC4b); gfx.UpdateDynamicVb_Lines(lineVb, lineVertices, selections.Count * LineVerticesCount); gfx.DepthWrite = false; gfx.AlphaBlending = true; gfx.UpdateDynamicVb_IndexedTris(vb, vertices, selections.Count * VerticesCount); gfx.DepthWrite = true; gfx.AlphaBlending = false; }
public void Render(double delta) { if (selections.Count == 0) { return; } // TODO: Proper selection box sorting. But this is very difficult because // we can have boxes within boxes, intersecting boxes, etc. Probably not worth it. Vector3 camPos = game.CurrentCameraPos; for (int i = 0; i < selections.Count; i++) { comparer.Intersect(selections[i], camPos); } selections.Sort(comparer); if (vertices == null) { InitData(); // lazy init as most servers don't use this. } int index = 0, lineIndex = 0; for (int i = 0; i < selections.Count; i++) { SelectionBox box = selections[i]; box.Render(delta, vertices, lineVertices, ref index, ref lineIndex); } Graphics.SetBatchFormat(VertexFormat.Pos3fCol4b); Graphics.UpdateDynamicVb(DrawMode.Lines, lineVb, lineVertices, selections.Count * LineVerticesCount); Graphics.DepthWrite = false; Graphics.AlphaBlending = true; Graphics.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, selections.Count * VerticesCount, selections.Count * IndicesCount); Graphics.DepthWrite = true; Graphics.AlphaBlending = false; }
public void AddSelection( byte id, Vector3I p1, Vector3I p2, FastColour col ) { SelectionBox selection = new SelectionBox( p1, p2, col, Graphics ); selection.ID = id; selections.Add( selection ); }