Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active January 5, 2018 12:10
Show Gist options
  • Save ronyx69/2f4b08a45f3a14c585597c848a594150 to your computer and use it in GitHub Desktop.
Save ronyx69/2f4b08a45f3a14c585597c848a594150 to your computer and use it in GitHub Desktop.
For decal compatible ploppable asphalt + props. Tags props, disables ruining and automatically edits normals, scales mesh and paints vertices for main and LOD meshes.
// Ploppable Apshalt + (RoadBridge) used for asphalt and pavement.
// Automatic normal editing, mesh scaling and vertex painting for main and LOD meshes.
// Also removes ruining, and tags as ploppable asphalt prop.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
asset.m_UIPriority = 0; // Set your UI priority!
var triangles = asset.m_mesh.triangles;
int[] triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0); var temp = 0;
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_mesh.triangles = triangleArray;
Vector3[] vertices = asset.m_mesh.vertices;
Vector3[] vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_mesh.vertices = vertexArray;
Color nc = new Color(1,0,1);
Color[] colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_mesh.colors = colors;
triangles = asset.m_lodMesh.triangles;
triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0);
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_lodMesh.triangles = triangleArray;
vertices = asset.m_lodMesh.vertices;
vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_lodMesh.vertices = vertexArray;
colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_lodMesh.colors = colors;
asset.m_createRuining = false;
asset.m_mesh.name="ploppableasphalt-prop";
// Ploppable Apshalt + (TrainBridge) used for gravel.
// Automatic normal editing, mesh scaling and vertex painting for main and LOD meshes.
// Also removes ruining, and tags as ploppable asphalt prop.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
asset.m_UIPriority = 0; // Set your UI priority!
var triangles = asset.m_mesh.triangles;
int[] triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0); var temp = 0;
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_mesh.triangles = triangleArray;
Vector3[] vertices = asset.m_mesh.vertices;
Vector3[] vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_mesh.vertices = vertexArray;
Color nc = new Color(1,0,1);
Color[] colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_mesh.colors = colors;
triangles = asset.m_lodMesh.triangles;
triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0);
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_lodMesh.triangles = triangleArray;
vertices = asset.m_lodMesh.vertices;
vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_lodMesh.vertices = vertexArray;
colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_lodMesh.colors = colors;
asset.m_createRuining = false;
asset.m_mesh.name = "ploppablegravel";
// Ploppable Apshalt + (Road) used for grass and cliff.
// Automatic normal editing, mesh scaling and vertex painting for main and LOD meshes.
// Also removes ruining, and tags as ploppable asphalt prop.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
asset.m_UIPriority = 0; // Set your UI priority!
var triangles = asset.m_mesh.triangles;
int[] triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0); var temp = 0;
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_mesh.triangles = triangleArray;
asset.m_mesh.RecalculateNormals();
Vector3[] vertices = asset.m_mesh.vertices;
Vector3[] vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_mesh.vertices = vertexArray;
Color nc = new Color(1,0,1);
Color[] colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_mesh.colors = colors;
triangles = asset.m_lodMesh.triangles;
triangleArray = new int[triangles.Length];
triangles.CopyTo(triangleArray, 0);
for (int i = 0; i < triangles.Length; i += 3) {
temp = triangleArray[i+1];
triangleArray[i+1]=triangleArray[i+2];
triangleArray[i+2]=temp; }
asset.m_lodMesh.triangles = triangleArray;
asset.m_lodMesh.RecalculateNormals();
vertices = asset.m_lodMesh.vertices;
vertexArray = new Vector3[vertices.Length];
vertices.CopyTo(vertexArray, 0);
for (int i = 0; i < vertices.Length; i++) vertexArray[i].z=vertexArray[i].z*0.451f;
asset.m_lodMesh.vertices = vertexArray;
colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++) colors[i] = nc;
asset.m_lodMesh.colors = colors;
asset.m_createRuining = false;
asset.m_mesh.name = "ploppablecliffgrass";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment