コード例 #1
0
        public OverlaySettings(RenderRequestOverlay enabledOverlays)
            : this()
        {
            EnabledOverlays = enabledOverlays;

            const float toolSize = 0.08f;
            const float toolMargin = 0.05f;
            ToolSize = new PointF(toolSize, toolSize);
            ToolPosition = new PointF(1 - (toolMargin + toolSize * 0.5f), 1 - (toolMargin + toolSize * 0.5f));
            ToolBackground = ToolBackgroundType.BrownBorder;
        }
コード例 #2
0
        public OverlaySettings(RenderRequestOverlay enabledOverlays)
            : this()
        {
            EnabledOverlays = enabledOverlays;

            const float toolSize   = 0.08f;
            const float toolMargin = 0.05f;

            ToolSize       = new PointF(toolSize, toolSize);
            ToolPosition   = new PointF(1 - (toolMargin + toolSize * 0.5f), 1 - (toolMargin + toolSize * 0.5f));
            ToolBackground = ToolBackgroundType.BrownBorder;
        }
コード例 #3
0
        protected void DrawAvatarTool(RendererBase <ToyWorld> renderer, IAvatar avatar, Vector2 size, Vector2 position, ToolBackgroundType type = ToolBackgroundType.BrownBorder)
        {
            GameObjectPainter goPainter = Owner.GameObjectPainter;

            GL.Enable(EnableCap.Blend);
            Owner.SetDefaultBlending();

            // Bind stuff to GL (used in overrides)
            renderer.TextureManager.Bind(goPainter.TilesetTexture);
            renderer.EffectManager.Use(goPainter.Effect);
            goPainter.Effect.TextureUniform(0);


            if (Owner.FlipYAxis)
            {
                size.Y     = -size.Y;
                position.Y = -position.Y;
            }

            Matrix transform = Matrix.CreateScale(size);

            transform *= Matrix.CreateTranslation(position.X, position.Y, 0.01f);


            // Draw the inventory background
            renderer.TextureManager.Bind(m_overlayTexture, Owner.GetTextureUnit(RenderRequestBase.TextureBindPosition.Ui));
            renderer.EffectManager.Use(m_overlayEffect);
            m_overlayEffect.TextureUniform((int)RenderRequestBase.TextureBindPosition.Ui);
            m_overlayEffect.TileTypesTextureUniform((int)RenderRequestBase.TextureBindPosition.TileTypes);
            m_overlayEffect.TileTypesIdxOffsetUniform(0);
            m_overlayEffect.ModelViewProjectionUniform(ref transform);

            goPainter.LocalTileTypesBuffer[0] = (ushort)type;
            if (avatar.Tool != null)
            {
                goPainter.LocalTileTypesBuffer[1] = (ushort)avatar.Tool.TilesetId;
            }

            GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
            goPainter.TileTypesTexure.Update1D(2, dataType: PixelType.UnsignedShort, data: goPainter.LocalTileTypesBuffer);
            QuadOffset.Draw();


            // Draw the inventory Tool
            if (avatar.Tool != null)
            {
                renderer.TextureManager.Bind(goPainter.TilesetTexture);
                renderer.EffectManager.Use(goPainter.Effect);
                goPainter.Effect.DiffuseUniform(new Vector4(1, 1, 1, 1));
                goPainter.Effect.TileTypesIdxOffsetUniform(1);

                Matrix toolTransform = Matrix.CreateScale(0.7f) * transform;
                goPainter.Effect.ModelViewProjectionUniform(ref toolTransform);

                QuadOffset.Draw();
            }
        }