Esempio n. 1
0
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FOutput[0] == null)
            {
                this.FOutput[0] = new DX11Resource <DX11VertexGeometry>();
            }

            if (this.FInApply[0] || this.FFirst)
            {
                this.FFirst = false;

                this.FInput.Validate();
                this.FInLayout.Sync();
                this.FInTopology.Sync();
                this.FInVerticesCount.Sync();

                this.FInvalidate = true;
                DX11Resource <DX11VertexGeometry> instance = this.FOutput[0];
                this.FOutput[0] = instance;

                this.inputlayout = new InputElement[this.FInLayout.SliceCount];
                this.vertexsize  = 0;
                for (int i = 0; i < this.FInLayout.SliceCount; i++)
                {
                    if (this.FInLayout.IsConnected && this.FInLayout[i] != null)
                    {
                        this.inputlayout[i] = this.FInLayout[i];
                    }
                    else
                    {
                        //Set deault, can do better here
                        this.inputlayout[i] = new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0);
                    }
                    this.vertexsize += FormatHelper.Instance.GetSize(this.inputlayout[i].Format);
                }
                InputLayoutFactory.AutoIndex(this.inputlayout);


                if (this.FStream != null)
                {
                    this.FStream.Dispose();
                }
                this.FStream = new DataStream(this.FInVerticesCount[0] * this.vertexsize, true, true);

                double *ptr;
                int     ptrcnt;
                this.FInput.GetValuePointer(out ptrcnt, out ptr);

                for (int i = 0; i < this.FInVerticesCount[0] * (this.vertexsize / 4); i++)
                {
                    this.FStream.Write((float)ptr[i % ptrcnt]);
                }

                DX11Resource <DX11VertexGeometry> v = this.FOutput[0];
                this.FOutput[0] = v;
            }
        }
        private InputElement[] BindInputLayout(out int vertexsize)
        {
            InputElement[] inputlayout = new InputElement[this.FInLayout.SliceCount];
            vertexsize = 0;
            for (int i = 0; i < this.FInLayout.SliceCount; i++)
            {
                if (this.FInLayout.PluginIO.IsConnected && this.FInLayout[i] != null)
                {
                    inputlayout[i] = this.FInLayout[i];
                }
                else
                {
                    //Set deault, can do better here
                    inputlayout[i] = new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0);
                }
                vertexsize += FormatHelper.Instance.GetSize(inputlayout[i].Format);
            }
            InputLayoutFactory.AutoIndex(inputlayout);

            return(inputlayout);
        }
Esempio n. 3
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInLayoutType.IsChanged || this.FInFormat.IsChanged || this.FAutoIndex.IsChanged)
            {
                this.FOutput.SliceCount = SpreadMax;
                int offset = 0;

                InputElement[] elements = new InputElement[SpreadMax];

                for (int i = 0; i < SpreadMax; i++)
                {
                    Format fmt = (Format)Enum.Parse(typeof(Format), this.FInFormat[i].Name);
                    elements[i] = InputLayoutFactory.GetInputElement(this.FInLayoutType[i], fmt, 0, offset);
                    offset     += FormatHelper.Instance.GetSize(fmt);
                }

                if (this.FAutoIndex[0])
                {
                    InputLayoutFactory.AutoIndex(elements);
                }

                this.FOutput.AssignFrom(elements);
            }
        }
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FOutput[0] == null)
            {
                this.FOutput[0] = new DX11Resource <DX11IndexedGeometry>();
            }

            if (this.FInApply[0] || FFirst)
            {
                this.FFirst = false;
                this.FInput.Sync();
                this.FInVerticesCount.Sync();
                this.FInIndices.Sync();
                this.FIndicesCount.Sync();
                this.FInLayout.Sync();
                this.FInTopology.Sync();

                this.FInvalidate = true;
                DX11Resource <DX11IndexedGeometry> instance = this.FOutput[0];
                this.FOutput[0] = instance;

                //Get Input Layout
                this.inputlayout = new InputElement[this.FInLayout.SliceCount];
                this.vertexsize  = 0;
                for (int i = 0; i < this.FInLayout.SliceCount; i++)
                {
                    if (this.FInLayout.PluginIO.IsConnected && this.FInLayout[i] != null)
                    {
                        this.inputlayout[i] = this.FInLayout[i];
                    }
                    else
                    {
                        //Set deault, can do better here
                        this.inputlayout[i] = new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0);
                    }
                    this.vertexsize += FormatHelper.Instance.GetSize(this.inputlayout[i].Format);
                }
                InputLayoutFactory.AutoIndex(this.inputlayout);

                //Load Vertex Stream
                if (this.FVertexStream != null)
                {
                    this.FVertexStream.Dispose();
                }

                this.FVertexStream = new DataStream(this.FInVerticesCount[0] * this.vertexsize, true, true);

                for (int i = 0; i < this.FInVerticesCount[0] * (this.vertexsize / 4); i++)
                {
                    this.FVertexStream.Write(this.FInput[i]);
                }
                this.FVertexStream.Position = 0;

                //Load index stream
                if (this.FIndexStream != null)
                {
                    this.FIndexStream.Dispose();
                }

                this.FIndexStream = new DataStream(this.FIndicesCount[0] * 4, true, true);
                for (int i = 0; i < this.FIndicesCount[0]; i++)
                {
                    this.FIndexStream.Write(this.FInIndices[i]);
                }
                this.FIndexStream.Position = 0;
            }
        }