Beispiel #1
0
        CefMouseEvent GetCurrentMouseEvent()
        {
            Vec2 pos        = viewSize.ToVec2() * MousePosition;
            var  mouseEvent = new CefMouseEvent((int)pos.X, (int)pos.Y, GetCurrentKeyboardModifiers());

            return(mouseEvent);
        }
        private static void CalculateDownScale4x4SampleOffsets(Vec2I sourceTextureSize, Vec2[] sampleOffsets)
        {
            // Sample from the 16 surrounding points. Since the center point will be in
            // the exact center of 16 texels, a 0.5f offset is needed to specify a texel
            // center.
            Vec2 invSize = 1.0f / sourceTextureSize.ToVec2();
            int  index   = 0;

            for (int y = 0; y < 4; y++)
            {
                for (int x = 0; x < 4; x++)
                {
                    sampleOffsets[index] = new Vec2(((float)x - 1.5f), ((float)y - 1.5f)) * invSize;
                    index++;
                }
            }
        }
Beispiel #3
0
        Vec2I GetNeededSize()
        {
            Vec2I result;

            ScreenControlManager screenControlManager = GetControlManager() as ScreenControlManager;

            if (screenControlManager != null)
            {
                //screen gui

                Vec2I viewportSize = screenControlManager.GuiRenderer.ViewportForScreenGuiRenderer.
                                     DimensionsInPixels.Size;

                Vec2 size = viewportSize.ToVec2() * GetScreenSize();
                if (screenControlManager.GuiRenderer._OutGeometryTransformEnabled)
                {
                    size *= screenControlManager.GuiRenderer._OutGeometryTransformScale;
                }

                result = new Vec2I((int)(size.X + .9999f), (int)(size.Y + .9999f));
            }
            else
            {
                //in-game gui

                int height = inGame3DGuiHeightInPixels;
                if (height > RenderSystem.Instance.Capabilities.MaxTextureSize)
                {
                    height = RenderSystem.Instance.Capabilities.MaxTextureSize;
                }

                Vec2  screenSize = GetScreenSize();
                float width      = (float)height * (screenSize.X / screenSize.Y) * GetControlManager().AspectRatio;
                result = new Vec2I((int)(width + .9999f), height);
            }

            if (result.X < 1)
            {
                result.X = 1;
            }
            if (result.Y < 1)
            {
                result.Y = 1;
            }
            return(result);
        }
            Vec2I GetNeededTextureSize()
            {
                Vec2I result = Vec2I.Zero;

                Vec2I screenSize = RendererWorld.Instance.DefaultViewport.DimensionsInPixels.Size;

                if (screenSize.X > 0 && screenSize.Y > 0)
                {
                    result = (rectangle.GetSize() * screenSize.ToVec2()).ToVec2I();
                }

                if (result.X < 1)
                {
                    result.X = 1;
                }
                if (result.Y < 1)
                {
                    result.Y = 1;
                }

                return(result);
            }
 static void CalculateDownScale4x4SampleOffsets( Vec2I sourceTextureSize, Vec2[] sampleOffsets )
 {
     // Sample from the 16 surrounding points. Since the center point will be in
     // the exact center of 16 texels, a 0.5f offset is needed to specify a texel
     // center.
     Vec2 invSize = 1.0f / sourceTextureSize.ToVec2();
     int index = 0;
     for( int y = 0; y < 4; y++ )
     {
         for( int x = 0; x < 4; x++ )
         {
             sampleOffsets[ index ] = new Vec2( ( (float)x - 1.5f ), ( (float)y - 1.5f ) ) * invSize;
             index++;
         }
     }
 }
Beispiel #6
0
 public Vec2 GetPieceDestinationPosition( Vec2I index )
 {
     //piece size is always 1,1
     return new Vec2( .5f, .5f ) + index.ToVec2();
 }
Beispiel #7
0
        Vec2I GetNeededSize()
        {
            Vec2I result;

            ScreenControlManager screenControlManager = GetControlManager() as ScreenControlManager;

            if (screenControlManager != null)
            {
                //screen gui

                Vec2I viewportSize = screenControlManager.GuiRenderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size;

                Vec2 size = viewportSize.ToVec2() * GetScreenSize();
                if (screenControlManager.GuiRenderer._OutGeometryTransformEnabled)
                {
                    size *= screenControlManager.GuiRenderer._OutGeometryTransformScale;
                }

                result = new Vec2I((int)(size.X + .9999f), (int)(size.Y + .9999f));
            }
            else
            {
                //in-game gui

                int   height     = inGame3DGuiHeightInPixels;
                Vec2  screenSize = GetScreenSize();
                float width      = (float)height * (screenSize.X / screenSize.Y) * GetControlManager().AspectRatio;
                result = new Vec2I((int)(width + .9999f), height);

                //int height = inGame3DGuiHeightInPixels;
                //if( height > RenderSystem.Instance.Capabilities.MaxTextureSize )
                //   height = RenderSystem.Instance.Capabilities.MaxTextureSize;

                //Vec2 screenSize = GetScreenSize();
                //float width = (float)height * ( screenSize.X / screenSize.Y ) * GetControlManager().AspectRatio;
                //result = new Vec2I( (int)( width + .9999f ), height );
            }

            if (result.X < 1)
            {
                result.X = 1;
            }
            if (result.Y < 1)
            {
                result.Y = 1;
            }

            //fix max texture size
            if (result.X > RenderSystem.Instance.Capabilities.MaxTextureSize || result.Y > RenderSystem.Instance.Capabilities.MaxTextureSize)
            {
                float divideX = (float)result.X / (float)RenderSystem.Instance.Capabilities.MaxTextureSize;
                float divideY = (float)result.Y / (float)RenderSystem.Instance.Capabilities.MaxTextureSize;
                float divide  = Math.Max(Math.Max(divideX, divideY), 1);
                if (divide != 1)
                {
                    result = (result.ToVec2() / divide).ToVec2I();
                    if (result.X > RenderSystem.Instance.Capabilities.MaxTextureSize)
                    {
                        result.X = RenderSystem.Instance.Capabilities.MaxTextureSize;
                    }
                    if (result.Y > RenderSystem.Instance.Capabilities.MaxTextureSize)
                    {
                        result.Y = RenderSystem.Instance.Capabilities.MaxTextureSize;
                    }
                }
            }

            return(result);
        }
 public Vec2 GetPieceDestinationPosition(Vec2I index)
 {
     //piece size is always 1,1
     return(new Vec2(.5f, .5f) + index.ToVec2());
 }