3 using System.Collections.Generic;
33 public override void Init () {
35 texturesToUpdate =
new List<int>();
36 materialsAtoms =
new Material[hball_meshes.Length];
37 texturesAtoms =
new Texture2D[hball_meshes.Length];
38 for(
int i=0;i<hball_meshes.Length;i++){
39 materialsAtoms[i] = hball_meshes[i].GetComponent<Renderer>().material;
40 texturesAtoms[i] = (Texture2D)materialsAtoms[i].mainTexture;
50 for(
int i=0;i<hball_meshes.Length;i++)
51 GameObject.Destroy(hball_meshes[i]);
52 hball_meshes =
new GameObject[0];
54 if(collidersGO.Length > 0)
55 GameObject.Destroy(collidersParent);
59 collidersGO =
new GameObject[0];
66 attenuation = enabling? 1f : 0f;
67 for (
int i=0; i<hball_meshes.Length; i++)
68 materialsAtoms[i].SetFloat(
"_Attenuation", attenuation);
87 public override void SetColor(Color col, List<string> atom,
string residue =
"All",
string chain =
"All"){
89 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
91 if(!atom.Contains (
"All")){
99 if(atom.Contains(aModel.
type)){
101 if(coordAtomTexture.TryGetValue(i,out res)){
102 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
103 texturesToUpdate.Add(res.Key);
112 if(coordAtomTexture.TryGetValue(i,out res)){
113 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
114 texturesToUpdate.Add(res.Key);
126 if(atom.Contains(aModel.
type)
130 if(coordAtomTexture.TryGetValue(i,out res)){
131 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
132 texturesToUpdate.Add(res.Key);
143 if(coordAtomTexture.TryGetValue(i,out res)){
144 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
145 texturesToUpdate.Add(res.Key);
159 if(atom.Contains(aModel.
type)
162 if(coordAtomTexture.TryGetValue(i,out res)){
163 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
164 texturesToUpdate.Add(res.Key);
174 if(coordAtomTexture.TryGetValue(i,out res)){
175 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
176 texturesToUpdate.Add(res.Key);
187 if(atom.Contains(aModel.
type)
191 if(coordAtomTexture.TryGetValue(i,out res)){
192 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
193 texturesToUpdate.Add(res.Key);
204 if(coordAtomTexture.TryGetValue(i,out res)){
205 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
206 texturesToUpdate.Add(res.Key);
215 if(residue ==
"All"){
220 if(coordAtomTexture.TryGetValue(i,out res)){
221 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
222 texturesToUpdate.Add(res.Key);
232 if(coordAtomTexture.TryGetValue(i,out res)){
233 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
234 texturesToUpdate.Add(res.Key);
246 if(coordAtomTexture.TryGetValue(i,out res)){
247 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
248 texturesToUpdate.Add(res.Key);
261 if(coordAtomTexture.TryGetValue(i,out res)){
262 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
263 texturesToUpdate.Add(res.Key);
285 public override void SetColor(Color col,
int atomNum) {
287 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
290 Debug.LogError(
"Invalid atom number : "+atomNum);
297 if(coordAtomTexture.TryGetValue(atomNum,out res)){
298 texturesAtoms[res.Key].SetPixel(1,res.Value,col);
299 texturesToUpdate.Add(res.Key);
319 public override void SetRadii(List<string> atom,
string residue =
"All",
string chain =
"All"){
320 Debug.Log(
"SetRadii =========================");
321 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
322 if(!atom.Contains (
"All")){
323 if(residue ==
"All"){
329 if(coordAtomTexture.TryGetValue(i,out res)){
331 texturesToUpdate.Add(res.Key);
439 for (
int i=0; i< hball_meshes.Length; i++){
440 materialsAtoms[i].SetTexture(
"_MatCap", texture);
446 Texture text2D = (Texture)Resources.Load(resource_name);
475 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
477 if(coordAtomTexture.TryGetValue(i,out res)){
483 Vector3 vec3AtomPos = Vector3.zero;
484 vec3AtomPos.x = atomPos[0];
485 vec3AtomPos.y = atomPos[1];
486 vec3AtomPos.z = atomPos[2];
487 collidersGO[i].transform.position = vec3AtomPos;
489 texturesToUpdate.Add(res.Key);
502 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
504 if(coordAtomTexture.TryGetValue(i,out res)){
511 collidersGO[i].transform.position = atomPos;
513 texturesToUpdate.Add(res.Key);
531 for (
int i=0; i< hball_meshes.Length; i++)
532 hball_meshes[i].GetComponent<Renderer>().enabled =
false;
534 for(
int i=0;i<collidersGO.Length;i++)
535 collidersGO[i].GetComponent<Collider>().enabled =
false;
548 for (
int i=0; i< hball_meshes.Length; i++)
549 hball_meshes[i].GetComponent<Renderer>().enabled =
true;
550 for(
int i=0;i<collidersGO.Length;i++)
551 collidersGO[i].GetComponent<Collider>().enabled =
true;
556 for (
int i=0; i< hball_meshes.Length; i++){
557 hball_meshes[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.On;
558 hball_meshes[i].GetComponent<Renderer>().receiveShadows =
true;
559 hball_meshes[i].GetComponent<Renderer>().material.shader = Shader.Find(
"FvNano/Ball HyperBalls Shadow Merged");
563 for (
int i=0; i< hball_meshes.Length; i++){
564 hball_meshes[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.Off;
565 hball_meshes[i].GetComponent<Renderer>().receiveShadows =
false;
566 hball_meshes[i].GetComponent<Renderer>().material.shader = Shader.Find(
"FvNano/Ball HyperBalls Merged");
575 for(
int i=0;i<materialsAtoms.Length;i++)
576 materialsAtoms[i].SetFloat(
"_Brightness",brightness);
580 resetBrightness =
false;
584 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
586 if(coordAtomTexture.TryGetValue(i,out res)){
592 collidersGO[i].GetComponent<SphereCollider>().radius = oriRadius
596 texturesToUpdate.Add(res.Key);
599 for(
int i=0;i<collidersGO.Length;i++){
609 for(
int i=0;i<materialsAtoms.Length;i++)
610 materialsAtoms[i].SetFloat(
"_Shininess",shininess);
611 resetShininess =
false;
619 List<int> idtex = texturesToUpdate.Distinct().ToList();
620 foreach(
int id in idtex){
622 texturesAtoms[id].Apply(
false,
false);
625 texturesToUpdate.Clear();
629 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
633 if(coordAtomTexture.TryGetValue(i,out res)){
635 texturesAtoms[res.Key].SetPixel(5,res.Value,Vector4.zero);
637 texturesAtoms[res.Key].SetPixel(5,res.Value,Vector4.one);
639 texturesToUpdate.Add(res.Key);
647 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
648 if(coordAtomTexture.TryGetValue(idAtom,out res)){
650 texturesAtoms[res.Key].SetPixel(5,res.Value,Vector4.one);
652 texturesAtoms[res.Key].SetPixel(5,res.Value,Vector4.zero);
654 texturesToUpdate.Add(res.Key);
658 KeyValuePair<int,int> res =
new KeyValuePair<int,int>();
661 if(coordAtomTexture.TryGetValue(i,out res)){
662 texturesAtoms[res.Key].SetPixel(5,res.Value,Vector4.one);
663 texturesToUpdate.Add(res.Key);
690 for (
int i=0; i<collidersGO.Length; i++) {
698 for (
int i=0; i<collidersGO.Length; i++) {
699 Destroy(collidersGO[i].GetComponent<MouseOverMoleculeIMDSimulation>());
void SetBrightness(float val)
override void SetRadii(int id)
Changes the scale for Atom selection.
override void ResetPositions()
Resets the positions of all balls.
override void Init()
Initalizes this instance.
static bool resetShininess
override void SetColor(Color col, int atomNum)
Sets the color of a specific atom.
Material[] materialsSticks
static bool resetBrightness
void hideAtom(int idAtom, bool show)
GameObject[] hball_meshes
SingleAtomSelection getClosestAtomGameObject(Vector3 position)
override void DestroyAll()
Disable and destroys all the Hyperballs
static bool resetBrightness
override void EnableRenderers()
Enables the renderers for the entire set of balls and sticks.
override void ResetRadii()
static List< string > atomsNamelist
The name of each atom.
override void ToggleDistanceCueing(bool enabling)
static List< string > atomsChainList
The chain of each atom.
void DestroyMouseOversIMDSimulation()
static List< AtomModel > atomsTypelist
The type of each atom.
static List< Vector3 > atomsIMDSimulationLocationlist
The coordinates of each atom, simulated through an IMD simulation.
GameObject collidersParent
override void EnableShadows()
void SetTexture(string resource_name)
List< int > texturesToUpdate
static Vector4 EncodeFloatRGBA(float v)
Texture2D[] texturesAtoms
static void setCurrentAtomManager(GenericManager manager)
static bool resetBrightness
static bool resetShininess
!WiP manage GUI, and provide static strings for the GUI.
static List< Color > atomsColorList
The color of each atom.
override void SetRadii(List< string > atom, string residue="All", string chain="All")
Changes the scale of the atoms.
override void showHydrogens(bool hide)
Dictionary< int, KeyValuePair< int, int > > coordAtomTexture
override void SetColor(Color col, List< string > atom, string residue="All", string chain="All")
Sets the color of atoms.
Material[] materialsAtoms
override GameObject GetBall(int id)
Gets the GameObject from hballs at the position "id".
static int selectionAtoms
override void ResetIMDSimulationPositions()
Resets the positions of all balls.
static bool resetShininess
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
static float globalRadius
static bool quickSelection
override void DisableRenderers()
Disables the renderers for the entire set of balls and sticks.
void setAtomId(int atomId)
void SetTexture(Texture texture)
override void DisableShadows()
static List< float > atomsLocalScaleList
void CreateMouseOversIMDSimulation()
static List< float[]> atomsLocationlist
The coordinates of each atom.