コード例 #1
0
ファイル: DebugUtil.cs プロジェクト: rasmus-z/unity-cj-lib
        // ------------------------------------------------------------------------
        // end: circle


        // cylinder
        // ------------------------------------------------------------------------

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

            Mesh mesh = null;

            switch (style)
            {
            case Style.Wireframe:
                mesh = PrimitiveMeshFactory.CylinderWireframe(numSegments);
                break;

            case Style.SolidColor:
                mesh = PrimitiveMeshFactory.CylinderSolidColor(numSegments);
                break;

            case Style.FlatShaded:
                mesh = PrimitiveMeshFactory.CylinderFlatShaded(numSegments);
                break;

            case Style.SmoothShaded:
                mesh = PrimitiveMeshFactory.CylinderSmoothShaded(numSegments);
                break;
            }
            if (mesh == null)
            {
                return;
            }

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

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

            Graphics.DrawMesh(mesh, center, rotation, material, 0, null, 0, materialProperties, false, false, false);
        }