Пример #1
0
        /// <summary>
        /// Add one field given as texture.
        /// </summary>
        /// <param name="field"></param>
        public void AddScalar(ScalarField field)
        {
            ShaderResourceView[] cpy = _fieldTextures;
            _fieldTextures = new ShaderResourceView[_fieldTextures.Length + 1];
            Array.Copy(cpy, _fieldTextures, cpy.Length);

            Texture2D tex = ColorMapping.GenerateTextureFromField(_device, field);

            _fieldTextures[cpy.Length] = new ShaderResourceView(_device, tex);

            SetRenderEffect(Effect);
        }
Пример #2
0
        /// <summary>
        /// Plane to display scalar/vector field data on. Condition: Fields domain is 2D.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="xAxis"></param>
        /// <param name="yAxis"></param>
        /// <param name="scale">Scaling the field extent.</param>
        /// <param name="field"></param>
        public FieldPlane(Plane plane, VectorField fields, RenderEffect effect = RenderEffect.DEFAULT, Colormap map = Colormap.Parula)
        {
#if DEBUG
            // Assert that the fields are 2 dimensional.
            foreach (Field field in fields.Scalars)
            {
                System.Diagnostics.Debug.Assert(field.Size.Length >= 2);
            }
#endif
            this._effect          = _planeEffect;
            this._vertexSizeBytes = 32;
            this._numVertices     = 6;
            this.UsedMap          = map;
            this._width           = fields[0].Size[0];
            this._height          = fields[0].Size[1];
            this._invalid         = fields.InvalidValue ?? float.MaxValue;
            this._field           = fields;

            // Setting up the vertex buffer.
            GenerateGeometry(plane, fields[0].Size.ToInt2(), fields.TimeSlice ?? 0);


            // Generating Textures from the fields.
            _fieldTextures = new ShaderResourceView[fields.Scalars.Length];
            for (int f = 0; f < _field.NumVectorDimensions; ++f)
            {
                Texture2D tex = ColorMapping.GenerateTextureFromField(_device, fields[f]);
                _fieldTextures[f] = new ShaderResourceView(_device, tex);
            }

            this.SetRenderEffect(effect);
            this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXTURE", 0, Format.R32G32B32A32_Float, 16, 0)
            });
        }