3 using System.Collections.Generic;
7 private List<float[]>
atoms;
9 private static float radius = 0.2f;
22 mat =
new Material(Shader.Find(
"Transparent/Cutout/Diffuse"));
23 mat.color = Color.blue;
24 mCamera = Camera.main;
25 cX = radius * (mCamera.transform.rotation * Vector3.right);
26 cY = radius * (mCamera.transform.rotation * Vector3.up);
29 spheres =
new GameObject[atoms.Count];
30 for(
int i=0; i<atoms.Count; i++)
40 float[] atom = atoms[i];
41 Color col = typeList[i].baseColor;
46 Mesh mesh =
new Mesh();
47 GetComponent<MeshFilter>().mesh = mesh;
49 Vector3 pos =
new Vector3(x,y,z);
50 Vector3[] vertices =
new Vector3[4];
53 vertices[0] = pos - cX +
cY;
54 vertices[1] = pos + cX +
cY;
55 vertices[2] = pos - cX -
cY;
56 vertices[3] = pos + cX -
cY;
58 mesh.vertices = vertices;
60 int[] triangles =
new int[6];
72 mesh.triangles = triangles;
74 Vector3[] normals =
new Vector3[4];
76 normals[0] = -Vector3.forward;
77 normals[1] = -Vector3.forward;
78 normals[2] = -Vector3.forward;
79 normals[3] = -Vector3.forward;
81 mesh.normals = normals;
83 Vector2[] uv =
new Vector2[4];
85 uv[0] =
new Vector2(0, 0);
86 uv[1] =
new Vector2(1, 0);
87 uv[2] =
new Vector2(0, 1);
88 uv[3] =
new Vector2(1, 1);
92 Color[] colors =
new Color[4];
93 for(
int j=0; i<4; i++)
112 float[] atom = atoms[i];
113 Color col = typeList[i].baseColor;
117 GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
118 sphere.transform.Translate(
new Vector3(x,y,z));
119 sphere.transform.parent = this.transform;
120 sphere.GetComponent<Renderer>().material.color = col;
static List< AtomModel > atomsTypelist
The type of each atom.
List< AtomModel > typeList
static List< float[]> atomsLocationlist
The coordinates of each atom.