UnityMol  0.9.6-875
UnityMol viewer / In developement
BondLineStyle.cs
Go to the documentation of this file.
1 
66 //The link of linerender of Unity:http://unity3d.com/support/documentation/ScriptReference/LineRenderer.html
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;
77 
79  {
80 
81  public int number=1;
82  public List<int[]> bondEPList;
83 
84  public static GameObject BondLineParent = new GameObject("BondLineParent");
85 
86  public BondLineStyle()
87  {
88  }
89 
90 
91  public void DisplayBonds()
92  {
94  {
95  bondEPList=MoleculeModel.bondCAList;
96  }
97  else
98  {
99  bondEPList=MoleculeModel.bondEPList;
100  }
101 
102  MoleculeModel.bondsnumber=bondEPList.Count;
103  int Number=bondEPList.Count/number;
104 
105  Debug.Log("DisplayBonds??bondEPList.Count " + bondEPList.Count);
106  Debug.Log("UIData.EnableUpdate " + UIData.EnableUpdate);
107 
108  for(int i=0;i<Number;i++)
109  {
110  CreateLine(i*number);
111 
112  }
113  GameObject lineManagerObj = GameObject.FindGameObjectWithTag("LineManager");
114  LineManager lineManager = lineManagerObj.GetComponent<LineManager>();
115  lineManager.Init();
116  }
117  private void CreateLine(int i)
118  {
119  GameObject Line=new GameObject("Line");
120  Line.transform.parent = BondLineParent.transform;
121 
122  int[] atomsIds = bondEPList[i] as int[];
123 
124  LineRenderer lineRenderer = Line.AddComponent<LineRenderer>();
125  lineRenderer.SetVertexCount(2);
126  lineRenderer.material = new Material (Shader.Find("Particles/Alpha Blended"));
127 
128  if(Line.GetComponent<LineUpdate>()==null)
129  Line.AddComponent<LineUpdate>();
130  LineUpdate comp = Line.GetComponent<LineUpdate>();
131 
132  comp.atomnumber1 = atomsIds[0];
133  comp.atomnumber2 = atomsIds[1];
134 
135  float[] posAtom1 = MoleculeModel.atomsLocationlist[atomsIds[0]];
136  float[] posAtom2 = MoleculeModel.atomsLocationlist[atomsIds[1]];
137 
138  comp.posAtom1 = new Vector3(posAtom1[0],posAtom1[1],posAtom1[2]);
139  comp.posAtom2 = new Vector3(posAtom2[0],posAtom2[1],posAtom2[2]);
140 
141 
142 
143  comp.enabled = true;
144  Line.tag="Club";
145  }
146 
147  }
148 }
static bool EnableUpdate
Definition: UIData.cs:143
Vector3 posAtom1
Definition: LineUpdate.cs:72
static List< int[]> bondCAList
The bonds between carbon alpha in the CA-Spline.
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
Definition: UIData.cs:176
Vector3 posAtom2
Definition: LineUpdate.cs:73
int atomnumber2
Definition: LineUpdate.cs:75
int atomnumber1
Definition: LineUpdate.cs:74
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static List< int[]> bondEPList
The bonds between atoms.
override void Init()
Initializes this instance of the manager.
Definition: LineManager.cs:14
Definition: GUIDisplay.cs:66
static List< float[]> atomsLocationlist
The coordinates of each atom.