public void RenderTriangles(DeviceContext context, List <VertexTypePC> verts, Camera camera, ShaderGlobalLights lights) { UseDynamicVerts = true; SetShader(context); SetInputLayout(context, VertexType.PC); SetSceneVars(context, camera, null, lights); int drawn = 0; int tricount = verts.Count / 3; int maxcount = vertices.StructCount / 3; while (drawn < tricount) { vertices.Clear(); int offset = drawn * 3; int bcount = Math.Min(tricount - drawn, maxcount); for (int i = 0; i < bcount; i++) { int t = offset + (i * 3); vertices.Add(verts[t + 0]); vertices.Add(verts[t + 1]); vertices.Add(verts[t + 2]); } drawn += bcount; vertices.Update(context); vertices.SetVSResource(context, 0); context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; context.Draw(vertices.CurrentCount, 0); } }
public void RenderTriangles(DeviceContext context, List <VertexTypePC> verts, Camera camera, ShaderGlobalLights lights) { UseDynamicVerts = true; SetShader(context); SetInputLayout(context, VertexType.PC); SetSceneVars(context, camera, null, lights); vertices.Clear(); foreach (var vert in verts) { vertices.Add(vert); } vertices.Update(context); vertices.SetVSResource(context, 0); context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; context.Draw(vertices.CurrentCount, 0); }
public void DrawDefaultWidget(DeviceContext context, Camera cam, Vector3 camrel, Quaternion ori, float size) { SetShader(context); SetInputLayout(context, VertexType.Default); SceneVars.Vars.Mode = 0; //vertices mode SceneVars.Vars.CamRel = camrel; SetSceneVars(context, cam, null, null); Vector3 xdir = ori.Multiply(Vector3.UnitX); Vector3 ydir = ori.Multiply(Vector3.UnitY); Vector3 zdir = ori.Multiply(Vector3.UnitZ); Color4 xcolour = new Color4(0.8f, 0.0f, 0.0f, 1.0f); Color4 ycolour = new Color4(0.8f, 0.0f, 0.0f, 1.0f); Color4 zcolour = new Color4(0.5f, 0.5f, 0.5f, 1.0f); Vector3[] axes = { xdir, ydir, zdir }; Vector3[] sides = { ydir, xdir, xdir }; Color4[] colours = { xcolour, ycolour, zcolour }; float linestart = 0.0f * size; float lineend = 1.0f * size; float arrowstart = 0.9f * size; float arrowend = 1.0f * size; float arrowrad = 0.05f * size; //draw lines... Vertices.Clear(); for (int i = 0; i < 3; i++) { WidgetAxis sa = (WidgetAxis)(1 << i); Color4 axcol = colours[i]; //main axis lines Vertices.Add(new WidgetShaderVertex(axes[i] * linestart, axcol)); Vertices.Add(new WidgetShaderVertex(axes[i] * lineend, axcol)); //arrow heads Vector3 astart = axes[i] * arrowstart; Vector3 aend = axes[i] * arrowend; Vector3 aside = sides[i] * arrowrad; Vertices.Add(new WidgetShaderVertex(aend, axcol)); Vertices.Add(new WidgetShaderVertex(astart + aside, axcol)); Vertices.Add(new WidgetShaderVertex(aend, axcol)); Vertices.Add(new WidgetShaderVertex(astart - aside, axcol)); } Vertices.Update(context); Vertices.SetVSResource(context, 0); context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList; context.Draw(Vertices.CurrentCount, 0); UnbindResources(context); }