Beispiel #1
0
        /// <summary>
        ///     Draws all Gizmos that are sub-classes of GizmoGeometry.
        /// </summary>
        /// <param name="pass">The pass from an effect to draw the geometry with.</param>
        private void DrawBaseGizmosGeometries(EffectPass pass)
        {
            var           count = 0;
            List <Matrix> matrices;

            foreach (var drawInstance in DrawInstances)
            {
                var geometry = drawInstance.Key;
                geometry.Bind();

                foreach (var colorEntry in drawInstance.Value)
                {
                    ColorParameter.SetValue(colorEntry.Key.ToVector3());

                    matrices = colorEntry.Value;
                    count    = matrices.Count;

                    for (var index = 0; index < count; index++)
                    {
                        WorldViewProjectionParameter.SetValue(matrices[index]);
                        pass.Apply();
                        geometry.Draw();
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void UpdateParameters()
        {
            if (DirtyFlags.Has(DirtyFlag.WorldViewProjection))
            {
                Matrix.Multiply(ref _world, ref _view, out Matrix worldView);
                Matrix.Multiply(ref worldView, ref _projection, out Matrix worldViewProjection);
                WorldViewProjection = worldViewProjection;
                WorldViewProjectionParameter.SetValue(worldViewProjection);

                DirtyFlags -= DirtyFlag.WorldViewProjection;
            }

            if (DirtyFlags.Has(DirtyFlag.MaterialColor))
            {
                Vector4 diffuseColor = new Vector4(
                    DiffuseColor.R / 255f,
                    DiffuseColor.G / 255f,
                    DiffuseColor.B / 255f,
                    (DiffuseColor.A / 255f) * Alpha
                    );

                DiffuseColorParameter.SetValue(diffuseColor);

                DirtyFlags -= DirtyFlag.MaterialColor;
            }

            if (DirtyFlags.Has(DirtyFlag.TechniqueIndex))
            {
                OnUpdateTechniqueIndex();
                DirtyFlags -= DirtyFlag.TechniqueIndex;
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Draws all Gizmos that are poly-lines.
        /// </summary>
        /// <param name="pass">The pass from an effect to draw the geometry with.</param>
        private void DrawPolyLines(EffectPass pass)
        {
            var count = 0;
            List <Vector3[]> positions;

            WorldViewProjectionParameter.SetValue(Matrix.Identity);
            foreach (var polyLineInstance in PolyLinesToDraw)
            {
                ColorParameter.SetValue(polyLineInstance.Key.ToVector3());

                positions = polyLineInstance.Value;
                count     = positions.Count;
                for (var index = 0; index < count; index++)
                {
                    pass.Apply();
                    PolyLine.Draw(positions[index]);
                }
            }
        }