Example #1
0
        internal DX11IndexOnlyGeometry(DX11IndexOnlyGeometry owner)
        {
            this.ownsido = false;

            this.context        = owner.context;
            this.drawer         = owner.drawer;
            this.InputLayout    = owner.InputLayout;
            this.Topology       = owner.Topology;
            this.IndexBuffer    = owner.IndexBuffer;
            this.HasBoundingBox = owner.HasBoundingBox;
            this.BoundingBox    = owner.BoundingBox;
        }
        internal DX11IndexOnlyGeometry(DX11IndexOnlyGeometry owner)
        {
            this.ownsido = false;

            this.context = owner.context;
            this.drawer = owner.drawer;
            this.InputLayout = owner.InputLayout;
            this.Topology = owner.Topology;
            this.IndexBuffer = owner.IndexBuffer;
            this.HasBoundingBox = owner.HasBoundingBox;
            this.BoundingBox = owner.BoundingBox;
        }
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (this.FInvalidate || this.FEmpty)
            {
                for (int i = 0; i < this.scenes.Count; i++)
                {
                    if (scenes[i] != null)
                    {
                        AssimpScene scene = scenes[i];

                        for (int j = 0; j < scene.MeshCount; j++)
                        {
                            AssimpMesh assimpmesh = scene.Meshes[j];

                            List<int> inds = assimpmesh.Indices;

                            if (inds.Count > 0 && assimpmesh.VerticesCount > 0)
                            {
                                var indexstream = new DataStream(inds.Count * 4, true, true);
                                indexstream.WriteRange(inds.ToArray());
                                indexstream.Position = 0;

                                DX11IndexOnlyGeometry geom = new DX11IndexOnlyGeometry(context);
                                geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true);
                                geom.InputLayout = assimpmesh.GetInputElements().ToArray();
                                geom.Topology = PrimitiveTopology.TriangleList;
                                geom.HasBoundingBox = true;
                                geom.BoundingBox = assimpmesh.BoundingBox;

                                DX11DynamicStructuredBuffer<Vector3> p =
                                    new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.PositionPointer, assimpmesh.VerticesCount);

                                DX11DynamicStructuredBuffer<Vector3> n =
                                    new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.NormalsPointer, assimpmesh.VerticesCount);

                                if (assimpmesh.UvChannelCount > 0)
                                {

                                    DX11DynamicStructuredBuffer<Vector3> u =
                                    new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.GetUvPointer(0), assimpmesh.VerticesCount);

                                    this.FOutUvs[i][j][context] = u;
                                }

                                DX11RawBuffer rb = new DX11RawBuffer(context, geom.IndexBuffer.Buffer);

                                this.FOutPosition[i][j][context] = p;
                                this.FOutNormals[i][j][context] = n;
                                this.FOutGeom[i][j][context] = geom;
                                this.FOutIndices[i][j][context] = rb;
                            }

                        }
                    }
                }
                this.FInvalidate = false;
                this.FEmpty = false;
            }
        }
        private void BuildBuffer(DX11RenderContext context,int[] data, Pin<DX11Resource<DX11IndexOnlyGeometry>> respin)
        {
            DX11IndexOnlyGeometry geom = new DX11IndexOnlyGeometry(context);

            geom.HasBoundingBox = false;
            geom.Topology = PrimitiveTopology.LineList;
            geom.InputLayout = new InputElement[0];

            var indexstream = new DataStream(data.Length * 4, true, true);
            indexstream.WriteRange(data);
            indexstream.Position = 0;

            geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true);
            respin[0][context] = geom;
        }