UnityMol  0.9.6-875
UnityMol viewer / In developement
StickUpdate.cs
Go to the documentation of this file.
1 
66 using UnityEngine;
67 using System.Collections;
68 using UI;
69 using Molecule.Model;
70 
71 
72 public class StickUpdate : MonoBehaviour {
73 
74  public static bool resetColors = false;
75 
76  public static float shrink = 0.01f;
77  public static float oldshrink = 0.01f;
78 
79  public static float scale = 1.0f;
80  public static float oldscale = 1.0f;
81 
82  public static float radiusFactor = 1.0f;
83  // public GameObject atompointer1=null;
84  // public GameObject atompointer2=null;
85  public int atomnumber1;
86  public int atomnumber2;
87 
88 
89 
90  public float oldrayon1 = 2.0f;
91  public float oldrayon2 = 2.0f;
92 
93  public ParticleEmitter emitter;
94 
95  public bool independant = false;
96 
97 /*
98  public static void SetTexture()
99  {
100  StickUpdate[] stickUpdates = Object.FindObjectsOfType(typeof(StickUpdate)) as StickUpdate[];
101  foreach(StickUpdate stu in stickUpdates)
102  {
103  stu.renderer.material.SetTexture("_MatCap", BallUpdateHB.text2D);
104  }
105  }
106 */
107 
108  public static void ResetColors() {
109  StickUpdate[] stickUpdates = Object.FindObjectsOfType(typeof(StickUpdate)) as StickUpdate[];
110  foreach(StickUpdate stu in stickUpdates) {
111 
112  Color colorAtom1 = MoleculeModel.atomsColorList[stu.atomnumber1];
113  Color colorAtom2 = MoleculeModel.atomsColorList[stu.atomnumber2];
114  stu.GetComponent<Renderer>().material.SetColor("_Color", colorAtom1);
115  stu.GetComponent<Renderer>().material.SetColor("_Color2", colorAtom2);
116  }
117  resetColors = false;
118  }
119 
120  // Only check for d3d once
121 // private bool d3d= false;
122  void Start (){
123  Color colorAtom1 = MoleculeModel.atomsColorList[atomnumber1];
124  Color colorAtom2 = MoleculeModel.atomsColorList[atomnumber2];
125 
126 
127  float[] fposAtom1 = MoleculeModel.atomsLocationlist[atomnumber1];
128  float[] fposAtom2 = MoleculeModel.atomsLocationlist[atomnumber2];
129 
130  Vector3 posAtom1 = new Vector3(fposAtom1[0],fposAtom1[1],fposAtom1[2]);
131  Vector3 posAtom2 = new Vector3(fposAtom2[0],fposAtom2[1],fposAtom2[2]);
132 
133 
134 // d3d = SystemInfo.graphicsDeviceVersion.IndexOf("Direct3D") > -1;
135  GetComponent<Renderer>().material.SetColor("_Color", colorAtom1);
136  GetComponent<Renderer>().material.SetColor("_Color2", colorAtom2);
137 
138  GetComponent<Renderer>().material.SetVector("_TexPos1", posAtom1);
139  transform.position = posAtom1;
140  GetComponent<Renderer>().material.SetVector("_TexPos2", posAtom2);
141 // renderer.material.SetTexture("_MatCap",BallUpdateHB.text2D);
142 
143  if(UIData.atomtype == UIData.AtomType.hyperball) {
144 
145  GameObject goatom1 = ((GameObject)MoleculeModel.atoms[atomnumber1]);
146  GameObject goatom2 = ((GameObject)MoleculeModel.atoms[atomnumber2]);
147 
148 
149  if (goatom1.GetComponent<Renderer>().material.HasProperty("_MatCap"))
150  {
151  Texture t1 = goatom1.GetComponent<Renderer>().material.GetTexture("_MatCap");
152  GetComponent<Renderer>().material.SetTexture("_MatCap", t1);
153  }
154  if (goatom2.GetComponent<Renderer>().material.HasProperty("_MatCap"))
155  {
156  Texture t2 = goatom2.GetComponent<Renderer>().material.GetTexture("_MatCap");
157  GetComponent<Renderer>().material.SetTexture("_MatCap2", t2);
158  }
159  }
160  else {
161  GetComponent<Renderer>().material.SetTexture("_MatCap", (Texture)Resources.Load("lit_spheres/divers/daphz05"));
162  GetComponent<Renderer>().material.SetTexture("_MatCap2", (Texture)Resources.Load("lit_spheres/divers/daphz05"));
163  }
164  }
165 
166 }
void Start()
Definition: StickUpdate.cs:122
static float radiusFactor
Definition: StickUpdate.cs:82
static float scale
Definition: StickUpdate.cs:79
static void ResetColors()
Definition: StickUpdate.cs:108
static float oldshrink
Definition: StickUpdate.cs:77
static float oldscale
Definition: StickUpdate.cs:80
float oldrayon1
Definition: StickUpdate.cs:90
float oldrayon2
Definition: StickUpdate.cs:91
ParticleEmitter emitter
Definition: StickUpdate.cs:93
int atomnumber1
Definition: StickUpdate.cs:85
bool independant
Definition: StickUpdate.cs:95
int atomnumber2
Definition: StickUpdate.cs:86
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static List< Color > atomsColorList
The color of each atom.
static bool resetColors
Definition: StickUpdate.cs:74
static AtomType atomtype
Definition: UIData.cs:139
static float shrink
Definition: StickUpdate.cs:76
Definition: GUIDisplay.cs:66
static List< float[]> atomsLocationlist
The coordinates of each atom.