Exemplo n.º 1
0
        public static void DrawTexGenOutlines(LineMeshManager visibleLinesMeshManager,
                                              LineMeshManager invisibleLinesMeshManager,
                                              PolygonMeshManager visibleSurfaceMeshManager,
                                              GeometryWireframe[] outlines, Vector3[] translations,
                                              //Int32 brushID, Shape shape, Vector3 translation, int texGenID,
                                              Color visibleInnerColor, Color visibleOuterColor, Color visibleOutlineColor,
                                              Color invisibleInnerColor, Color invisibleOuterColor, Color invisibleOutlineColor,
                                              Color surfaceColor,
                                              float thickness = ToolConstants.thickLineScale)
        {
            if (outlines == null)
            {
                return;
            }

            var translationMatrix = MathConstants.identityMatrix;

            if (invisibleOutlineColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline     = outlines[i];
                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;


                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, invisibleOutlineColor);
                    }
                    if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.invisibleOuterLines, invisibleOutlineColor);
                    }
                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, invisibleOutlineColor);
                    }
                    if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.invisibleInnerLines, invisibleOutlineColor);
                    }
                }
            }

            if (invisibleInnerColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline     = outlines[i];
                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, invisibleInnerColor, dashSize: visibleOuterLineDots);
                    }
                    if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.invisibleOuterLines, invisibleInnerColor, dashSize: invisibleOuterLineDots);
                    }
                }
            }


            if (invisibleOuterColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline     = outlines[i];
                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;

                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, invisibleOuterColor, dashSize: visibleInnerLineDots);
                    }
                    if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.invisibleInnerLines, invisibleOuterColor, dashSize: invisibleInnerLineDots);
                    }
                }
            }

            for (int i = 0; i < outlines.Length; i++)
            {
                var outline = outlines[i];
                if (outline.invalidLines == null || outline.invalidLines.Length == 0)
                {
                    continue;
                }

                var translation = translations[i];
                translationMatrix.m03 = translation.x;
                translationMatrix.m13 = translation.y;
                translationMatrix.m23 = translation.z;

                invisibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.invalidLines, Color.red, dashSize: invalidLineDots);
            }

            if (visibleOutlineColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, visibleOutlineColor, thickness: thickness + 2.0f);
                    }
                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, visibleOutlineColor, thickness: thickness + 2.0f);
                    }
                }
            }

            if (visibleOuterColor.a >= kMinAlpha || visibleInnerColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;

                    if (visibleInnerColor.a >= kMinAlpha && outline.visibleOuterLines != null && outline.visibleOuterLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleOuterLines, visibleInnerColor, thickness: thickness * 0.5f);
                    }
                    if (visibleOuterColor.a >= kMinAlpha && outline.visibleInnerLines != null && outline.visibleInnerLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(translationMatrix, outline.vertices, outline.visibleInnerLines, visibleOuterColor, thickness: thickness * 0.5f);
                    }
                }
            }

            if (surfaceColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    if (outline.visibleTriangles == null || outline.visibleTriangles.Length == 0)
                    {
                        continue;
                    }

                    var translation = translations[i];
                    translationMatrix.m03 = translation.x;
                    translationMatrix.m13 = translation.y;
                    translationMatrix.m23 = translation.z;

                    visibleSurfaceMeshManager.DrawTriangles(translationMatrix, outline.vertices, outline.visibleTriangles, surfaceColor);
                }
            }
        }
Exemplo n.º 2
0
        public static void DrawSurfaceOutlines(LineMeshManager visibleLinesMeshManager,
                                               LineMeshManager invisibleLinesMeshManager,
                                               PolygonMeshManager visibleSurfaceMeshManager,
                                               GeometryWireframe[] outlines,
                                               Matrix4x4[] transformations,
                                               Color visibleInnerColor, Color visibleOuterColor, Color visibleOutlineColor,
                                               Color invisibleInnerColor, Color invisibleOuterColor, Color invisibleOutlineColor,
                                               Color surfaceColor,
                                               float thickness = GUIConstants.thickLineScale)
        {
            if (outlines == null)
            {
                return;
            }

            if (invisibleOutlineColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline        = outlines[i];
                    var transformation = transformations[i];

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, invisibleOutlineColor);
                    }
                    if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleOuterLines, invisibleOutlineColor);
                    }
                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, invisibleOutlineColor);
                    }
                    if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleInnerLines, invisibleOutlineColor);
                    }
                }
            }

            if (invisibleInnerColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline        = outlines[i];
                    var transformation = transformations[i];

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, invisibleInnerColor, dashSize: visibleOuterLineDots);
                    }
                    if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleOuterLines, invisibleInnerColor, dashSize: invisibleOuterLineDots);
                    }
                }
            }


            if (invisibleOuterColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline        = outlines[i];
                    var transformation = transformations[i];

                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, invisibleOuterColor, dashSize: visibleInnerLineDots);
                    }
                    if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
                    {
                        invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleInnerLines, invisibleOuterColor, dashSize: invisibleInnerLineDots);
                    }
                }
            }

#if TEST_ENABLED
            for (int i = 0; i < outlines.Length; i++)
            {
                var outline = outlines[i];
                if (outline.invalidLines == null || outline.invalidLines.Length == 0)
                {
                    continue;
                }

                var transformation = transformations[i];

                invisibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.invalidLines, Color.red, dashSize: invalidLineDots);
            }
