コード例 #1
0
ファイル: RenderingContext.cs プロジェクト: benjy3gg/PoeHud
 public RenderingContext(Device dx, GameWindow window)
 {
     this.Dx = dx;
     this.window = window;
     this.textSprite = new Sprite(dx);
     this.texrenderer = new TextureRenderer(dx);
 }
コード例 #2
0
    public void DrawMesh(MeshData meshData, Texture2D texture)
    {
        MeshFilter meshFilter = GetComponent <MeshFilter>();

        Mesh mesh = meshData.CreateMesh();

        meshFilter.sharedMesh = mesh;

        TextureRenderer renderer = GetComponent <TextureRenderer>();

        renderer.DrawTexture(texture);
    }
コード例 #3
0
        public override void Render(Vector2 windowSize)
        {
            foreach (Numbers number in background)
            {
                Vector2 position = number.Position;
                position.Y = (float)Math.Round(position.Y);
                position  *= 16;

                for (int i = 0; i < number.Values.Count; i++)
                {
                    int value = number.Values[i];
                    TextureRenderer.Draw(Textures.Get("Font"), position - new Vector2(0, i * 16), Vector2.One * 2, number.Color, new RectangleF(((value + 16) % 16) * 6, ((value + 16) / 16) * 6, 6, 6));
                }
            }

            if (!clickedNums.All(x => x == null))
            {
                string s = "";
                for (int i = maxNums - 1; i >= 0; i--)
                {
                    s += clickedNums[i].ToString();
                }

                TextBlock number = new TextBlock(s, 3);
                if (correctAnimation > 0)
                {
                    number.Color = (correctAnimation / 10) % 2 == 0 ? Color.Green : Color.White;
                }
                else if (wrongAnimation > 0)
                {
                    number.Color = (wrongAnimation / 10) % 2 == 0 ? Color.Red : Color.White;
                }
                else
                {
                    number.Color = Color.White;
                }

                number.SetConstraints(
                    new PixelConstraint(20),
                    new PixelConstraint(20, RelativeTo.Window, Direction.Bottom),
                    new PixelConstraint((int)number.TextWidth),
                    new PixelConstraint((int)number.TextHeight));

                number.Render(windowSize);
                number.Dispose();
            }

            ui.Render(windowSize);
        }
コード例 #4
0
ファイル: MainMenu.cs プロジェクト: JGDoerrer/KreativerName
        public override void Render(Vector2 windowSize)
        {
            // Render background
            float w = windowSize.X / (layout.size * sqrt3) + 8;
            float h = windowSize.Y / (layout.size * 1.5f) + 8;

            for (int y = -4; y < h - 4; y++)
            {
                for (int x = -(y / 2) - 4; x < w - (y + 1) / 2; x++)
                {
                    TextureRenderer.DrawHex(Textures.Get("Hex\\0"), new HexPoint(x, y), layout, Vector2.One, Color.FromArgb(10, 10, 10), new RectangleF(0, 0, 32, 32));
                }
            }

            ui.Render(windowSize);
        }
コード例 #5
0
        public InterfaceManager(ContentManager content)
        {
            fontLibrary = new Library();
            fontFace    = new Face(fontLibrary, "Content/Fonts/Jack.ttf");
            fontFace.SetCharSize(0, 18f, 0, 0);

            textureRenderer = new TextureRenderer(content, 800, 450);
            shapeRenderer   = new ShapeRenderer(content, 800, 450);
            stringRenderer  = new StringRenderer();

            shapeRenderer.Begin();
            shapeRenderer.SetProjection(Matrix4.CreateOrthographicOffCenter(0f, 800f, 450f, 0f, -1f, 1f));
            shapeRenderer.End();

            screens = new Dictionary <string, Screen>();
            screens.Add("MainMenu", new MainMenu(this));
            screens.Add("GameOverlay", new GameOverlay(this));

            ChangeScreen("GameOverlay");
        }
コード例 #6
0
ファイル: Button.cs プロジェクト: JGDoerrer/KreativerName
        public override void Render(Vector2 windowSize)
        {
            const int   a     = 8;
            const float scale = 2;

            float x = GetX(windowSize);
            float y = GetY(windowSize);
            float w = GetWidth(windowSize);
            float h = GetHeight(windowSize);

            float     state = State * a * 3;
            float     style = Style * a * 3;
            Color     color = Color;
            Texture2D tex   = Textures.Get("Button");

            if (!Enabled)
            {
                color = Color.FromArgb(Color.R / 2, Color.B / 2, Color.G / 2);
            }

            float[] xs = { x, x + a * scale, x + w - a * scale };
            float[] ys = { y, y + a * scale, y + h - a * scale };

            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    Vector2 scl = new Vector2(i == 1 ? w / (a * scale) - 2 : 1,
                                              j == 1 ? h / (a * scale) - 2 : 1) * scale;

                    TextureRenderer.Draw(tex, new Vector2(xs[i], ys[j]), scl, color, new RectangleF(state + a * i, style + a * j, a, a));
                }
            }

            RenderChildren(windowSize);
        }
