// ReSharper restore NotAccessedField.Global
// ReSharper restore MemberCanBePrivate.Global

        public VertexPositionTextureNormalBinormalTangent(Vector3 position, Vector2 textureCoordinate, Vector3 normal, Vector3 binormal, Vector3 tangent)
        {
            Position = position.ToXNA();
            TextureCoordinate = textureCoordinate.ToXNA();
            Normal = normal.ToXNA();
            Binormal = binormal.ToXNA();
            Tangent = tangent.ToXNA();
        }
        private void OnButtonClicked()
        {
            if (_parameterType == null)
            {
                (_memberInfo as MethodInfo).Invoke(_target, new object[] { });
            }
            else
            {
                // extract the param and properly cast it
                object[] parameters = new object[1];

                try {
                    if (_parameterType == typeof(float))
                    {
                        parameters[0] = _floatParam;
                    }
                    else if (_parameterType == typeof(int))
                    {
                        parameters[0] = _intParam;
                    }
                    else if (_parameterType == typeof(bool))
                    {
                        parameters[0] = _boolParam;
                    }
                    else if (_parameterType == typeof(string))
                    {
                        parameters[0] = _stringParam;
                    }
                    else if (_parameterType == typeof(Vector2))
                    {
                        parameters[0] = _vec2Param.ToXNA();
                    }
                    else if (_parameterType == typeof(Vector3))
                    {
                        parameters[0] = _vec3Param.ToXNA();
                    }
                    (_memberInfo as MethodInfo).Invoke(_target, parameters);
                }
                catch (Exception e) {
                    Debug.Error(e.ToString());
                }
            }
        }
Exemple #3
0
        public void Draw(Rectangle area)
        {
            var device = _vertices.GraphicsDevice;
            var pp = device.PresentationParameters;

// ReSharper disable CompareOfFloatsByEqualityOperator
            if (_dirty || area != _previousArea || _screenHeight != pp.BackBufferHeight || _screenWidth != pp.BackBufferWidth)
// ReSharper restore CompareOfFloatsByEqualityOperator
            {
                _screenHeight = pp.BackBufferHeight;
                _screenWidth = pp.BackBufferWidth;

                float x = (area.X / _screenWidth) * 2 - 1;
                float y = -((area.Y / _screenHeight) * 2 - 1);
                float width = (area.Width / _screenWidth) * 2;
                float height = (area.Height / _screenHeight) * 2;

                for (int i = 0; i < _data.Length; i++)
                {
                    var position = new Vector3(
                            x + (i / (float)(_data.Length - 1)) * width,
                            (y - height) + _data[i] * height,
                            0);
                    _transformedData[i] = new VertexPositionColor(position.ToXNA(), _colour);
                }

                _vertices.SetData<VertexPositionColor>(_transformedData);

                _dirty = false;
                _previousArea = area;
            }

            _effect.Techniques[0].Passes[0].Apply();
            device.SetVertexBuffer(_vertices);
            device.DrawPrimitives(PrimitiveType.LineStrip, 0, _data.Length - 1);
        }
        public static void SetValue(this EffectParameter collection, Vector3 value)
        {
            Contract.Requires(collection != null);

            collection.SetValue(value.ToXNA());
        }
Exemple #5
0
 public static Plane CreateFromPoints(Vector3 a, Vector3 b, Vector3 c)
 {
     Microsoft.Xna.Framework.Plane p = new Microsoft.Xna.Framework.Plane(a.ToXNA(), b.ToXNA(), c.ToXNA());
     return new Plane(p.Normal.FromXNA(), p.D);
 }
Exemple #6
0
// ReSharper restore NotAccessedField.Global
// ReSharper restore MemberCanBePrivate.Global

        public VertexPosition(Vector3 position)
        {
            Position = position.ToXNA();
        }
 public static void SetValue(this EffectParameter collection, Vector3 value)
 {
     collection.SetValue(value.ToXNA());
 }
Exemple #8
0
        /// <summary>
        /// Spawns a new particle.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="velocity">The velocity.</param>
        /// <param name="angularVelocity">The angular velocity.</param>
        /// <param name="size">The size.</param>
        /// <param name="lifetimeScale">The lifetime scale. This should be between 0 and 1.</param>
        /// <param name="startColour">The start colour.</param>
        /// <param name="endColour">The end colour.</param>
        public void Spawn(Vector3 position, Vector3 velocity, float angularVelocity, float size, float lifetimeScale, Color startColour, Color endColour)
        {
            if (_dirty)
                InitialiseBuffer();

            // exit if we have run out of capacity
            int nextFreeParticle = (_free + 1) % Description.Capacity;
            if (nextFreeParticle == _finished)
                return;

            // write data into buffer
            for (int i = 0; i < 4; i++)
            {
                _particles[_free * 4 + i].Position = position.ToXNA();
                _particles[_free * 4 + i].Velocity = new Vector4(velocity, angularVelocity).ToXNA();
                _particles[_free * 4 + i].Scales = new HalfVector2(size, lifetimeScale > 0 ? 1f / lifetimeScale : 1);
                _particles[_free * 4 + i].StartColour = startColour;
                _particles[_free * 4 + i].EndColour = endColour;
                _particles[_free * 4 + i].Time = _time;
            }

            _free = nextFreeParticle;
        }