// ------------------------------------------------------------------------ // end: capsule // cone // ------------------------------------------------------------------------ public static void DrawCone(Vector3 baseCenter, 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.ConeWireframe(numSegments); break; case Style.SolidColor: mesh = PrimitiveMeshFactory.ConeSolidColor(numSegments); break; case Style.FlatShaded: mesh = PrimitiveMeshFactory.ConeFlatShaded(numSegments); break; case Style.SmoothShaded: mesh = PrimitiveMeshFactory.ConeSmoothShaded(numSegments); break; } if (mesh == null) { return; } Material material = GetMaterial(style, depthTest, false); MaterialPropertyBlock materialProperties = GetMaterialPropertyBlock(); materialProperties.SetColor("_Color", color); materialProperties.SetVector("_Dimensions", new Vector4(radius, height, radius, 0.0f)); materialProperties.SetFloat("_ZBias", (style == Style.Wireframe) ? s_wireframeZBias : 0.0f); Graphics.DrawMesh(mesh, baseCenter, rotation, material, 0, null, 0, materialProperties, false, false, false); }
// ------------------------------------------------------------------------ // end: capsule // cone // ------------------------------------------------------------------------ public static void DrawCone(Vector3 baseCenter, Quaternion rotation, float height, float radius, int numSegments, Color color, Style style = Style.FlatShaded) { if (height < MathUtil.Epsilon || radius < MathUtil.Epsilon) { return; } Mesh mesh = null; switch (style) { case Style.Wireframe: mesh = PrimitiveMeshFactory.ConeWireframe(numSegments); break; case Style.FlatShaded: mesh = PrimitiveMeshFactory.ConeFlatShaded(numSegments); break; case Style.SmoothShaded: mesh = PrimitiveMeshFactory.ConeSmoothShaded(numSegments); break; } if (mesh == null) { return; } Gizmos.color = color; if (style == Style.Wireframe) { Gizmos.DrawWireMesh(mesh, baseCenter, rotation, new Vector3(radius, height, radius)); } else { Gizmos.DrawMesh(mesh, baseCenter, rotation, new Vector3(radius, height, radius)); } }