UnityMol  0.9.6-875
UnityMol viewer / In developement
BondParticleStyle.cs
Go to the documentation of this file.
1 
66 
67 namespace Molecule.View.DisplayBond
68 {
69 
70  using UnityEngine;
71  using System.Collections;
72  using System.Collections.Generic;
73  using Molecule.Model;
74  using Molecule.Control;
75  using UI;
78  {
79  public List<int[]> bondList=new List<int[]>();
80  public List<int[]> bondEPList=new List<int[]>();
81 
82  Particle[] p = new Particle[MoleculeModel.bondEPList.Count];
83  int bondindex=0;
84 
86  {
87  }
88 
89 
90  public void DisplayBonds()
91  {
92  bondEPList=MoleculeModel.bondEPList;
93  Debug.Log("DisplayBonds??bondEPList.Count " + bondEPList.Count);
94  int Number=bondEPList.Count;
95 
96  for(int i=0;i<Number;i++)
97  {
98  if(i!=0)
99  {
100  CreateCylinderByParticle(i,(i+1));
101  }
102  else
103  {
104  CreateCylinderByParticle(i,bondEPList.Count);
105  }
106 
107  }
108  GameObject ParticleStickManager=GameObject.Find("ParticleStickManager");
109  ParticleEffect particleeffect=ParticleStickManager.transform.GetComponent<ParticleEffect>();
110  particleeffect.atomcount=MoleculeModel.bondEPList.Count;
111  particleeffect.p=p;
112  particleeffect.SpawnEffect ();
113  Debug.Log("the length of p ="+p.Length);
114 
115 
116 
117 
118  }
119 
120  private void CreateCylinderByParticle(int start, int end) // Apparently unused function. Would make ParticleSticks.
121  {
122 
123 
124  GameObject ParticleManager=GameObject.Find("ParticleStickManager");
125 // ParticleEffect particleeffect=ParticleManager.transform.GetComponent<ParticleEffect>();
126  ParticleManager.transform.GetComponent<ParticleEffect>();
127  for(int i=start;i<end;i++)
128  {
129 // Vector3[] location=bondEPList[i] as Vector3[];
130  Vector3[] location = new Vector3[bondEPList.Count];
131  for(int j=0; i<(bondEPList.Count); j++)
132  {
133  Vector3 v = new Vector3( (bondEPList[i][0]),
134  (bondEPList[i][1]),
135  (bondEPList[i][2]) );
136  location[i] = v;
137  }
138 
139  Vector3 atom0position=new Vector3();
140  Vector3 atom1position=new Vector3();
141  Vector3 atomtype=new Vector3();
142  atom0position=location[0];
143  atom1position=location[1];
144  atomtype=location[2];
145 // string atom0type="X";
146 // string atom1type="X";
147 // Color atom0color=Color.red;
148 // Color atom1color=Color.red;
149  float atomradius0=1f;
150  float atomradius1=1f;
151 // int oratom1number=0;
152 // int oratom2number=0;
153 
154 // int atom1number;
155 // int atom2number;
156 
157  if(UI.GUIDisplay.file_extension=="xgmml")
158  {
159 // oratom1number=(int)atomtype.x;
160 // oratom2number=(int)atomtype.y;
161  }
162  else
163  {
164 // oratom1number=(int)atomtype.z/100;
165 // oratom2number=(int)atomtype.z-oratom1number*99;
166  }
167 
168  switch((int)atomtype.x)
169  {
170  case 1:
171 // atom0type="C";
172 // atom0color= (MoleculeModel.carbonColor);
173  atomradius0=1.7f;
174  break;
175  case 2:
176 // atom0type="N";
177 // atom0color= (MoleculeModel.nitrogenColor);
178  atomradius0=1.55f;
179 
180  break;
181  case 3:
182 // atom0type="O";
183 // atom0color= (MoleculeModel.oxygenColor);
184  atomradius0=1.52f;
185 
186  break;
187  case 4:
188 // atom0type="S";
189 // atom0color= (MoleculeModel.sulphurColor);
190  atomradius0=2.27f;
191 
192  break;
193  case 5:
194 // atom0type="P";
195 // atom0color= (MoleculeModel.phosphorusColor);
196  atomradius0=1.18f;
197 
198  break;
199  case 6:
200 // atom0type="H";
201 // atom0color= (MoleculeModel.hydrogenColor);
202  atomradius0=1.2f;
203 
204  break;
205  case 7:
206 // atom0type="X";
207 // atom0color= (MoleculeModel.unknownColor);
208  atomradius0=1.0f;
209 
210  break;
211  }
212 
213  switch((int)atomtype.y)
214  {
215  case 1:
216 // atom1type="C";
217 // atom1color= (MoleculeModel.carbonColor);
218  atomradius1=1.7f;
219 
220  break;
221  case 2:
222 // atom1type="N";
223 // atom1color= (MoleculeModel.nitrogenColor);
224  atomradius1=1.55f;
225 
226  break;
227  case 3:
228 // atom1type="O";
229 // atom1color= (MoleculeModel.oxygenColor);
230  atomradius1=1.52f;
231 
232  break;
233  case 4:
234 // atom1type="S";
235 // atom1color= (MoleculeModel.sulphurColor);
236  atomradius1=2.27f;
237 
238  break;
239  case 5:
240 // atom1type="P";
241 // atom1color= (MoleculeModel.phosphorusColor);
242  atomradius1=1.18f;
243 
244  break;
245  case 6:
246 // atom1type="H";
247 // atom1color= (MoleculeModel.hydrogenColor);
248  atomradius1=1.2f;
249 
250  break;
251  case 7:
252 // atom1type="X";
253 // atom1color= (MoleculeModel.unknownColor);
254  atomradius1=1.0f;
255 
256  break;
257  }
258 
259  Quaternion q=Quaternion.identity;
260  Vector3 v3=new Vector3();
261  v3.x=location[1].x*180f/3.1416f;
262  v3.y=location[1].y*180f/3.1416f;
263  v3.z=location[1].z*180f/3.1416f;
264  q.eulerAngles=v3;
265  p[bondindex+start].position=(atom0position+atom1position)/2;
266  p[bondindex+start].size=(float)(atomradius0+atomradius1)/2;
267  p[bondindex+start].color=Color.yellow;
268  p[bondindex+start].energy=1000;
269 
270  }
271 
272  }
273 
274  }
275 
276 }
Particle[] p
!WiP manage GUI, and provide static strings for the GUI.
Definition: GUIDisplay.cs:94
static string file_extension
Definition: GUIDisplay.cs:121
static List< int[]> bondEPList
The bonds between atoms.
Definition: GUIDisplay.cs:66