Exemplo n.º 1
0
        private IDxGeometry PrepareGeometry(IDxGeometry geometry)
        {
            if (geometry is DX11VertexGeometry)
            {
                DX11VertexGeometry vd = (DX11VertexGeometry)geometry.ShallowCopy();
                vd.VertexBuffer  = this.rawbuffer.Buffer;
                vd.VertexSize    = this.outputvertexsize;
                vd.VerticesCount = this.outputvertexcount;
                vd.InputLayout   = this.outputlayout;
                vd.Topology      = geometry.Topology;
                if (this.AsAuto)
                {
                    DX11VertexAutoDrawer auto = new DX11VertexAutoDrawer();
                    vd.AssignDrawer(auto);
                }
                return(vd);
            }
            if (geometry is DX11IndexedGeometry)
            {
                if (this.AsAuto)
                {
                    DX11VertexGeometry vd = new DX11VertexGeometry(this.Device);
                    vd.VertexBuffer  = this.rawbuffer.Buffer;
                    vd.VertexSize    = this.outputvertexsize;
                    vd.VerticesCount = this.outputvertexcount;
                    vd.InputLayout   = this.outputlayout;
                    vd.Topology      = geometry.Topology;
                    DX11VertexAutoDrawer auto = new DX11VertexAutoDrawer();
                    vd.AssignDrawer(auto);
                    return(vd);
                }
                else
                {
                    //Replace the vertexbuffer
                    DX11IndexedGeometry id = (DX11IndexedGeometry)geometry.ShallowCopy();
                    id.InputLayout  = this.outputlayout;
                    id.VertexBuffer = DX11VertexBuffer.CreateFromRawBuffer(this.Device, this.outputvertexcount, this.outputvertexsize, this.rawbuffer);
                    return(id);
                }
            }
            if (geometry is DX11NullGeometry)
            {
                DX11VertexGeometry vd = new DX11VertexGeometry(this.Device);
                vd.VertexBuffer  = this.rawbuffer.Buffer;
                vd.VertexSize    = this.outputvertexsize;
                vd.VerticesCount = this.outputvertexcount;
                vd.InputLayout   = this.outputlayout;
                vd.Topology      = geometry.Topology;
                if (this.AsAuto)
                {
                    DX11VertexAutoDrawer auto = new DX11VertexAutoDrawer();
                    vd.AssignDrawer(auto);
                }
                return(vd);
            }

            throw new NotSupportedException("Can't prepare geometry from provided geometry");
        }
Exemplo n.º 2
0
        public static Action <LayerSettings> DetachGeometry(LayerSettings settings)
        {
            IDxGeometry geom = settings.Geometry;

            settings.Geometry = null;
            Action <LayerSettings> restore = (rs) => { rs.Geometry = geom; };

            return(restore);
        }
Exemplo n.º 3
0
        public void AssignGeometry(IDxGeometry geometry)
        {
            this.outputvertexcount = this.GetVertexCount(geometry);
            int buffersize = this.outputvertexcount * this.outputvertexsize;

            if (rawbuffer != null)
            {
                if (buffersize != this.rawbuffer.Size)
                {
                    rawbuffer.Dispose(); rawbuffer = null;
                }
            }

            if (rawbuffer == null)
            {
                rawbuffer = DX11RawBuffer.CreateWriteable(this.Device, buffersize, new RawBufferBindings()
                {
                    AllowVertexBuffer = true, WriteMode = eRawBufferWriteMode.StreamOut
                });
            }
            this.binding        = new StreamOutputBufferBinding[] { new StreamOutputBufferBinding(this.rawbuffer.Buffer, 0) };
            this.outputgeometry = this.PrepareGeometry(geometry);
        }
Exemplo n.º 4
0
        private int GetVertexCount(IDxGeometry geometry)
        {
            if (this.UseMaxElements)
            {
                return(this.MaxElements);
            }

            if (geometry is DX11VertexGeometry)
            {
                DX11VertexGeometry vd = (DX11VertexGeometry)geometry;
                return(vd.VerticesCount);
            }
            if (geometry is DX11IndexedGeometry)
            {
                DX11IndexedGeometry id = (DX11IndexedGeometry)geometry;
                return(id.VertexBuffer.VerticesCount);
            }
            if (geometry is DX11NullGeometry)
            {
                return(this.MaxElements);
            }

            throw new NotSupportedException("Can't set Vertices count from provided geometry");
        }