Esempio n. 1
0
 // For the time being, source rects for 3D sprites aren't supported (in order to simplify the rendering
 // process). This might be fine, even if source rects are never added.
 public Sprite3D(QuadSource source, Alignments alignment = Alignments.Center)
 {
     Source = source;
     origin = Utilities.ComputeOrigin(source.Width, source.Height, alignment) -
              new ivec2(source.Width, source.Height) / 2;
     Scale          = vec2.Ones;
     Orientation    = quat.Identity;
     Color          = Color.White;
     IsShadowCaster = true;
 }
Esempio n. 2
0
        public Sprite3D(QuadSource source, SourceRect sourceRect, ivec2 origin) :
            this(source, sourceRect, Alignments.Custom)
        {
            int w;
            int h;

            if (sourceRect.Width > 0)
            {
                w = sourceRect.Width;
                h = sourceRect.Height;
            }
            else
            {
                w = source.Width;
                h = source.Height;
            }

            correction = origin - new vec2(w, h) / 2;
        }
Esempio n. 3
0
        public Sprite3D(QuadSource source, SourceRect sourceRect, Alignments alignment = Alignments.Center)
        {
            Source     = source;
            SourceRect = sourceRect;

            int w;
            int h;

            if (sourceRect.Width > 0)
            {
                w = sourceRect.Width;
                h = sourceRect.Height;
            }
            else
            {
                w = source.Width;
                h = source.Height;
            }

            if (alignment != Alignments.Custom)
            {
                bool left   = (alignment & Alignments.Left) > 0;
                bool right  = (alignment & Alignments.Right) > 0;
                bool top    = (alignment & Alignments.Top) > 0;
                bool bottom = (alignment & Alignments.Bottom) > 0;

                var x = left ? 0 : (right ? w : w / 2f);
                var y = top ? 0 : (bottom ? h : h / 2f);

                correction = new vec2(x, y) - new vec2(w, h) / 2;
            }

            var flags = new Flags <TransformFlags>(TransformFlags.None);

            IsDrawEnabled  = true;
            IsShadowCaster = true;
            positionField  = new RenderPosition3DField(flags);
            scaleField     = new RenderScale2DField(flags);
            scaleField.SetValue(new vec2(w, h) / PixelDivisor, false);
            orientationField = new RenderOrientationField(flags);
            colorField       = new RenderColorField(flags);
        }
Esempio n. 4
0
 public Sprite3D(QuadSource source, Alignments alignment = Alignments.Center) :
     this(source, new SourceRect(), alignment)
 {
 }