Ejemplo n.º 1
0
        internal static void OnPaint(SceneView sceneView)
        {
            SceneDragToolManager.OnPaint();

            if (sceneView == null ||
                Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (RealtimeCSG.CSGSettings.GridVisible)
            {
                RealtimeCSG.CSGGrid.RenderGrid();
            }

            if (RealtimeCSG.CSGSettings.IsWireframeShown(sceneView))
            {
                if (forceOutlineUpdate || meshGeneration != InternalCSGModelManager.MeshGeneration)
                {
                    forceOutlineUpdate = false;
                    meshGeneration     = InternalCSGModelManager.MeshGeneration;
                    lineMeshManager.Begin();
                    for (int i = 0; i < InternalCSGModelManager.Brushes.Length; i++)
                    {
                        var brush = InternalCSGModelManager.Brushes[i];
                        if (!brush)
                        {
                            continue;
                        }

                        var brush_cache = InternalCSGModelManager.GetBrushCache(brush);
                        if (brush_cache == null)
                        {
                            continue;
                        }

                        if (!brush.outlineColor.HasValue)
                        {
                            brush.outlineColor = ColorSettings.GetBrushOutlineColor(brush);
                        }

                        var brush_translation = brush_cache.compareTransformation.modelLocalPosition +
                                                brush_cache.childData.ModelTransform.position;
                        CSGRenderer.DrawSimpleOutlines(lineMeshManager, brush.brushID, brush_translation, brush.outlineColor.Value);
                    }
                    lineMeshManager.End();
                }

                MaterialUtility.LineDashMultiplier      = 1.0f;
                MaterialUtility.LineThicknessMultiplier = 1.0f;
                MaterialUtility.LineAlphaMultiplier     = 1.0f;
                lineMeshManager.Render(MaterialUtility.NoZTestGenericLine);
            }
        }
Ejemplo n.º 2
0
        internal static void OnPaint(SceneView sceneView)
        {
            if (!sceneView)
            {
                return;
            }

            var camera = sceneView.camera;

            SceneDragToolManager.OnPaint(camera);

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (RealtimeCSG.CSGSettings.GridVisible)
            {
                RealtimeCSG.CSGGrid.RenderGrid(camera);
            }

            if (RealtimeCSG.CSGSettings.IsWireframeShown(sceneView))
            {
                if (forceOutlineUpdate || meshGeneration != InternalCSGModelManager.MeshGeneration)
                {
                    forceOutlineUpdate = false;
                    meshGeneration     = InternalCSGModelManager.MeshGeneration;
                    lineMeshManager.Begin();
                    for (int i = 0; i < InternalCSGModelManager.Brushes.Count; i++)
                    {
                        var brush = InternalCSGModelManager.Brushes[i];
                        if (!brush)
                        {
                            continue;
                        }

                        if (!brush.outlineColor.HasValue)
                        {
                            brush.outlineColor = ColorSettings.GetBrushOutlineColor(brush);
                        }

                        var brush_transformation = brush.compareTransformation.localToWorldMatrix;
                        CSGRenderer.DrawSimpleOutlines(lineMeshManager, brush.brushNodeID, brush_transformation, brush.outlineColor.Value);
                    }
                    lineMeshManager.End();
                }

                MaterialUtility.LineDashMultiplier      = 1.0f;
                MaterialUtility.LineThicknessMultiplier = 1.0f;
                MaterialUtility.LineAlphaMultiplier     = 1.0f;
                lineMeshManager.Render(MaterialUtility.NoZTestGenericLine);
            }
        }
        public void Update(SceneView sceneView, CSGBrush[] brushes, ControlMesh[] controlMeshes, ControlMeshState[] meshStates)
        {
            if (brushes.Length == 0)
            {
                _outlinesManager.Clear();
                _edgeColorsManager.Clear();
                _polygonManager.Clear();
                return;
            }

            _outlinesManager.Begin();
            _edgeColorsManager.Begin();
            _polygonManager.Begin();
            for (var t = 0; t < brushes.Length; t++)
            {
                var brush = brushes[t];
                if (!brush)
                {
                    continue;
                }

                var meshState = meshStates[t];
                if (meshState.WorldPoints.Length == 0 &&
                    meshState.Edges.Length == 0)
                {
                    continue;
                }

                if (!meshState.UpdateColors(sceneView, brush, controlMeshes[t]))
                {
                    continue;
                }

                _outlinesManager.DrawLines(meshState.WorldPoints, meshState.Edges, ColorSettings.MeshEdgeOutline, thickness: 1.0f);         //, zTest: false);
                _edgeColorsManager.DrawLines(meshState.WorldPoints, meshState.Edges, meshState.EdgeColors, thickness: 1.0f);                //, zTest: false);

                for (int p = 0; p < meshState.PolygonPointIndices.Length; p++)
                {
                    if (meshState.PolygonColors[p].a < (1.0f / 255.0f))
                    {
                        continue;
                    }

                    var color         = meshState.PolygonColors[p];
                    var polygonPoints = meshState.PolygonPointIndices[p];
                    _polygonManager.DrawPolygon(meshState.WorldPoints, polygonPoints, color);
                }
            }
            _polygonManager.End();
            _edgeColorsManager.End();
            _outlinesManager.End();
        }
Ejemplo n.º 4
0
        public static void DrawOutlines(LineMeshManager zTestLineMeshManager, LineMeshManager noZTestLineMeshManager,
                                        GeometryWireframe[] outlines, Matrix4x4[] transformations,
                                        Color outerColor, Color outerColorOccluded, Color innerColor, Color innerColorOccluded,
                                        float thickness = -1)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (outlines == null || transformations == null ||
                outlines.Length != transformations.Length)
            {
                zTestLineMeshManager.Clear();
                noZTestLineMeshManager.Clear();
                return;
            }

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

                    var transformation = transformations[i];

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        zTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor);                        //, zTest: true);
                        //PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor);//CustomWireMaterial
                    }

                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        zTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor);                        //, zTest: true);//CustomWireMaterial
                        //PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor);//CustomWireMaterial
                    }
                }
            }
            else
            {
                for (int i = 0; i < outlines.Length; i++)
                {
                    var outline = outlines[i];
                    if (outline == null ||
                        outline.vertices == null ||
                        outline.vertices.Length == 0)
                    {
                        continue;
                    }

                    var transformation = transformations[i];

                    if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                    {
                        //PaintUtility.DrawUnoccludedLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor);
                        zTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, outerColor, thickness: thickness);                        //, zTest: true);
                        //PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, thickness, outerColor);//CustomThickWireMaterial
                    }

                    if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                    {
                        //PaintUtility.DrawUnoccludedLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor);
                        zTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, innerColor, thickness: thickness);                        //, zTest: true);
                        //PaintUtility.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, thickness, innerColor);//CustomThickWireMaterial
                    }
                }
            }
            zTestLineMeshManager.End();

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


                var transformation = transformations[i];
                Handles.matrix = transformation;

                if (outline.visibleOuterLines != null && outline.visibleOuterLines.Length > 0)
                {
                    //Handles.color = outerColorOccluded;
                    //Handles.DrawDottedLines(outline.vertices, outline.visibleOuterLines, visibleOuterLineDots);	// internal
                    noZTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleOuterLines, outerColorOccluded, dashSize: visibleOuterLineDots);                    //, zTest: false);
                }

                if (outline.visibleInnerLines != null && outline.visibleInnerLines.Length > 0)
                {
                    //Handles.color = innerColorOccluded;
                    //Handles.DrawDottedLines(outline.vertices, outline.visibleInnerLines, visibleInnerLineDots); // internal
                    noZTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.visibleInnerLines, innerColorOccluded, dashSize: visibleInnerLineDots);                    //, zTest: false);
                }

                if (outline.invisibleOuterLines != null && outline.invisibleOuterLines.Length > 0)
                {
                    //Handles.color = outerColorOccluded;
                    //Handles.DrawDottedLines(outline.vertices, outline.invisibleOuterLines, invisibleOuterLineDots); // internal
                    noZTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleOuterLines, outerColorOccluded, dashSize: invisibleOuterLineDots);                    //, zTest: false);
                }
                if (outline.invisibleInnerLines != null && outline.invisibleInnerLines.Length > 0)
                {
                    //Handles.color = innerColor;
                    //Handles.DrawDottedLines(outline.vertices, outline.invisibleInnerLines, invisibleInnerLineDots); // internal
                    noZTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.invisibleInnerLines, innerColor, dashSize: invisibleInnerLineDots);                    //, zTest: false);
                }
