示例#1
0
        // ------------------------------------------------------------------------
        // end: cylinder


        // sphere
        // ------------------------------------------------------------------------

        public static void DrawSphere(Vector3 center, Quaternion rotation, float radius, int latSegments, int longSegments, Color color, bool depthTest = true, Style style = Style.Wireframe)
        {
            if (radius < MathUtil.Epsilon)
            {
                return;
            }

            Mesh mesh = null;

            switch (style)
            {
            case Style.Wireframe:
                mesh = PrimitiveMeshFactory.SphereWireframe(latSegments, longSegments);
                break;

            case Style.SolidColor:
                mesh = PrimitiveMeshFactory.SphereSolidColor(latSegments, longSegments);
                break;

            case Style.FlatShaded:
                mesh = PrimitiveMeshFactory.SphereFlatShaded(latSegments, longSegments);
                break;

            case Style.SmoothShaded:
                mesh = PrimitiveMeshFactory.SphereSmoothShaded(latSegments, longSegments);
                break;
            }
            if (mesh == null)
            {
                return;
            }

            Material material = GetMaterial(style, depthTest, false);
            MaterialPropertyBlock materialProperties = GetMaterialPropertyBlock();

            materialProperties.SetColor("_Color", color);
            materialProperties.SetVector("_Dimensions", new Vector4(radius, radius, radius, 0.0f));
            materialProperties.SetFloat("_ZBias", (style == Style.Wireframe) ? s_wireframeZBias : 0.0f);

            Graphics.DrawMesh(mesh, center, rotation, material, 0, null, 0, materialProperties, false, false, false);
        }
示例#2
0
        // ------------------------------------------------------------------------
        // end: cylinder


        // sphere
        // ------------------------------------------------------------------------

        public static void DrawSphere(Vector3 center, Quaternion rotation, float radius, int latSegments, int longSegments, Color color, Style style = Style.SmoothShaded)
        {
            if (radius < MathUtil.Epsilon)
            {
                return;
            }

            Mesh mesh = null;

            switch (style)
            {
            case Style.Wireframe:
                mesh = PrimitiveMeshFactory.SphereWireframe(latSegments, longSegments);
                break;

            case Style.FlatShaded:
                mesh = PrimitiveMeshFactory.SphereFlatShaded(latSegments, longSegments);
                break;

            case Style.SmoothShaded:
                mesh = PrimitiveMeshFactory.SphereSmoothShaded(latSegments, longSegments);
                break;
            }
            if (mesh == null)
            {
                return;
            }

            Gizmos.color = color;
            if (style == Style.Wireframe)
            {
                Gizmos.DrawWireMesh(mesh, center, rotation, new Vector3(radius, radius, radius));
            }
            else
            {
                Gizmos.DrawMesh(mesh, center, rotation, new Vector3(radius, radius, radius));
            }
        }