/// <summary> /// create GeoSphere game object /// </summary> /// <param name="radius">radius of sphere</param> /// <param name="subdivision">number of subdivision</param> /// <param name="baseType">type of generation primitive</param> /// <param name="normals">type of normals to be generated</param> /// <param name="pivotPosition">position of the model pivot</param> /// <returns>GeoSphere class with GeoSphere game object</returns> public static GeoSphere Create(float radius, int subdivision, Primitives.GeoSpherePrimitive.BaseType baseType, NormalsType normals, PivotPosition pivotPosition) { var sphereObject = new GameObject("GeoSpherePro"); sphereObject.AddComponent <MeshFilter>(); var renderer = sphereObject.AddComponent <MeshRenderer>(); renderer.sharedMaterial = new Material(Shader.Find("Diffuse")); var sphere = sphereObject.AddComponent <GeoSphere>(); sphere.GenerateGeometry(radius, subdivision, baseType, normals, pivotPosition); return(sphere); }
/// <summary> /// create GeoSphere game object /// </summary> /// <param name="radius">radius of sphere</param> /// <param name="subdivision">number of subdivision</param> /// <param name="baseType">type of generation primitive</param> /// <param name="normalsType">type of normals to be generated</param> /// <param name="pivotPosition">position of the model pivot</param> public void GenerateGeometry(float radius, int subdivision, Primitives.GeoSpherePrimitive.BaseType baseType, NormalsType normalsType, PivotPosition pivotPosition) { // generate new mesh and clear old one var meshFilter = GetComponent <MeshFilter>(); if (meshFilter.sharedMesh == null) { meshFilter.sharedMesh = new Mesh(); } var mesh = meshFilter.sharedMesh; // geneate geometry GenerationTimeMS = Primitives.GeoSpherePrimitive.GenerateGeometry(mesh, radius, subdivision, baseType, normalsType, pivotPosition); this.radius = radius; this.subdivision = subdivision; this.baseType = baseType; this.normalsType = normalsType; this.flipNormals = false; this.pivotPosition = pivotPosition; }
/// <summary> /// create GeoSphere game object /// </summary> /// <param name="radius">radius of sphere</param> /// <param name="subdivision">number of subdivision</param> /// <param name="baseType">type of generation primitive</param> /// <param name="normalsType">type of normals to be generated</param> /// <param name="pivotPosition">position of the model pivot</param> public void GenerateGeometry(float radius, int subdivision, Primitives.GeoSpherePrimitive.BaseType baseType, NormalsType normalsType, PivotPosition pivotPosition) { // generate new mesh and clear old one var meshFilter = GetComponent<MeshFilter>(); if (meshFilter.sharedMesh == null) { meshFilter.sharedMesh = new Mesh(); } var mesh = meshFilter.sharedMesh; // geneate geometry GenerationTimeMS = Primitives.GeoSpherePrimitive.GenerateGeometry(mesh, radius, subdivision, baseType, normalsType, pivotPosition); this.radius = radius; this.subdivision = subdivision; this.baseType = baseType; this.normalsType = normalsType; this.flipNormals = false; this.pivotPosition = pivotPosition; }