Beispiel #1
0
    public void Draw()
    {
        if (!Visible)
        {
            return;
        }
        if (Enabled)
        {
            GL.Enable(EnableCap.StencilTest);
            GL.StencilFunc(StencilFunction.Always, Index, 0xff);
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
        }

        TKTools.Color c = Design.Tile == null ? Color : TKTools.Color.White;
        MeshProgram["enableTexture"].SetValue(Design.Tile != null);

        if (!Enabled && OptionsForm.options.FocusLayer)
        {
            MeshProgram["uniColor"].SetValue(c * OptionsForm.options.LayerOpacity);
        }
        else
        {
            MeshProgram["uniColor"].SetValue(c);
        }

        if (Design.Tile != null)
        {
            Design.Tile.Texture.Bind();
        }

        mesh.Draw(PrimitiveType.Polygon);
        GL.Disable(EnableCap.StencilTest);
    }
Beispiel #2
0
    public void DrawUI()
    {
        if (!Visible)
        {
            return;
        }
        if (!Enabled)
        {
            return;
        }

        GL.Enable(EnableCap.StencilTest);
        GL.StencilFunc(StencilFunction.Gequal, Index, 0xff);
        GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);

        MeshProgram["enableTexture"].SetValue(false);

        TKTools.Color color = Selected ? TKTools.Color.White : TKTools.Color.Yellow;
        if (!(Selected || Hovered))
        {
            color *= new TKTools.Color(1f, 1f, 1f, OptionsForm.options.MeshBorderOpacity);
        }

        MeshProgram["uniColor"].SetValue(color);

        if (Selected)
        {
            GL.LineWidth(2f);
        }

        if (OptionsForm.options.MeshBorders || Hovered || Selected)
        {
            mesh.Draw(PrimitiveType.LineLoop);
        }

        GL.LineWidth(1f);

        if (Hovered)
        {
            MeshProgram["uniColor"].SetValue(new TKTools.Color(1f, 1f, 1f,
                                                               (mouse[OpenTK.Input.MouseButton.Left] && !editor.DisableSelect && !editor.selectionBox.Active) ? 0.3f : 0.2f));
            mesh.Draw(PrimitiveType.Polygon);
        }

        //GL.Disable(EnableCap.StencilTest);

        if (editor.SelectMode == SelectMode.Vertices)
        {
            foreach (EVertex v in vertices)
            {
                v.Draw();
            }
        }
    }
Beispiel #3
0
        public void CreateCombinedMesh()
        {
            List <Texture>         textureList  = new List <Texture>();
            List <List <Vector3> > verticesList = new List <List <Vector3> >();
            List <List <Vector2> > uvList       = new List <List <Vector2> >();

            foreach (EnvObject obj in objects)
            {
                Texture t = obj.template.Texture;

                if (!textureList.Contains(t))
                {
                    textureList.Add(t);
                    verticesList.Add(new List <Vector3>());
                    uvList.Add(new List <Vector2>());
                }

                int id = textureList.IndexOf(t);
                verticesList[id].AddRange(obj.mesh.Vertices);
                uvList[id].AddRange(obj.mesh.UV);
            }

            for (int i = 0; i < textureList.Count; i++)
            {
                Mesh mesh = new Mesh();
                mesh.Vertices = verticesList[i].ToArray();
                mesh.UV       = uvList[i].ToArray();

                mesh.Texture = textureList[i];

                if (depth > 0f)
                {
                    mesh.FillColor = true;

                    TKTools.Color c1 = new TKTools.Color(87, 90, 74);
                    TKTools.Color c2 = new TKTools.Color(251, 236, 214);

                    mesh.Color = TKTools.Color.Blend(c1, c2, depth / 100f);
                }

                combinedMeshes.Add(mesh);
            }
        }
Beispiel #4
0
 public EnvEvent(int id, string name, TKTools.Color color)
 {
     this.id    = id;
     this.name  = name;
     this.color = color;
 }