コード例 #1
0
 // Lerp
 public void Lerp(ref SpriteColors from, ref SpriteColors to, float f01)
 {
     Color0.Lerp(from.Color0, to.Color0, f01);
     Color1.Lerp(from.Color1, to.Color1, f01);
     Color2.Lerp(from.Color2, to.Color2, f01);
     Color3.Lerp(from.Color3, to.Color3, f01);
 }
コード例 #2
0
        public override void VTSUpdate(double interpolationHd, float interpolationLd, float elapsedTime)
        {
            if (_player == null)
            {
                return;
            }

            // update model color, get the cube where model is
            var result = _chunkContainer.GetCube(_player.Position);

            if (result.IsValid && result.Cube.Id == WorldConfiguration.CubeId.Air)
            {
                // we take the max color
                var sunPart     = (float)result.Cube.EmissiveColor.A / 255;
                var sunColor    = _skyDome.SunColor * sunPart;
                var resultColor = Color3.Max(result.Cube.EmissiveColor.ToColor3(), sunColor);

                _lightColor.Value = resultColor;

                if (_lightColor.ValueInterp != _lightColor.Value)
                {
                    Color3.Lerp(ref _lightColor.ValueInterp, ref _lightColor.Value, elapsedTime * 10.0f, out _lightColor.ValueInterp);
                }
            }

            // play animation
            if (_animation)
            {
                const float speed = 21f;
                if (elapsedTime == 0.0f)
                {
                    elapsedTime = 0.0001f;
                }
                Quaternion finalRotation = Quaternion.RotationYawPitchRoll(0, MathHelper.PiOver2, 0);
                Vector3    finalOffset   = new Vector3(0, 0, 2);

                if (_animationStated)
                {
                    Quaternion.Slerp(ref _animationRotation, ref finalRotation, (float)elapsedTime * speed, out _animationRotation);
                    Vector3.Lerp(ref _animationOffset, ref finalOffset, (float)elapsedTime * speed, out _animationOffset);

                    if (_animationRotation.EqualsEpsilon(finalRotation, 0.1f))
                    {
                        _animationStated = false;
                    }
                }
                else
                {
                    var identity   = Quaternion.Identity;
                    var nullOffset = new Vector3();
                    Quaternion.Slerp(ref _animationRotation, ref identity, (float)elapsedTime * speed, out _animationRotation);
                    Vector3.Lerp(ref _animationOffset, ref nullOffset, (float)elapsedTime * speed, out _animationOffset);
                }

                if (_animationRotation == Quaternion.Identity)
                {
                    _animation = false;
                }
            }
        }
コード例 #3
0
        public override void VTSUpdate(double interpolationHd, float interpolationLd, float elapsedTime)
        {
            foreach (var entity in _dynamicEntitiesDico.Values)
            {
                entity.Interpolation(interpolationHd, interpolationLd, elapsedTime);

                // update model color, get the cube where model is
                var result = _chunkContainer.GetCube(entity.WorldPosition.ValueInterp);
                if (result.IsValid && result.Cube.Id == WorldConfiguration.CubeId.Air)
                {
                    // we take the max color
                    var sunPart     = (float)result.Cube.EmissiveColor.A / 255;
                    var sunColor    = _skyDome.SunColor * sunPart;
                    var resultColor = Color3.Max(result.Cube.EmissiveColor.ToColor3(), sunColor);

                    entity.ModelLight.Value = resultColor;

                    if (entity.ModelLight.ValueInterp != entity.ModelLight.Value)
                    {
                        Color3.Lerp(ref entity.ModelLight.ValueInterp, ref entity.ModelLight.Value, elapsedTime * 10.0f, out entity.ModelLight.ValueInterp);
                    }
                }
            }
        }