private void SetMesh(MESH_TYPE mt, ref MeshGenerator mg) { switch (mt) { case MESH_TYPE.QUAD: mg = MeshGenerator.Quad(fParameter1, iParameter1); break; case MESH_TYPE.CUBE: mg = MeshGenerator.Cube(fParameter1, iParameter1); break; case MESH_TYPE.SPHERE: mg = MeshGenerator.Sphere(fParameter1, iParameter1, iParameter2); break; case MESH_TYPE.CYLINDER: mg = MeshGenerator.Cylinder(fParameter1, fParameter2, iParameter1); break; case MESH_TYPE.CONE: mg = MeshGenerator.Cone(fParameter1, fParameter2, iParameter1); break; default: return; } }
//this function is to only be used AFTER the new importer added NEW metadata and needs to populate old values //if you use the old importer and had old data, this will ruin the world. we will all cry, and everything will be aweful. I think I spelled awful incorrectly. private void DownConvertDarwinSpecToProtoSpec() { this.vendorId = "DAZ3D"; this.versionId = this.mcs_version.ToString(); this.meshType = ItemFunctionToMeshType(this.function); this.geometryId = this.item_name; this.ID = this.item_id; if (this.function != ItemFunction.figure) { if (this.compatibilities.figures.Length != 0) { Debug.Log("this.compatibilities.figures is not null"); this.compatabilityBase = this.compatibilities.figures[0]; } } else { this.compatabilityBase = this.item_name; } //declarativeUse; //controllerScales; MCS.FOUNDATIONS.CoreMesh core_mesh = GetComponent <MCS.FOUNDATIONS.CoreMesh>(); if (core_mesh != null) { //Debug.Log("Core Mesh != null "); core_mesh.dazName = geometryId; core_mesh.ID = ID; core_mesh.meshType = meshType; } }
public Effect AskForEffect(MESH_TYPE tipo) { switch (tipo) { case MESH_TYPE.DEFAULT: return(null); case MESH_TYPE.SHADOW: return(shader); case MESH_TYPE.DEAD: return(shader); case MESH_TYPE.DYNAMIC_ILLUMINATION: return(shader); case MESH_TYPE.DYNAMIC_ILLUMINATION_METALLIC: return(shader); default: return(null); } }
public void Display() { meshTypeSelection = (MESH_TYPE)EditorGUILayout.EnumPopup("Mesh type:", meshTypeSelection); if (meshTypeSelection == MESH_TYPE.LOAD_FILE) { if (GUILayout.Button("Open file")) { meshFilePath = EditorUtility.OpenFolderPanel("Load mesh", "", ""); } if (meshFilePath != "") { EditorGUILayout.TextArea(meshFilePath); } } else { MeshSetupGUI(meshTypeSelection); } }
private void MeshSetupGUI(MESH_TYPE mt) { switch (mt) { case MESH_TYPE.QUAD: case MESH_TYPE.CUBE: fParameter1 = EditorGUILayout.FloatField("Size:", fParameter1); iParameter1 = EditorGUILayout.IntField("Meridians count:", iParameter1); break; case MESH_TYPE.SPHERE: fParameter1 = EditorGUILayout.FloatField("Radius:", fParameter1); iParameter1 = EditorGUILayout.IntField("Meridians count:", iParameter1); iParameter2 = EditorGUILayout.IntField("Parallels count: ", iParameter2); break; case MESH_TYPE.CYLINDER: case MESH_TYPE.CONE: fParameter1 = EditorGUILayout.FloatField("Height:", fParameter1); fParameter2 = EditorGUILayout.FloatField("Radius:", fParameter2); iParameter1 = EditorGUILayout.IntField("Meridians count: ", iParameter1); break; } }
// ------------------------------------------------------------------------------------------ public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType) { // Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset); // m_MeshType, m_AlignType Vector3[] planeVertices; Vector2 texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y); float fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f*texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f*texScale.y : 0)); Rect frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset; if (bTrimCenterAlign) frameUvOffset.center = Vector2.zero; // Vertices planeVertices = new Vector3[4]; planeVertices[0] = new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight); planeVertices[1] = new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight); planeVertices[2] = new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight); planeVertices[3] = new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight); // Color Color[] colors = new Color[4]; colors[0] = Color.white; colors[1] = Color.white; colors[2] = Color.white; colors[3] = Color.white; // Normals Vector3[] normals = new Vector3[4]; normals[0] = new Vector3(0, 0, -1.0f); normals[1] = new Vector3(0, 0, -1.0f); normals[2] = new Vector3(0, 0, -1.0f); normals[3] = new Vector3(0, 0, -1.0f); // Tangents Vector4[] tangents = new Vector4[4]; tangents[0] = new Vector4(1, 0, 0, -1.0f); tangents[1] = new Vector4(1, 0, 0, -1.0f); tangents[2] = new Vector4(1, 0, 0, -1.0f); tangents[3] = new Vector4(1, 0, 0, -1.0f); // Triangles int[] triangles; if (m_MeshType == MESH_TYPE.BuiltIn_Plane) { triangles = new int[6]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; } else { triangles = new int[12]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; triangles[6] = 1; triangles[7] = 0; triangles[8] = 3; triangles[9] = 3; triangles[10] = 2; triangles[11] = 1; } // Uv Vector2[] uvs = new Vector2[4]; uvs[0] = new Vector2(1, 1); uvs[1] = new Vector2(1, 0); uvs[2] = new Vector2(0, 0); uvs[3] = new Vector2(0, 1); meshFilter.mesh.Clear(); meshFilter.mesh.vertices = planeVertices; meshFilter.mesh.colors = colors; meshFilter.mesh.normals = normals; meshFilter.mesh.tangents = tangents; meshFilter.mesh.triangles = triangles; meshFilter.mesh.uv = uvs; meshFilter.mesh.RecalculateBounds(); // for (int n = 0; n < meshFilter.mesh.vertices.Length; n++) // Debug.Log(meshFilter.mesh.vertices[n]); }
// ------------------------------------------------------------------------------------------ public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType, float fHShowRate) { // Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset); // m_MeshType, m_AlignType Vector3[] planeVertices; Vector2 texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y); float fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f * texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f * texScale.y : 0)); float fHAlignHeight = (alignType == ALIGN_TYPE.LEFTCENTER ? 1.0f * texScale.x : (alignType == ALIGN_TYPE.RIGHTCENTER ? -1.0f * texScale.x : 0)); Rect frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset; if (bTrimCenterAlign) { frameUvOffset.center = Vector2.zero; } // Vertices planeVertices = new Vector3[4]; if (alignType == ALIGN_TYPE.LEFTCENTER && 0 < fHShowRate) { planeVertices[0] = new Vector3(frameUvOffset.xMax * texScale.x * fHShowRate + fHAlignHeight * fHShowRate, frameUvOffset.yMax * texScale.y + fVAlignHeight); planeVertices[1] = new Vector3(frameUvOffset.xMax * texScale.x * fHShowRate + fHAlignHeight * fHShowRate, frameUvOffset.yMin * texScale.y + fVAlignHeight); } else { planeVertices[0] = new Vector3(frameUvOffset.xMax * texScale.x + fHAlignHeight, frameUvOffset.yMax * texScale.y + fVAlignHeight); planeVertices[1] = new Vector3(frameUvOffset.xMax * texScale.x + fHAlignHeight, frameUvOffset.yMin * texScale.y + fVAlignHeight); } planeVertices[2] = new Vector3(frameUvOffset.xMin * texScale.x + fHAlignHeight, frameUvOffset.yMin * texScale.y + fVAlignHeight); planeVertices[3] = new Vector3(frameUvOffset.xMin * texScale.x + fHAlignHeight, frameUvOffset.yMax * texScale.y + fVAlignHeight); Color defColor = Color.white; if (meshFilter.mesh.colors != null && 0 < meshFilter.mesh.colors.Length) { defColor = meshFilter.mesh.colors[0]; } // Color Color[] colors = new Color[4]; colors[0] = defColor; colors[1] = defColor; colors[2] = defColor; colors[3] = defColor; // Normals Vector3[] normals = new Vector3[4]; normals[0] = Vector3.back; normals[1] = Vector3.back; normals[2] = Vector3.back; normals[3] = Vector3.back; // Tangents Vector4[] tangents = new Vector4[4]; tangents[0] = new Vector4(1, 0, 0, -1.0f); tangents[1] = new Vector4(1, 0, 0, -1.0f); tangents[2] = new Vector4(1, 0, 0, -1.0f); tangents[3] = new Vector4(1, 0, 0, -1.0f); // Triangles int[] triangles; if (m_MeshType == MESH_TYPE.BuiltIn_Plane) { triangles = new int[6]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; } else { triangles = new int[12]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; triangles[6] = 1; triangles[7] = 0; triangles[8] = 3; triangles[9] = 3; triangles[10] = 2; triangles[11] = 1; } // Uv Vector2[] uvs = new Vector2[4]; float fHUvRate = 1; if (alignType == ALIGN_TYPE.LEFTCENTER && 0 < fHShowRate) { fHUvRate = fHShowRate; } uvs[0] = new Vector2(fHUvRate, 1); uvs[1] = new Vector2(fHUvRate, 0); uvs[2] = new Vector2(0, 0); uvs[3] = new Vector2(0, 1); meshFilter.mesh.Clear(); meshFilter.mesh.vertices = planeVertices; meshFilter.mesh.colors = colors; meshFilter.mesh.normals = normals; meshFilter.mesh.tangents = tangents; meshFilter.mesh.triangles = triangles; meshFilter.mesh.uv = uvs; meshFilter.mesh.RecalculateBounds(); // for (int n = 0; n < meshFilter.mesh.vertices.Length; n++) // Debug.Log(meshFilter.mesh.vertices[n]); }
// ------------------------------------------------------------------------------------------ public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, ALIGN_TYPE alignType, MESH_TYPE m_MeshType) { // Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset); // m_MeshType, m_AlignType Vector3[] planeVertices; Vector2 texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y); float fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f * texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f * texScale.y : 0)); // Vertices planeVertices = new Vector3[4]; planeVertices[0] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMax * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMax * texScale.y + fVAlignHeight); planeVertices[1] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMax * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMin * texScale.y + fVAlignHeight); planeVertices[2] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMin * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMin * texScale.y + fVAlignHeight); planeVertices[3] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMin * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMax * texScale.y + fVAlignHeight); // Color Color[] colors = new Color[4]; colors[0] = Color.white; colors[1] = Color.white; colors[2] = Color.white; colors[3] = Color.white; // Normals Vector3[] normals = new Vector3[4]; normals[0] = new Vector3(0, 0, -1.0f); normals[1] = new Vector3(0, 0, -1.0f); normals[2] = new Vector3(0, 0, -1.0f); normals[3] = new Vector3(0, 0, -1.0f); // Tangents Vector4[] tangents = new Vector4[4]; tangents[0] = new Vector4(1, 0, 0, -1.0f); tangents[1] = new Vector4(1, 0, 0, -1.0f); tangents[2] = new Vector4(1, 0, 0, -1.0f); tangents[3] = new Vector4(1, 0, 0, -1.0f); // Triangles int[] triangles; if (m_MeshType == MESH_TYPE.BuiltIn_Plane) { triangles = new int[6]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; } else { triangles = new int[12]; triangles[0] = 1; triangles[1] = 2; triangles[2] = 0; triangles[3] = 0; triangles[4] = 2; triangles[5] = 3; triangles[6] = 1; triangles[7] = 0; triangles[8] = 3; triangles[9] = 3; triangles[10] = 2; triangles[11] = 1; } // Uv Vector2[] uvs = new Vector2[4]; uvs[0] = new Vector2(1, 1); uvs[1] = new Vector2(1, 0); uvs[2] = new Vector2(0, 0); uvs[3] = new Vector2(0, 1); meshFilter.mesh.Clear(); meshFilter.mesh.vertices = planeVertices; meshFilter.mesh.colors = colors; meshFilter.mesh.normals = normals; meshFilter.mesh.tangents = tangents; meshFilter.mesh.triangles = triangles; meshFilter.mesh.uv = uvs; meshFilter.mesh.RecalculateBounds(); // for (int n = 0; n < meshFilter.mesh.vertices.Length; n++) // Debug.Log(meshFilter.mesh.vertices[n]); }
public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType) { int[] numArray; Vector2 vector = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y); float num = (alignType != ALIGN_TYPE.BOTTOM) ? ((alignType != ALIGN_TYPE.TOP) ? 0f : (-1f * vector.y)) : (1f * vector.y); Rect frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset; if (bTrimCenterAlign) { frameUvOffset.center = Vector2.zero; } Vector3[] vectorArray = new Vector3[] { new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMax * vector.y) + num), new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMax * vector.y) + num) }; Color[] colorArray = new Color[] { Color.white, Color.white, Color.white, Color.white }; Vector3[] vectorArray2 = new Vector3[] { new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f) }; Vector4[] vectorArray3 = new Vector4[] { new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f) }; if (m_MeshType == MESH_TYPE.BuiltIn_Plane) { numArray = new int[] { 1, 2, 0, 0, 2, 3 }; } else { numArray = new int[] { 1, 2, 0, 0, 2, 3, 1, 0, 3, 3, 2, 1 }; } Vector2[] vectorArray4 = new Vector2[] { new Vector2(1f, 1f), new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(0f, 1f) }; meshFilter.mesh.Clear(); meshFilter.mesh.vertices = vectorArray; meshFilter.mesh.colors = colorArray; meshFilter.mesh.normals = vectorArray2; meshFilter.mesh.tangents = vectorArray3; meshFilter.mesh.triangles = numArray; meshFilter.mesh.uv = vectorArray4; meshFilter.mesh.RecalculateBounds(); }
public void SetTechnique(string technique, MESH_TYPE tipo)//indica que technique debe usar que tipo de mesh { objs.ForEach(obj => obj.SetTechnique(technique, tipo)); //normal_meshes.ForEach(m => m.Technique = technique); }
public void RenderMesh(MESH_TYPE tipo) { objs.ForEach(obj => obj.Render(tipo)); }