public void Create(VertexGenerator vg, Vector3 origin) { //Track the angle we are currenlty on TerrainAngle = vg.CurrentTerrainRule.Angle; //Create the front mesh and populate our key verts for the front plane MeshPiece mp = new MeshPiece(vg, MeshPiece.Plane.Front, settings); mp.PopulateKeyVerticies(MeshPiece.Plane.Front); //Now create the mesh mp.Create(origin, TerrainAngle); //The first mesh could be null if we are below the minimum verticies we need to create a plane if (mp.MeshObject != null) { //Create a placeholder object for our mesh pieces InstantiateTerrainObject(); //if (meshCollider == null) { // meshCollider = TerrainObject.AddComponent<MeshCollider>(); // meshCollider.convex = true; //} if (terrainCollider == null) { terrainCollider = TerrainObject.AddComponent <TerrainCollider>(); terrainCollider.material = new PhysicMaterial(); } //And add the front plane mesh piece to our list of meshes in the terrain piece MeshPieces.Add(mp); if (settings.DrawDetailMeshRenderer) { MeshPiece mpDetail = new MeshPiece(vg, MeshPiece.Plane.Detail, settings); mpDetail.Create(origin + settings.DetailPlaneOffset, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpDetail); } if (settings.DrawTopMeshCollider || settings.DrawTopMeshRenderer) { MeshPiece mpTop = new MeshPiece(vg, MeshPiece.Plane.Top, settings); mpTop.Create(mp.StartTopMesh, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpTop); } //Just to tidy up the heirarchy ParentMeshesToTerrainObject(); } }
public void Create(VertexGenerator vg, Vector3 origin) { //Track the angle we are currenlty on TerrainAngle = vg.CurrentTerrainRule.Angle; //Create the front mesh and populate our key verts for the front plane MeshPiece mp = new MeshPiece(vg, MeshPiece.Plane.Front, settings); mp.PopulateKeyVerticies(MeshPiece.Plane.Front); //Now create the mesh mp.Create(origin, TerrainAngle); //The first mesh could be null if we are below the minimum verticies we need to create a plane if (mp.MeshObject != null){ //Create a placeholder object for our mesh pieces InstantiateTerrainObject(); //And add the front plane mesh piece to our list of meshes in the terrain piece MeshPieces.Add(mp); if (settings.DrawDetailMeshRenderer) { MeshPiece mpDetail = new MeshPiece(vg, MeshPiece.Plane.Detail, settings); mpDetail.Create(origin + settings.DetailPlaneOffset, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpDetail); } if (settings.DrawTopMeshCollider || settings.DrawTopMeshRenderer) { MeshPiece mpTop = new MeshPiece(vg, MeshPiece.Plane.Top, settings); mpTop.Create(mp.StartTopMesh, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpTop); } //Just to tidy up the heirarchy ParentMeshesToTerrainObject(); } }
public void Create(VertexGenerator vg, Vector3 origin, Transform newParent) { //Track the angle we are currenlty on TerrainAngle = vg.CurrentTerrainRule.Angle; //Create the front mesh and populate our key verts for the front plane MeshPiece mp = new MeshPiece(vg, MeshPiece.Plane.Front, settings); mp.PopulateKeyVerticies(MeshPiece.Plane.Front); //Now create the mesh mp.Create(origin, TerrainAngle); //The first mesh could be null if we are below the minimum verticies we need to create a plane if (mp.MeshObject != null) { //Create a placeholder object for our mesh pieces InstantiateTerrainObject(origin.x, newParent); //And add the front plane mesh piece to our list of meshes in the terrain piece MeshPieces.Add(mp); if (settings.DrawDetailMeshRenderer) { MeshPiece mpDetail = new MeshPiece(vg, MeshPiece.Plane.Detail, settings); mpDetail.Create(origin + settings.DetailPlaneOffset, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpDetail); } if (settings.DrawTopMeshCollider || settings.DrawTopMeshRenderer) { MeshPiece mpTop = new MeshPiece(vg, MeshPiece.Plane.Top, settings); mpTop.Create(mp.StartTopMesh, TerrainAngle, mp.KeyTopVerticies); if (settings.TopPhysicsMaterial2D != null) { mpTop.edgeCollider.sharedMaterial = settings.TopPhysicsMaterial2D; // assign Physics Material if any } if (settings.TerrainLayer != 0) { mpTop.MeshObject.layer = settings.TerrainLayer; // assign Layer if any } MeshPieces.Add(mpTop); } //Just to tidy up the heirarchy ParentMeshesToTerrainObject(); } }