68 using System.Collections.Generic;
76 public List<Vector2>
uvs;
85 groups =
new List<GroupData>();
86 allFaces =
new List<FaceIndices>();
99 faces =
new List<FaceIndices>();
101 public bool isEmpty {
get {
return faces.Count == 0; } }
105 objects =
new List<ObjectData>();
117 vertices =
new List<Vector3>();
118 uvs =
new List<Vector2>();
119 normals =
new List<Vector3>();
124 if(
isEmpty) objects.Remove(current);
149 Debug.Log(
"Pushing new material " + name +
" with curgr.empty=" + curgr.
isEmpty);
175 Debug.Log(
"OBJ has " + objects.Count +
" object(s)");
176 Debug.Log(
"OBJ has " + vertices.Count +
" vertice(s)");
177 Debug.Log(
"OBJ has " + uvs.Count +
" uv(s)");
178 Debug.Log(
"OBJ has " + normals.Count +
" normal(s)");
180 Debug.Log(od.
name +
" has " + od.
groups.Count +
" group(s)");
182 Debug.Log(od.
name +
"/" + gd.
name +
" has " + gd.
faces.Count +
" faces(s)");
189 public bool isEmpty {
get {
return vertices.Count == 0; } }
197 for(
int i = 0; i < gs.Length; i++) {
204 Vector3[] tvertices =
new Vector3[
vertextot];
206 Vector3[] tnormals =
new Vector3[
vertextot];
208 int[] triangles =
new int[od.
allFaces.Count];
215 for (
int bari =0; bari<
vertextot;bari++){
216 barix = barix + vertices[bari].x;
218 bariy = bariy + vertices[bari].y;
219 bariz = bariz + vertices[bari].z;
226 Debug.Log(
"Surface baricentre coords :: "+ barix +
" "+ bariy+
" "+ bariz);
234 tvertices[l] = vertices[l];
235 tvertices[l].x = vertices[l].x;
236 tvertices[l].y = vertices[l].y;
237 tvertices[l].z = vertices[l].z;
238 tnormals[l]= normals[l];
253 triangles[k] = fi.
vi;
260 Vector3 baricenter =
new Vector3(barix,bariy,bariz);
261 Debug.Log(
"Obj center = " + baricenter);
266 Mesh m = (gs[i].GetComponent(typeof(MeshFilter)) as MeshFilter).mesh;
267 m.vertices = tvertices;
269 if(hasUVs) m.uv = tuvs;
274 for(
int tri=0; tri<triangles.Length; tri=tri+3)
276 int tmp = triangles[tri];
277 triangles[tri] = triangles[tri+2];
278 triangles[tri+2] = tmp;
281 if(od.
groups.Count == 1) {
284 gs[i].GetComponent<Renderer>().material = mats[gd.
materialName];
289 m.triangles = triangles;
void PushObject(string name)
void PushGroup(string name)
static Vector3[] vertices
void PushNormal(Vector3 v)
static Vector3 Offset
The offset for the molecule.
void PushMaterialName(string name)
List< ObjectData > objects
void PopulateMeshes(GameObject[] gs, Dictionary< string, Material > mats)
List< FaceIndices > allFaces
List< FaceIndices > faces
void PushFace(FaceIndices f)
void PushVertex(Vector3 v)
static Vector3 Center
The barycenter of the molecule.