#if TEST_ENABLED
                if (outline.invalidLines != null && outline.invalidLines.Length > 0)
                {
                    //Handles.color = Color.red;
                    //Handles.DrawDottedLines(outline.vertices, outline.invalidLines, invalidLineDots);   // internal
                    noZTestLineMeshManager.DrawLines(transformation, outline.vertices, outline.invalidLines, Color.red, dashSize: invalidLineDots);                    //, zTest: false);
                }
#endif
            }

            noZTestLineMeshManager.End();
        }
Ejemplo n.º 5
0
        internal static void OnPaint(SceneView sceneView)
        {
            if (!sceneView)
            {
                return;
            }

            SceneDragToolManager.OnPaint(sceneView);

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (RealtimeCSG.CSGSettings.GridVisible)
            {
                sceneView.showGrid = false;
                RealtimeCSG.CSGGrid.RenderGrid(sceneView);
            }

            if (RealtimeCSG.CSGSettings.IsWireframeShown(sceneView))
            {
                if (forceOutlineUpdate || meshGeneration != InternalCSGModelManager.MeshGeneration)
                {
                    forceOutlineUpdate = false;
                    meshGeneration     = InternalCSGModelManager.MeshGeneration;
                    lineMeshManager.Begin();
                    for (int i = 0; i < InternalCSGModelManager.Brushes.Count; i++)
                    {
                        var brush = InternalCSGModelManager.Brushes[i];

                        if (!brush)
                        {
                            continue;
                        }

                        //if (!brush.outlineColor.HasValue)
                        //                  {
                        //	//brush.outlineColor = ColorSettings.GetBrushOutlineColor(brush);
                        //	brush.outlineColor = ColorSettings.SimpleOutlineColor;
                        //}

                        var color      = Color.white;
                        var comparison = brush.OperationType;
                        var op         = brush.GetComponentInParent <CSGOperation>();
                        if (op)
                        {
                            comparison = op.OperationType;
                        }
                        switch (comparison)
                        {
                        case Foundation.CSGOperationType.Additive:
                            color = ColorSettings.SimpleOutlineAdditiveColor;
                            break;

                        case Foundation.CSGOperationType.Subtractive:
                            color = ColorSettings.SimpleOutlineSubtractiveColor;
                            break;

                        case Foundation.CSGOperationType.Intersecting:
                            color = ColorSettings.SimpleOutlineIntersectingColor;
                            break;
                        }

                        var brushTransformation = brush.compareTransformation.localToWorldMatrix;
                        CSGRenderer.DrawSimpleOutlines(lineMeshManager, brush.brushNodeID, brushTransformation, color);
                        CSGRenderer.DrawPolygonCenters(lineMeshManager, brush);
                    }
                    lineMeshManager.End();
                }

                MaterialUtility.LineDashMultiplier      = 1.0f;
                MaterialUtility.LineThicknessMultiplier = 1.0f;
                MaterialUtility.LineAlphaMultiplier     = 1.0f;
                lineMeshManager.Render(MaterialUtility.NoZTestGenericLine);
            }
        }