Пример #1
0
 public static Vector2b Next(this Random random, Vector2b min, Vector2b max)
 {
     return(new Vector2b(
                (sbyte)random.Next(min.X, max.X + 1),
                (sbyte)random.Next(min.Y, max.Y + 1)
                ));
 }
Пример #2
0
 public static Vector2b Next(this Random random, Vector2b min, Vector2b max)
 {
     return new Vector2b(
         (sbyte)random.Next(min.X, max.X + 1),
         (sbyte)random.Next(min.Y, max.Y + 1)
     );
 }
Пример #3
0
        public void NormalizeUV()
        {
            normuv.Clear();

            foreach (Vector2b v in uv)
            {
                Vector2b n = new Vector2b(0, 0);
                n.X = (byte)(Helpers.Normalize(min.X, max.X, v.X) * 255);
                n.Y = (byte)(Helpers.Normalize(min.Y, max.Y, v.Y) * 255);
                normuv.Add(n);
            }
        }
Пример #4
0
        public void SetPixels(Vector3i offset, Vector2i size, ReadOnlySpan <TPixel> pixels)
        {
            if (Vector3b.Any(offset < 0))
            {
                throw new ArgumentOutOfRangeException(nameof(size), "All components must be >=0");
            }
            else if (Vector2b.Any(size < 0))
            {
                throw new ArgumentOutOfRangeException(nameof(size), "All components must be >=0 and <TexSize");
            }

            GL.TextureSubImage2D(Handle, 0, offset.X, offset.Y, (uint)size.X, (uint)size.Y, _PixelFormat, _PixelType, pixels);
        }
Пример #5
0
        public static VertexPositionColorTexture ToVptc(CTRFramework.Vertex v, Vector2b uv, float scale = 1.0f)
        {
            VertexPositionColorTexture mono_v = new VertexPositionColorTexture();

            mono_v.Position = ToVector3(v.coord, scale);
            mono_v.Color    = new Color(
                v.color.X / 255f,
                v.color.Y / 255f,
                v.color.Z / 255f
                );
            mono_v.TextureCoordinate = new Microsoft.Xna.Framework.Vector2(uv.X / 255.0f, uv.Y / 255.0f);
            return(mono_v);
        }
Пример #6
0
        public Texture2D(GL gl, Vector2i size, WrapMode wrapMode, FilterMode filterMode, bool mipmap) : base(gl, TextureTarget.Texture2D)
        {
            if (Vector2b.Any(size < 0))
            {
                throw new ArgumentOutOfRangeException(nameof(size), "All components must be >=0");
            }

            Size = size;

            AssignPixelFormats <TPixel>();
            AssignTextureParameters(GetWrapModeAsGLEnum(wrapMode), GetFilterModeAsGLEnum(filterMode));
            GL.TextureStorage2D(Handle, 1, _InternalFormat, (uint)size.X, (uint)size.Y);

            if (mipmap)
            {
                GL.GenerateTextureMipmap(Handle);
            }
        }
            public void Update(Vector2 newInput)
            {
                LastRawInput    = CurrentRawInput;
                CurrentRawInput = (Vector2b)newInput;

                SmashFramesRemaining = Mathf.Max(0, SmashFramesRemaining - 1);

                var lastInput    = InputUtil.EnforceDeadZone(LastRawInput, InputConfig.DeadZone);
                var currentInput = InputUtil.EnforceDeadZone(CurrentRawInput, InputConfig.DeadZone);

                if (InputUtil.OutsideDeadZone(lastInput, InputConfig.DeadZone))
                {
                    SmashValue = Vector2b.zero;
                    return;
                }

                var diff = currentInput - lastInput;

                diff = InputUtil.EnforceDeadZone(diff, InputConfig.SmashThreshold);
                diff = InputUtil.MaxComponent(diff);

                if (SmashFramesRemaining > 0)
                {
                    // Has recently smashed, needs to be in a different direction to change
                    var currentDirection = SmashValue.Direction;
                    var newDirection     = diff.Direction;
                    if (currentDirection != newDirection)
                    {
                        RefreshSmashValue(diff);
                    }
                }
                else if (!InputUtil.OutsideDeadZone(diff, InputConfig.SmashThreshold))
                {
                    SmashValue = Vector2b.zero;
                }
                else
                {
                    RefreshSmashValue(diff);
                }
            }
Пример #8
0
 public VertexPositionColorTexture()
 {
     Position          = Vector3.zero;
     TextureCoordinate = new Vector2b(0, 0);
     Color             = Color.white;
 }
Пример #9
0
 public VertexPositionColorTexture(Vector3 position, Color color, Vector2b textureCoordinate)
 {
     Position          = position;
     TextureCoordinate = textureCoordinate;
     Color             = color;
 }
Пример #10
0
 /// <summary>Read a <see cref="Vector2b"/>.</summary>
 public static void ReadVector2b(this BinaryReader reader , out Vector2b result)
 {
     result.X = reader.ReadByte();
                                 result.Y = reader.ReadByte();
             return;
 }
Пример #11
0
 /// <summary>Read an array of <c>Vector2b</c> values.</summary>
 public static Vector2b[] ReadArrayVector2b(this BinaryReader reader, int count)
 {
     Vector2b[] array = new Vector2b[count]; reader.ReadArray(array, 0, count); return array;
 }
 void RefreshSmashValue(Vector2b value)
 {
     SmashValue           = value;
     SmashFramesRemaining = (int)InputConfig.SmashFrameWindow;
 }