public DX11IndexedGeometry Octahedron(Octahedron settings) { OctahedronBuilder builder = new OctahedronBuilder(); ListGeometryAppender appender = new ListGeometryAppender(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); builder.Construct(settings, appender.AppendVertex, appender.AppendIndex); return(FromAppender(settings, appender, info)); }
public DX11IndexedGeometry Cylinder(Cylinder settings) { CylinderBuilder builder = new CylinderBuilder(); ListGeometryAppender appender = new ListGeometryAppender(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); builder.Construct(settings, appender.AppendVertex, appender.AppendIndex); return(FromAppender(settings, appender, info)); }
public DX11IndexedGeometry QuadNormals(Quad settings) { QuadBuilder builder = new QuadBuilder(); ListGeometryAppender appender = new ListGeometryAppender(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); builder.Construct(settings, appender.AppendVertex, appender.AppendIndex); return(FromAppender(settings, appender, info)); }
public DX11IndexedGeometry IcoSphere(IcoSphere settings) { float radius = settings.Radius; IcoSphereBuilder builder = new IcoSphereBuilder(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); ListGeometryAppender appender = new ListGeometryAppender(); builder.Construct(settings, appender.AppendVertex, appender.AppendIndex); DX11IndexedGeometry geom = FromAppender(settings, appender, info); geom.BoundingBox = new BoundingBox(new Vector3(-radius), new Vector3(radius)); return(geom); }
public DX11IndexedGeometry IcoGrid(IcoGrid settings) { IcoGridBuilder builder = new IcoGridBuilder(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); ListGeometryAppender appender = new ListGeometryAppender(); builder.Construct(settings, appender.AppendVertex, appender.AppendIndex); float invmx = 1.0f / builder.MaxX; float invmy = 1.0f / builder.MaxY; appender.TransformVertices((v) => { v.Position.X *= invmx; v.Position.X -= 0.5f; v.Position.Y *= invmy; v.Position.Y -= 0.5f; return(v); }); return(FromAppender(settings, appender, info)); }
public DX11IndexedGeometry Segment(Segment settings) { SegmentBuilder builder = new SegmentBuilder(); ListGeometryAppender appender = new ListGeometryAppender(); PrimitiveInfo info = builder.GetPrimitiveInfo(settings); Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue); Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); builder.Construct(settings, (v, n, u) => { appender.AppendVertex(v, n, u); min = Vector3.Min(min, v); max = Vector3.Max(max, v); }, appender.AppendIndex); DX11IndexedGeometry geom = new DX11IndexedGeometry(device); geom.Tag = settings; geom.PrimitiveType = settings.PrimitiveType; geom.VertexBuffer = DX11VertexBuffer.CreateImmutable(device, appender.Vertices.ToArray()); geom.IndexBuffer = DX11IndexBuffer.CreateImmutable(device, appender.Indices.ToArray()); geom.InputLayout = Pos4Norm3Tex2Vertex.Layout; geom.Topology = PrimitiveTopology.TriangleList; geom.HasBoundingBox = true; geom.BoundingBox = new BoundingBox(min, max); return(geom); }
private DX11IndexedGeometry FromAppender(AbstractPrimitiveDescriptor descriptor, ListGeometryAppender appender, PrimitiveInfo info) { DX11IndexedGeometry geom = new DX11IndexedGeometry(device); geom.Tag = descriptor; geom.PrimitiveType = descriptor.PrimitiveType; geom.VertexBuffer = DX11VertexBuffer.CreateImmutable(device, appender.Vertices.ToArray()); geom.IndexBuffer = DX11IndexBuffer.CreateImmutable(device, appender.Indices.ToArray()); geom.InputLayout = Pos4Norm3Tex2Vertex.Layout; geom.Topology = PrimitiveTopology.TriangleList; geom.HasBoundingBox = info.IsBoundingBoxKnown; geom.BoundingBox = info.BoundingBox; return(geom); }