예제 #1
0
        protected MeshUser(Mesh mesh)
        {
            Mesh           = mesh;
            IsDrawEnabled  = true;
            IsShadowCaster = true;

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

            // The corresponding properties are intentionally not called (in order to keep flags unset).
            position    = new RenderPosition3DField(flags);
            scale       = new RenderScale3DField(flags);
            orientation = new RenderOrientationField(flags);
        }
예제 #2
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);
        }