コード例 #7
0
        public InputBox(string text, Point position, Vector2?size, SpriteFont font, Color foregroundColor, Color backgroundColor)
        {
            Text     = text;
            Position = position;
            if (size != null)
            {
                Size = size.Value;
            }
            else
            {
                //todo auto calculate rect's size
            }
            Font            = font;
            ForegroundColor = foregroundColor;
            BackgroundColor = backgroundColor;
            CursorPosition  = 0;
            maxTextLength   = FindMaxTextLength();
            textSpacing     = rect.Width / maxTextLength;
            ignoreCharacter = new List <char>();

            rectTexture = TextureRenderer.Render(CONTENT_MANAGER.spriteBatch, new Vector2(rect.Width, rect.Height), Vector2.Zero, backgroundColor, 1, Primitive2DActionGenerator.DrawRectangle(new Rectangle(0, 0, rect.Width, rect.Height), backgroundColor));

            CONTENT_MANAGER.GameInstance.Window.TextInput += TextInputHandler;
        }
コード例 #8
0
 public ChampionMirrorRenderer(ChampionDecoration graphics, Texture2D mirror, Texture2D face) : base(mirror, graphics)
 {
     faceRenderer = new TextureRenderer((Matrix.CreateScale(0.25f) * Matrix.CreateTranslation(-Vector3.UnitZ * 0.497f)), face);
 }
コード例 #9
0
 public LootContainer(string name, bool isOneTime, Bag bag)
     : base(name, true, bag)
 {
     Renderer = new TextureRenderer("builds/containers", new Point(0, 0));
 }
コード例 #10
0
 public LootContainer(Character character)
     : base(character.Name, true, character.Bag)
 {
     Position = (Position)Location.Current.Location.FindFreeSpaceForBuild(character.Position);
     Renderer = new TextureRenderer("builds/containers", new Point(0, 0));
 }
コード例 #11
0
 public VideoPlayer3D(DuiBrowser browser, TextureRenderer textureRenderer, string screenName)
 {
     this.textureRenderer = textureRenderer;
     this.ScreenName      = screenName;
     this.Browser         = browser;
 }
コード例 #12
0
ファイル: Chest.cs プロジェクト: Gandifil/Askalhorn
 public Chest(Bag bag)
     : base("сундук", false, bag)
 {
     Renderer = new TextureRenderer("grassland_tiles", new Point(0, 4));
 }
コード例 #13
0
    // wait for the first web cam frame to set config structs with correct size values
    // (mWebCamTexture.width and height are set to default values before the first frame is captured)
    public void Update()
    {
        if (!IsTextureSizeAvailable && mWebCamTexture.DidUpdateThisFrame)
        {
            QCARRenderer.Vec2I resampledSize = mWebCamProfile.ResampledTextureSize;

                mVideoModeData = new CameraDevice.VideoModeData
                                     {
                                         width = resampledSize.x,
                                         height = resampledSize.y,
                                         frameRate = mWebCamProfile.RequestedFPS // real fps not known, but not used in Unity any way...
                                     };

                mVideoTextureInfo = new QCARRenderer.VideoTextureInfo
                                        {
                                            imageSize = resampledSize,
                                            textureSize = resampledSize
                                        };

                mTextureRenderer = new TextureRenderer(mWebCamTexture.Texture, mRenderTextureLayer, resampledSize);
                mBufferReadTexture = new Texture2D(resampledSize.x, resampledSize.y);
                mReadPixelsRect = new Rect(0, 0, resampledSize.x, resampledSize.y);

            IsTextureSizeAvailable = true;
        }

        // turn on and off BGRenderingBehaviour depending if Background Rendering has been enabled or not:
        mBgRenderingTexBehaviour.CheckAndSetActive(QCARRenderer.Instance.DrawVideoBackground);
    }
