public static void GenerateMeshes(List <Vector3> vertices, List <Vector3> normals, List <int> triangles, List <Color32> colors, int[] ss, string tag = "RibbonObj", string gameobj = "Ribbons") { // DuplicateVertices(vertices, normals, triangles, colors); tag = Ribbons.ribbontag; AddFirstFrontalFace(vertices, normals, triangles, colors, ss); AddLastFrontalFace(vertices, normals, triangles, colors, ss); MeshData mData = new MeshData(); mData.vertices = vertices.ToArray(); mData.normals = normals.ToArray(); mData.triangles = triangles.ToArray(); mData.colors = colors.ToArray(); /* * for(int i=0; i<mData.vertices.Length; i++) { * mData.vertices[i] += Molecule.Model.MoleculeModel.Offset; * } */ Splitting split = new Splitting(); List <Mesh> meshes = split.Split(mData); SubGenerateMeshes(meshes, tag, gameobj); }
/// <summary> /// Creates the surface objects. /// </summary> /// <param name='voxels'> /// Voxels, i.e. the scalar field used to compute the surface. /// </param> /// <param name='threshold'> /// The threshold on which the isosurface is based. /// </param> /// <param name='delta'> /// Delta parameter from the grid, basically the size of each cell. /// </param> /// <param name='origin'> /// Origin of the grid. /// </param> /// <param name='colors'> /// Colors. Kept from previous implementation, but doesn't do anything here. I'm only /// keeping it because I'm not sure what it was used for. --- Alexandre /// </param> /// <param name='tag'> /// Tag for the objects to be created. /// </param> /// <param name='electro'> /// True if this is an electrostatic field isosurface. /// </param> public static void CreateSurfaceObjects(float[,,] voxels, float threshold, Vector3 delta, Vector3 origin, Color[] colors, string tag = "SurfaceManager", bool electro = false) { ELECTRO = electro; Debug.Log(ELECTRO.ToString()); if (ELECTRO) { ReadDX readDX = UI.GUIMoleculeController.readdx; origin = readDX.GetOrigin(); delta = readDX.GetDelta(); } InitGenMesh(voxels, threshold, delta, origin, tag); SetDims(); float bMCTime = Time.realtimeSinceStartup; MeshData mData = MarchingCubes.CreateMesh(VOXELS, 0, XDIM, 0, YDIM, 0, ZDIM); Debug.Log("Entire surface contains " + mData.vertices.Length.ToString() + " vertices."); float elapsed = 10f * (Time.realtimeSinceStartup - bMCTime); Debug.Log("GenerateMesh::MarchingCubes time: " + elapsed.ToString()); OffsetVertices(mData); float bSmooth = Time.realtimeSinceStartup; AdjacencySets adjacencySets = new AdjacencySets(mData.triangles.Length); adjacencySets.AddAllTriangles(mData.triangles); SmoothFilter.AdjSetsSmoother(mData, adjacencySets); elapsed = Time.realtimeSinceStartup - bSmooth; Debug.Log("Smoothing time: " + elapsed.ToString()); ProperlyCalculateNormals(mData); // Necessary for electrostatic fields isosurfaces Debug.Log(threshold.ToString()); if (threshold < 0) { FlipTriangles(mData); } Splitting splitting = new Splitting(); List <Mesh> meshes = splitting.Split(mData); CreateSurfaceObjects(meshes); }
//imyjimmy public void GenerateMeshes(List <Vector3> vertices, List <Vector3> normals, List <int> triangles, List <Color32> colors, int[] ss, List <Residue> residueSeq, string tag = "RibbonObj", string gameobj = "Ribbons") { // DuplicateVertices(vertices, normals, triangles, colors); tag = Ribbons.ribbontag; if (tag == "" || tag == " " || tag == null) { tag = "RibbonObj"; } Debug.Log("inside PostProcessing.GenerateMeshes"); Debug.Log("adding first and last frontal faces."); this.AddFirstFrontalFace(vertices, normals, triangles, colors, ss); this.AddLastFrontalFace(vertices, normals, triangles, colors, ss); MeshData mData = new MeshData(); //imyjimmy //MoleculeModel.ribbonColors = colors; mData.vertices = vertices.ToArray(); mData.normals = normals.ToArray(); mData.triangles = triangles.ToArray(); mData.colors = colors.ToArray(); mData.residueSeq = residueSeq; Debug.Log("mData.colors.Length: " + mData.colors.Length); Debug.Log("mData.vertices.Length: " + mData.vertices.Length); Debug.Log("mData.normals.Length: " + mData.normals.Length); /* * for(int i=0; i<mData.vertices.Length; i++) { * mData.vertices[i] += Molecule.Model.MoleculeModel.Offset; * } */ List <Mesh> meshes = split.Split(mData, this); Debug.Log("PostProcessing, number of meshes: " + meshes.Count); this.SubGenerateMeshes(meshes, tag, gameobj); }