64 using System.Collections.Generic;
80 public static bool xgmml =
false;
99 public override void Init () {
107 for (
int i=0; i<hballs.Length; i++) {
108 hballs[i].GetComponent<Renderer>().enabled =
true;
109 hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.Off;
110 hballs[i].GetComponent<Renderer>().receiveShadows =
false;
124 Debug.Log(
"Destroying Hyperboloids");
130 for (
int i=0; i<hballs.Length; i++) {
133 GameObject.Destroy(hballs[i].gameObject);
186 attenuation = enabling? 1f : 0f;
188 for (
int i=0; i<hballs.Length; i++)
189 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Attenuation", attenuation);
242 public void SetTexture(Texture texture, List<string> atom,
string residue =
"All",
string chain =
"All") {
245 Debug.Log(
"SetTexture HBall");
250 if(!atom.Contains (
"All")){
251 if(residue ==
"All"){
256 for (
int i=0; i<hballs.Length; i++)
257 if(atom.Contains(hballs[i].tag))
258 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
260 for (
int i=0; i<hballs.Length; i++)
262 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
269 for (
int i=0; i<hballs.Length; i++){
270 if(atom.Contains(hballs[i].tag)
272 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
275 for (
int i=0; i<hballs.Length; i++){
278 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
288 for (
int i=0; i<hballs.Length; i++){
289 if(atom.Contains(hballs[i].tag)
291 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
294 for (
int i=0; i<hballs.Length; i++){
297 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
305 for (
int i=0; i<hballs.Length; i++){
306 if(atom.Contains(hballs[i].tag)
309 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
312 for (
int i=0; i<hballs.Length; i++){
313 if(atom.Contains(hballs[i].tag)
316 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
323 if(residue ==
"All"){
327 for (
int i=0; i<hballs.Length; i++)
328 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
333 for (
int i=0; i<hballs.Length; i++){
335 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
343 for (
int i=0; i<hballs.Length; i++){
345 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
351 for (
int i=0; i<hballs.Length; i++){
354 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
378 public void SetTexture(
string resource_name, List<string> atom,
string residue =
"All",
string chain =
"All") {
379 Texture text2D = (Texture)Resources.Load(resource_name);
393 Debug.Log(
"HBallManager object: SetTexture(Texture, int) : " + texture.name +
" - " + atomNum);
395 for (
int i=0; i<hballs.Length; i++)
396 if(hballs[i].GetComponent<BallUpdate>().number == atomNum)
397 hballs[i].GetComponent<Renderer>().material.
SetTexture(
"_MatCap", texture);
411 Texture text2D = (Texture)Resources.Load(resource_name);
424 for (
int i=0; i<hballs.Length; i++)
427 hballs[i].GetComponent<Renderer>().material.SetColor(
"_Color", hballs[i].
atomcolor);}
453 public override void SetColor(Color col, List<string> atom,
string residue =
"All",
string chain =
"All") {
455 if(!atom.Contains (
"All")){
456 if(residue ==
"All"){
461 for (
int i=0; i<hballs.Length; i++){
462 if(atom.Contains(hballs[i].tag))
466 for (
int i=0; i<hballs.Length; i++){
476 for (
int i=0; i<hballs.Length; i++){
477 if(atom.Contains(hballs[i].tag)
482 for (
int i=0; i<hballs.Length; i++){
495 for (
int i=0; i<hballs.Length; i++){
496 if(atom.Contains(hballs[i].tag)
501 for (
int i=0; i<hballs.Length; i++){
512 for (
int i=0; i<hballs.Length; i++){
513 if(atom.Contains(hballs[i].tag)
519 for (
int i=0; i<hballs.Length; i++){
530 if(residue ==
"All"){
534 for (
int i=0; i<hballs.Length; i++)
540 for (
int i=0; i<hballs.Length; i++){
550 for (
int i=0; i<hballs.Length; i++){
559 for (
int i=0; i<hballs.Length; i++){
581 public override void SetColor(Color col,
int atomNum) {
582 for (
int i=0; i<hballs.Length; i++){
583 if(hballs[i].GetComponent<BallUpdate>().number == atomNum)
601 public override void SetRadii(List<string> atom,
string residue =
"All",
string chain =
"All") {
602 if(!atom.Contains (
"All")){
603 if(residue ==
"All"){
607 for (
int i=0; i<hballs.Length; i++) {
608 if(atom.Contains(hballs[i].tag))
612 for (
int i=0; i<hballs.Length; i++) {
621 for (
int i=0; i<hballs.Length; i++) {
622 if(atom.Contains(hballs[i].tag)
627 for (
int i=0; i<hballs.Length; i++) {
639 for (
int i=0; i<hballs.Length; i++) {
640 if(atom.Contains(hballs[i].tag)
645 for (
int i=0; i<hballs.Length; i++) {
655 for (
int i=0; i<hballs.Length; i++) {
656 if(atom.Contains(hballs[i].tag)
662 for (
int i=0; i<hballs.Length; i++) {
673 if(residue ==
"All"){
676 for (
int i=0; i<hballs.Length; i++) {
682 for (
int i=0; i<hballs.Length; i++) {
691 for (
int i=0; i<hballs.Length; i++) {
698 for (
int i=0; i<hballs.Length; i++) {
717 for (
int i=0; i<hballs.Length; i++) {
718 if((
int)hballs[i].number ==
id)
735 for (
int i=0; i<hballs.Length; i++)
736 if(hballs[i].transform.position == pos)
737 return hballs[i].GetComponent<Renderer>().material.GetColor(
"_Color");
751 return hballs[id].gameObject;
759 for (
int i=0; i<hballs.Length; i++)
760 hballs[i].transform.localPosition =
new Vector3(hballs[i].transform.localPosition.x,hballs[i].transform.localPosition.y, hballs[i].
z * depthFactor);
770 for (
int j=0; j<hballs.Length; j++){
771 int i = (int)hballs[j].number;
784 for (
int j=0; j<hballs.Length; j++){
785 int i = (int)hballs[j].number;
811 for (
int i=0; i<hballs.Length; i++) {
814 if (hballs[i].rayon == 3.7f){
815 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Rayon", hballs[i].
rayon 820 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Rayon", hballs[i].
rayon 826 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Rayon", hballs[i].
rayon 845 for (
int i=0; i<hballs.Length; i++) {
856 for (
int i=0; i<hballs.Length; i++) {
857 Destroy(hballs[i].GetComponent<MouseOverMolecule>());
862 for (
int i=0; i<hballs.Length; i++) {
863 Destroy(hballs[i].GetComponent<SpringJoint>());
864 Destroy(hballs[i].GetComponent<Rigidbody>());
871 for (
int i=0; i<hballsGameObjects.Length; i++) {
880 for (
int i=0; i<hballsGameObjects.Length; i++) {
881 Destroy(hballsGameObjects[i].GetComponent<MouseOverMoleculeIMDSimulation>());
887 for (
int i=0; i<hballs.Length; i++) {
888 if(!hballs[i].GetComponent<Rigidbody>())
889 hballs[i].gameObject.AddComponent<Rigidbody>();
890 if(!hballs[i].GetComponent<SpringJoint>())
891 hballs[i].gameObject.AddComponent<SpringJoint>();
901 for (
int i=0; i<hballs.Length; i++) {
902 float v = hballs[i].GetComponent<Rigidbody>().velocity.magnitude;
904 Color c = Color.Lerp(Color.white, Color.black, v);
905 hballs[i].GetComponent<Renderer>().material.SetColor(
"_Color", c);
908 wasInteractiveColored =
true;
910 else if(wasInteractiveColored){
911 for (
int i=0; i<hballs.Length; i++) {
914 wasInteractiveColored =
false;
923 Debug.Log(
"HBallManager: Disabling renderers");
929 for (
int i=0; i<hballs.Length; i++){
931 hballs[i].GetComponent<Renderer>().enabled =
false;
933 hballs[i].GetComponent<Collider>().enabled =
false;
955 for (
int i=0; i<hballs.Length; i++){
957 hballs[i].GetComponent<Renderer>().enabled =
true;
958 hballs[i].GetComponent<Collider>().enabled =
true;
961 Debug.Log(
"HBallManager: Enabling renderer");
967 for(
int i=0; i<hballs.Length; i++){
968 hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.On;
969 hballs[i].GetComponent<Renderer>().receiveShadows =
true;
970 hballs[i].GetComponent<Renderer>().material.shader = Shader.Find(
"FvNano/HyperBalls Shadow GL_D3D");
976 for(
int i=0; i<hballs.Length; i++){
977 hballs[i].GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.Off;
978 hballs[i].GetComponent<Renderer>().receiveShadows =
false;
979 hballs[i].GetComponent<Renderer>().material.shader = Shader.Find(
"FvNano/HyperBalls GL_D3D");
987 for(
int i=0; i<hballs.Length; i++)
988 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Brightness", brightness);
992 resetBrightness =
false;
1014 if (xgmml && (oldDepthFactor!=depthFactor)) {
1072 Vector3 sum =
new Vector3(0.0f, 0.0f, 0.0f);
1073 int currentAtomId = 0;
1075 for (
int i = 0; i < 3; i++) {
1076 currentAtomId = atoms[i];
1078 GameObject go = hballsGameObjects[currentAtomId] as GameObject;
1079 sum += go.transform.position;
1084 return sum / nbOfAtoms;
1096 GameObject go = hballsGameObjects[atoms[0]] as GameObject;
1097 Vector3 point1 = go.transform.position;
1099 go = hballsGameObjects[atoms[1]] as GameObject;
1100 Vector3 point2 = go.transform.position;
1102 go = hballsGameObjects[atoms[2]] as GameObject;
1103 Vector3 point3 = go.transform.position;
1115 return Vector3.Cross(point2 - point1, point3 - point1).normalized;
1129 Debug.Log(
"Finding atoms");
1132 int nbOfAtoms = entry.Value.Count;
1134 int currentAtomId = 0;
1135 string currentAtomName;
1136 string currentResidueName;
1139 List<int> triplet =
new List<int>();
1140 while (i != nbOfAtoms)
1142 currentAtomId = (int)entry.Value[i];
1148 if (currentResidueName ==
"G" || currentResidueName ==
"A") {
1149 if (currentAtomName ==
"CY" || currentAtomName ==
"G1" || currentAtomName ==
"G2" || currentAtomName ==
"A1" || currentAtomName ==
"A2") {
1150 triplet.Add (currentAtomId);
1155 if (currentAtomName ==
"CY" || currentAtomName ==
"CA" || currentAtomName ==
"C1" || currentAtomName ==
"U1") {
1156 triplet.Add (currentAtomId);
1160 if (triplet.Count == 3)
1172 while (i != nbOfAtoms)
1174 currentAtomId = (int)entry.Value[i];
1176 if (currentAtomName ==
"CA")
1199 int nbOfSticks = sticks.Length;
1200 for (
int i = 0; i < nbOfSticks; i++)
1219 GameObject Atom = entry.Value;
1222 Atom.transform.position = pos;
1225 Atom.transform.forward = normal;
1240 string currentResidueName;
1247 Atom = GameObject.CreatePrimitive(PrimitiveType.Cube);
1249 Atom.GetComponent<Renderer>().material.shader = Shader.Find(
"FvNano/HyperBalls GL_D3D");
1256 if (currentResidueName ==
"C") {
1257 Atom.GetComponent<Renderer>().material.SetColor(
"_Color", Color.yellow);
1259 else if (currentResidueName ==
"G") {
1260 Atom.GetComponent<Renderer>().material.SetColor(
"_Color", Color.green);
1262 else if (currentResidueName ==
"A") {
1263 Atom.GetComponent<Renderer>().material.SetColor(
"_Color", Color.red);
1265 else if (currentResidueName ==
"U") {
1266 Atom.GetComponent<Renderer>().material.SetColor(
"_Color",
new Color(0.7f, 0.7f, 0.98f));
1270 comp.SetRayonFactor(1.0f);
1271 Atom.GetComponent<Renderer>().material.SetFloat(
"_Rayon", 1.0f);
1272 Atom.GetComponent<Renderer>().material.SetVector(
"_Equation",
new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
1274 Atom.GetComponent<Renderer>().transform.localScale =
new Vector3(3.0f, 1.5f, 4.0f);
1277 comp.enabled =
true;
1285 ellipsoidsInitialized =
true;
1300 for(
int i = 0; i < entry.Value.Length; i++)
1303 GameObject go = hballsGameObjects[entry.Value[i]] as GameObject;
1304 go.GetComponent<Renderer>().enabled =
true;
1327 for(
int i = 0; i < entry.Value.Length; i++)
1330 GameObject go = hballsGameObjects[entry.Value[i]] as GameObject;
1331 go.GetComponent<Renderer>().enabled =
false;
1348 if (ellipsoidsInitialized ==
false)
1358 if (ellipsoidsInitialized ==
false)
1383 if (ellipsoidView ==
true)
1394 for(
int i=0; i<hballs.Length; i++)
1395 hballs[i].GetComponent<Renderer>().material.SetFloat(
"_Shininess", shininess);
1397 resetShininess =
false;
1411 float minDist = Vector3.Distance(closestAtom.gameObject.transform.position, position);
1414 for (
int i = 1; i < hballs.Length; i++) {
1415 tempAtom = hballs[i];
1416 tempDist = Vector3.Distance(tempAtom.gameObject.transform.position, position);
1417 if (tempDist < minDist) {
1419 closestAtom = tempAtom;
1423 selection.
go = closestAtom.gameObject;
1430 for (
int j=0; j<hballs.Length; j++){
1431 if (hballs[j].tag==
"H")
1432 hballs[j].GetComponent<Renderer>().enabled = !hide;
static float highBFradius
Radius used for the highest B factor value.
override void ResetPositions()
Resets the positions of all balls.
override void SetColor(Color col, int atomNum)
Sets the color of a specific atom.
static bool networkLoaded
GameObject[] hballsGameObjects
void CreateMouseOversIMDSimulation()
static bool resetShininess
override void SetColor(Color col, List< string > atom, string residue="All", string chain="All")
Sets the color of atoms.
void CreateMouseOvers()
Creates the mouse overs, needed when interactive mode is triggered.
static bool secondarystruct
Switch between all atoms and C-alpha trace or BFactor secondary structure representation.
static bool resetShininess
Vector3 computeEllipsoidPosition(int residueId)
Compute an ellipsoid position based on its associated atoms
override void ResetIMDSimulationPositions()
Resets the positions of all balls.
static string[] allowedAtomsForPosition
override void showHydrogens(bool hide)
void SetTexture(string resource_name, int atomNum)
Sets the MatCap texture for one atom.
override void DestroyAll()
Disable and destroys all the Hyperballs and Sticks.
static bool resetBrightness
void DestroyMouseOvers()
Destroys the mouse overs, needed when interactive mode is turned off.
void ResetColors()
Resets the colors of all balls and sticks.
static List< string > atomsNamelist
The name of each atom.
static float oldDepthFactor
static List< string > atomsChainList
The chain of each atom.
static List< AtomModel > atomsTypelist
The type of each atom.
static bool ellipsoidsInitialized
static List< Vector3 > atomsIMDSimulationLocationlist
The coordinates of each atom, simulated through an IMD simulation.
override void SetRadii(List< string > atom, string residue="All", string chain="All")
Changes the scale of the atoms.
void DeactivateEllipsoids()
override void ToggleDistanceCueing(bool enabling)
Initializes the list of sticks.
static BallUpdateHB[] hballs
bool ellipsoidViewEnabled()
void SetTexture(Texture texture, List< string > atom, string residue="All", string chain="All")
Sets the texture of atoms.
static string structType
The current rendered structure type.
static List< GameObject > bondsForReplacedAtoms
static bool resetBrightness
static void setCurrentAtomManager(GenericManager manager)
void StartPhysicsManagement()
static void SetTexture(Texture text)
void GenerateEllipsoids()
Generates the ellipsoids based on coarse-grain model
Vector3 computeEllipsoidOrientation(int residueId)
static bool resetBrightness
static Dictionary< int, GameObject > ellipsoidsPerResidue
The ellipsoids per residue.
!WiP Includes FLAGS of GUI.
override GameObject GetBall(int id)
Gets the GameObject from hballs at the position "id".
override void DisableShadows()
static bool wasInteractiveColored
static void ChangeRepresentation(UIData.AtomType newAtomType, UIData.BondType newBondType=UIData.BondType.nobond)
static bool resetShininess
!WiP manage GUI, and provide static strings for the GUI.
override void ResetRadii()
Resets the radii of all balls when it is changed via the GUI.
static List< Color > atomsColorList
The color of each atom.
void findBonds()
Find bonds to be hidden to render ellipsoids
static float radiusFactor
static string file_extension
static Dictionary< int, ArrayList > residues
The residues.
static bool ellipsoidView
void SetTexture(string resource_name, List< string > atom, string residue="All", string chain="All")
Sets the texture of one atom.
void ActivateEllipsoids()
static float oldRadiusFactor
Vector3 computeEllipsoidNormal(int residueId)
Compute the plane normal for an ellipsoid (given a residue)
void DestroyMouseOversIMDSimulation()
static bool bondsReadyToBeReset
override void SetRadii(int id)
Changes the scale for Atom selection.
override void EnableShadows()
void MoveNetworkNodes()
Moves the network nodes when the depth factor is changed.
static bool toggle_NA_INTERACTIVE
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
static float globalRadius
static bool quickSelection
static List< GameObject > ellipsoids
Contiguous (really?) list of ellipsoids
void SetTexture(Texture texture, int atomNum)
Sets the MatCap texture for one atom.
static Dictionary< int, int > atomsForEllipsoidsOrientationPerResidue
override void Init()
Initalizes this instance.
void setAtomId(int atomId)
override void DisableRenderers()
Disables the renderers for the entire set of balls and sticks.
static bool isHBallLoaded
void ManagePhysics()
Manages the rigidbody physics.
Color GetColor(Vector3 pos)
Gets the color of the atom at the location "pos".
void findAtoms()
Find atoms used to compute the ellipsoid plane
static Dictionary< int, int[]> atomsForEllipsoidsPerResidue
The atoms per ellipsoids per residue for HiRERNA rendering Key is the residue id Value is an array of...
override void EnableRenderers()
Enables the renderers for the entire set of balls and sticks.
static List< float > atomsLocalScaleList
static List< float[]> atomsLocationlist
The coordinates of each atom.
SingleAtomSelection getClosestAtomGameObject(Vector3 position)