コード例 #14
0
    private void DrawBakeSetting(Rect rect)
    {
        bool guienable = GUI.enabled;

        GUI.enabled = guienable && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None;
        GUI.BeginGroup(new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10));

        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        GUI.Label(new Rect(0, 0, position.width - 10, 17), "区域设置");
        m_MaxHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 20, rect.width - 10, 17),
                                                     new GUIContent("上方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整上方高度直到超过所有物体"),
                                                     m_MaxHeight));
        m_MinHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 40, rect.width - 10, 17),
                                                     new GUIContent("下方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整下方高度直到刚好超过水底最深处"),
                                                     m_MinHeight));

        GUI.enabled   = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable && m_MeshGeneratorType == MeshGeneratorType.ModelFile;
        m_LocalCenter = EditorGUI.Vector2Field(new Rect(0, 60, rect.width - 10, 40),
                                               new GUIContent("位置偏移", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的坐标偏移"),
                                               m_LocalCenter);


        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        m_RotY      = EditorGUI.FloatField(new Rect(0, 100, rect.width - 10, 17),
                                           new GUIContent("Y轴旋转", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的Y轴旋转"),
                                           m_RotY);

        GUI.Label(new Rect(0, 120, position.width - 10, 17), "渲染设置");
        m_TextureRendererType = (TextureRendererType)EditorGUI.EnumPopup(new Rect(0, 140, rect.width - 10, 17), "贴图渲染器类型", m_TextureRendererType);


        GUILayout.BeginArea(new Rect(0, 160, rect.width - 10, rect.height - 160));

        TextureRenderer renderer = textureRenderer;

        if (renderer != null)
        {
            renderer.DrawGUI();
        }

        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("渲染", GUIStyleCache.GetStyle("ButtonLeft"), GUILayout.Width(rect.width * 0.5f - 5)))
        {
            if (renderer != null)
            {
                Vector2 size = m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType);
                renderer.RenderDepthTexture(m_TargetGameObject, m_LocalCenter, size,
                                            Quaternion.Euler(90, m_RotY, 0), m_MaxHeight, m_MinHeight, ref m_Texture);
            }
        }
        GUI.enabled = m_Texture != null && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        if (m_MeshGeneratorType != MeshGeneratorType.ModelFile)
        {
            if (GUILayout.Button("生成Mesh", GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.GenerateMesh(m_TargetGameObject, m_Texture, meshGenerator);
            }
        }
        else
        {
            if (GUILayout.Button("应用到顶点色", GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.ApplyToVertexColor(m_TargetGameObject, m_Texture, m_LocalCenter, m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType), m_MinHeight, m_MaxHeight);
            }
        }
        GUILayout.EndHorizontal();

        GUI.enabled = guienable;

        GUILayout.EndArea();

        GUI.EndGroup();
    }
コード例 #15
0
ファイル: SuperSampling.cs プロジェクト: Arafo/Syncopia
    public void Start()
    {
        screenWidth = Screen.width;
        screenHeight = Screen.height;
        int num = (int)((float)Screen.width * scaleWidth);
        int num2 = (int)((float)Screen.height * scaleHeight);

        if (renderTexture == null || renderTexture.width != num || renderTexture.height != num2) {
            if (renderTexture != null) {
                renderTexture.Release();
            }
            renderTexture = new RenderTexture(num, num2, 24, 0);
            renderTexture.name = "SamplingTexture";
        }

        instance = this;

        if (renderCam == null) {
            renderCam = new GameObject("SamplingCamera");
            Camera camera = renderCam.AddComponent<Camera>();
            camera.CopyFrom(camara);
            camera.cullingMask = 0;
            camera.targetTexture = null;
            textureRenderer = renderCam.AddComponent<TextureRenderer>();

            if (SamplingShader != null) {
                switch (filter) {
                    case 0:
                        textureRenderer.samplingMaterial = new Material(SamplingShader[0]);
                        break;
                    case 1:
                        textureRenderer.samplingMaterial = new Material(SamplingShader[1]);
                        break;
                    case 2:
                        textureRenderer.samplingMaterial = null;
                        break;
                }
            }
        }
        active = true;
    }
コード例 #16
0
ファイル: TextBox.cs プロジェクト: JGDoerrer/KreativerName
        public override void Render(Vector2 windowSize)
        {
            const int   a     = 8;
            const float scale = 2;

            float x = GetX(windowSize);
            float y = GetY(windowSize);
            float w = GetWidth(windowSize);
            float h = GetHeight(windowSize);

            float     offset = 0;
            Color     color;
            Texture2D tex = Textures.Get("TextBox");

            if (MouseOver(windowSize) || Focused)
            {
                if (MouseLeftDown)
                {
                    color = Color.FromArgb(100, 100, 100);
                }
                else
                {
                    color = Color.FromArgb(150, 150, 150);
                }
            }
            else
            {
                color = Color.FromArgb(255, 255, 255);
            }

            if (!Enabled)
            {
                color = Color.FromArgb(color.R / 2, color.B / 2, color.G / 2);
            }

            float[] xs = { x, x + a * scale, x + w - a * scale };
            float[] ys = { y, y + a * scale, y + h - a * scale };

            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    Vector2 scl = new Vector2(i == 1 ? w / (a * scale) - 2 : 1,
                                              j == 1 ? h / (a * scale) - 2 : 1) * scale;

                    TextureRenderer.Draw(tex, new Vector2(xs[i], ys[j]), scl, color, new RectangleF(offset + a * i, a * j, a, a));
                }
            }

            StringBuilder text = new StringBuilder(Text.PadRight(MaxTextSize));

            if ((cursorAnim / 30) % 2 == 0 && Focused)
            {
                text[Cursor] = '_';
            }

            Rendering.TextRenderer.RenderString(text.ToString(), new Vector2(GetX(windowSize), GetY(windowSize)) + TextOffset, TextColor, w - TextOffset.X * 3, TextSize);

            RenderChildren(windowSize);
            cursorAnim++;
        }
コード例 #17
0
ファイル: TextureRenderer.cs プロジェクト: ThomasSchemmer/SDF
 public void Start()
 {
     instance = this;
 }
コード例 #18
0
 public TextureHandler(ContentManager contentManager, GraphicsDeviceControl graphicsDeviceControl)
     : base(contentManager, graphicsDeviceControl)
 {
     _textureRenderer = new TextureRenderer(graphicsDeviceControl, graphicsDeviceControl.GraphicsDevice);
 }