private void SetVerticies(Vector3 origin, float angle, List <Vector3> keyVerticies) { if (keyVerticies != null) { KeyTopVerticies = keyVerticies; } //Don't try and set the vertices if we're below the min we need for a plane if (BelowMinVerts()) { return; } if (vg.CurrentTerrainRule == null) { return; } TransformHelpers th = new TransformHelpers(); AllTopVerticies = vg.GenerateCalculatedVertices(KeyTopVerticies); //For the front plane, set a fixed lower boundary on the verts (bottom of mesh will be a straight line) if (PlaneType == Plane.Front) { Vector3 firstBottomVertex = AllTopVerticies[0]; Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y - settings.MainPlaneHeight, firstBottomVertex.z); AllBottomVerticies = th.MoveStartVertex(AllTopVerticies, AllTopVerticies[0], shift, true); KeyBottomVerticies = th.MoveStartVertex(KeyTopVerticies, AllTopVerticies[0], shift, true); //Test perp verts //Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y, firstBottomVertex.z); //AllBottomVerticies = th.GetPerpendicularOffset(AllTopVerticies, settings.MainPlaneHeight); //KeyBottomVerticies = th.GetPerpendicularOffset(KeyTopVerticies, settings.MainPlaneHeight); } if (PlaneType == Plane.Detail) { Vector3 firstBottomVertex = th.CopyVertex(AllTopVerticies[0]); Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y - settings.DetailPlaneHeight, firstBottomVertex.z); AllBottomVerticies = th.MoveStartVertex(AllTopVerticies, firstBottomVertex, shift, true); KeyBottomVerticies = th.MoveStartVertex(KeyTopVerticies, firstBottomVertex, shift, true); } //For the top of the mesh, shift the verticies in the z direction if (PlaneType == Plane.Top) { //The bottom verts are a copy of the top AllBottomVerticies = th.CopyList(AllTopVerticies); KeyBottomVerticies = th.CopyList(KeyTopVerticies); Vector3 firstBottomVertex = AllTopVerticies[0]; //Then shift the top verts into the z plane AllTopVerticies = th.MoveStartVertex(AllTopVerticies, AllTopVerticies[0], new Vector3(firstBottomVertex.x, firstBottomVertex.y, firstBottomVertex.z + settings.TopPlaneHeight), false); } //Now stich top and bottom verticies together into a plane PlaneVerticies = vg.GetPlaneVerticies(AllBottomVerticies, AllTopVerticies); //For the top plane we have to move our point of origin based on the plane height if (PlaneType == Plane.Top) { origin = new Vector3(origin.x, origin.y, origin.z + settings.TopPlaneHeight); } //Now move the whole plane to the point of origin (usually where the last mesh ended) //Move relative to the vertex at index 1 (the top of the plane) instead of zero (the bottom of the plane) since we want to match the top of the meshes PlaneVerticies = th.MoveStartVertex(PlaneVerticies, PlaneVerticies[1], origin, false); //Store the rotated verticies so we know where the actual end point of the mesh is (and where to start the next one) //Create the mesh from the rotate verticies, but generate it from the non-rotated ones if (angle != 0) { RotatedPlaneVerticies = th.RotateVertices(PlaneVerticies, angle); RotatedPlaneVerticies = th.MoveStartVertex(RotatedPlaneVerticies, RotatedPlaneVerticies[1], origin, false); } else { RotatedPlaneVerticies = PlaneVerticies; } }
private void SetVerticies(Vector3 origin, float angle, List<Vector3> keyVerticies) { if (keyVerticies !=null){KeyTopVerticies = keyVerticies;} //Don't try and set the vertices if we're below the min we need for a plane if (BelowMinVerts()){return;} if (vg.CurrentTerrainRule == null) { return; } TransformHelpers th = new TransformHelpers(); AllTopVerticies = vg.GenerateCalculatedVertices(KeyTopVerticies); //For the front plane, set a fixed lower boundary on the verts (bottom of mesh will be a straight line) if (PlaneType == Plane.Front) { Vector3 firstBottomVertex = AllTopVerticies[0]; Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y - settings.MainPlaneHeight, firstBottomVertex.z); AllBottomVerticies = th.MoveStartVertex(AllTopVerticies, AllTopVerticies[0], shift, true); KeyBottomVerticies = th.MoveStartVertex(KeyTopVerticies, AllTopVerticies[0], shift, true); //Test perp verts //Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y, firstBottomVertex.z); //AllBottomVerticies = th.GetPerpendicularOffset(AllTopVerticies, settings.MainPlaneHeight); //KeyBottomVerticies = th.GetPerpendicularOffset(KeyTopVerticies, settings.MainPlaneHeight); } if (PlaneType == Plane.Detail) { Vector3 firstBottomVertex = th.CopyVertex(AllTopVerticies[0]); Vector3 shift = new Vector3(firstBottomVertex.x, firstBottomVertex.y - settings.DetailPlaneHeight, firstBottomVertex.z); AllBottomVerticies = th.MoveStartVertex(AllTopVerticies,firstBottomVertex, shift, true); KeyBottomVerticies = th.MoveStartVertex(KeyTopVerticies, firstBottomVertex, shift, true); } //For the top of the mesh, shift the verticies in the z direction if (PlaneType == Plane.Top) { //The bottom verts are a copy of the top AllBottomVerticies = th.CopyList(AllTopVerticies); KeyBottomVerticies = th.CopyList(KeyTopVerticies); Vector3 firstBottomVertex = AllTopVerticies[0]; //Then shift the top verts into the z plane AllTopVerticies = th.MoveStartVertex(AllTopVerticies, AllTopVerticies[0], new Vector3(firstBottomVertex.x, firstBottomVertex.y, firstBottomVertex.z + settings.TopPlaneHeight), false); } //Now stich top and bottom verticies together into a plane PlaneVerticies = vg.GetPlaneVerticies(AllBottomVerticies, AllTopVerticies); //For the top plane we have to move our point of origin based on the plane height if (PlaneType == Plane.Top) { origin = new Vector3(origin.x, origin.y, origin.z + settings.TopPlaneHeight); } //Now move the whole plane to the point of origin (usually where the last mesh ended) //Move relative to the vertex at index 1 (the top of the plane) instead of zero (the bottom of the plane) since we want to match the top of the meshes PlaneVerticies = th.MoveStartVertex(PlaneVerticies, PlaneVerticies[1], origin, false); //Store the rotated verticies so we know where the actual end point of the mesh is (and where to start the next one) //Create the mesh from the rotate verticies, but generate it from the non-rotated ones if (angle!=0) { RotatedPlaneVerticies = th.RotateVertices(PlaneVerticies, angle); RotatedPlaneVerticies = th.MoveStartVertex(RotatedPlaneVerticies, RotatedPlaneVerticies[1], origin, false); } else { RotatedPlaneVerticies = PlaneVerticies; } }