#endif

            if (visibleOutlineColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    var transformation = transformations[i];

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, visibleOutlineColor, thickness: thickness + 2.0f);
                    }
                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, visibleOutlineColor, thickness: thickness + 2.0f);
                    }
                }
            }

            if (visibleOuterColor.a >= kMinAlpha || visibleInnerColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    var transformation = transformations[i];

                    if (visibleInnerColor.a >= kMinAlpha && outline.visibleOuterLines != null && outline.visibleOuterLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, visibleInnerColor, thickness: thickness * 0.5f);
                    }
                    if (visibleOuterColor.a >= kMinAlpha && outline.visibleInnerLines != null && outline.visibleInnerLines.Length != 0)
                    {
                        visibleLinesMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, visibleOuterColor, thickness: thickness * 0.5f);
                    }
                }
            }

            if (surfaceColor.a >= kMinAlpha)
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];

                    if (outline.visibleTriangles == null || outline.visibleTriangles.Length == 0)
                    {
                        continue;
                    }

                    var transformation = transformations[i];

                    visibleSurfaceMeshManager.DrawTriangles(transformation, outline.vertices, outline.visibleTriangles, surfaceColor);
                }
            }
        }
Exemplo n.º 3
0
        public static void DrawTexGenOutlines(LineMeshManager visibleLinesMeshManager,
                                              LineMeshManager invisibleLinesMeshManager,
                                              PolygonMeshManager visibleSurfaceMeshManager,
                                              Int32 brushID, Shape shape, Vector3 translation, int texGenID,
                                              Color innerColor, Color outerColor, Color surfaceColor,
                                              float thickness = ToolConstants.thickLineScale)
        {
            // .. could be a prefab
            if (brushID == -1 ||
                texGenID == -1)
            {
                return;
            }

            if (texGenID < 0 ||
                texGenID >= shape.TexGens.Length)
            {
                return;
            }

            Vector3[] vertices            = null;
            Int32[]   visibleOuterLines   = null;
            Int32[]   visibleInnerLines   = null;
            Int32[]   visibleTriangles    = null;
            Int32[]   invisibleOuterLines = null;
            Int32[]   invisibleInnerLines = null;
            Int32[]   invalidLines        = null;

            if (!InternalCSGModelManager.External.GetTexGenOutline(
                    brushID,
                    texGenID,
                    ref vertices,
                    ref visibleOuterLines,
                    ref visibleInnerLines,
                    ref visibleTriangles,
                    ref invisibleOuterLines,
                    ref invisibleInnerLines,
                    ref invalidLines))
            {
                return;
            }

            var translationMatrix = MathConstants.identityMatrix;

            translationMatrix.m03 = translation.x;
            translationMatrix.m13 = translation.y;
            translationMatrix.m23 = translation.z;


            var dashInnerColor = innerColor;

            dashInnerColor.a *= 0.5f;

            if (dashInnerColor.a > 0)
            {
                if (visibleOuterLines != null && visibleOuterLines.Length > 0)
                {
                    invisibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleOuterLines, dashInnerColor, dashSize: visibleOuterLineDots);
                }
                if (invisibleOuterLines != null && invisibleOuterLines.Length > 0)
                {
                    invisibleLinesMeshManager.DrawLines(translationMatrix, vertices, invisibleOuterLines, dashInnerColor, dashSize: invisibleOuterLineDots);
                }
            }

            var dashOuterColor = outerColor;

            dashOuterColor.a *= 0.5f;

            if (dashOuterColor.a > 0)
            {
                if (visibleInnerLines != null && visibleInnerLines.Length > 0)
                {
                    invisibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleInnerLines, dashOuterColor, dashSize: visibleInnerLineDots);
                }
                if (invisibleInnerLines != null && invisibleInnerLines.Length > 0)
                {
                    invisibleLinesMeshManager.DrawLines(translationMatrix, vertices, invisibleInnerLines, dashOuterColor, dashSize: invisibleInnerLineDots);
                }
                if (invalidLines != null && invalidLines.Length > 0)
                {
                    invisibleLinesMeshManager.DrawLines(translationMatrix, vertices, invalidLines, Color.red, dashSize: invalidLineDots);
                }
            }

            innerColor.a = 1.0f;
            if (innerColor.a > 0 && visibleOuterLines != null && visibleOuterLines.Length > kMinAlpha)
            {
                visibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleOuterLines, ColorSettings.MeshEdgeOutline, thickness: thickness * 2.0f);
                visibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleOuterLines, innerColor, thickness: thickness);
            }

            outerColor.a = 1.0f;
            if (outerColor.a > 0 && visibleInnerLines != null && visibleInnerLines.Length > kMinAlpha)
            {
                visibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleInnerLines, ColorSettings.MeshEdgeOutline, thickness: thickness * 2.0f);
                visibleLinesMeshManager.DrawLines(translationMatrix, vertices, visibleInnerLines, outerColor, thickness: thickness);
            }

            if (visibleTriangles != null && visibleTriangles.Length > 0 && surfaceColor.a > kMinAlpha)
            {
                PaintUtility.DrawTriangles(translationMatrix, vertices, visibleTriangles, surfaceColor);
            }
        }