/// <summary> /// Sets the center of the scene on the original center or on an atom. /// </summary> /// <param name='mode'> /// Setting mode (0 for original center, 1 for atom center). Int. /// </param> private void SetCenter(int mode) { GameObject CamTarget = GameObject.Find("Cam Target"); // choose the main function 0 to restart position or 1 to center around an atom if (mode == 0) { Debug.Log("Entering :: SetCenter for cam target to" + MoleculeModel.cameraLocation.z); if (scenecontroller.GetComponent <maxCamera>().enabled) { maxCamera comp = scenecontroller.GetComponent <maxCamera>(); comp.ToCenter(); } if (UIData.atomtype == UIData.AtomType.hyperball) { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); hbManager.ResetPositions(); } } else if (mode == 1) { Debug.Log("target : " + MoleculeModel.target); CamTarget.transform.rotation = transform.rotation; CamTarget.transform.position = MoleculeModel.target; } }
public static void ResetBondDisplay() { UIData.resetBondDisplay = false; DestroyBondObject(); if (UIData.bondtype == UIData.BondType.cube || UIData.bondtype == UIData.BondType.hyperstick || UIData.bondtype == UIData.BondType.bbhyperstick) { IBondStyle displayBond = new BondCubeStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.line) { IBondStyle displayBond = new BondLineStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.tubestick) { IBondStyle displayBond = new BondTubeStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.particlestick) { IBondStyle displayBond = new BondParticleStyle(); displayBond.DisplayBonds(); } // else if(UIData.bondtype==UIData.BondType.nobond) {} CreatBondGameObjectArray(); if (UIData.bondtype == UIData.BondType.cube || UIData.bondtype == UIData.BondType.hyperstick || UIData.bondtype == UIData.BondType.bbhyperstick) { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); hbManager.findBonds(); } }
/// <summary> /// Gets the list of active managers based on the atom type provided and based on the bond type in UIData. /// </summary> /// <returns> /// The list of managers. A List<GenericManager> object that should contains the "atom" manager in position 0 and the "bond" manager in position 1 (if there is one). /// </returns> public static List <GenericManager> GetManagers() { UIData.AtomType aType = UIData.atomtype; List <GenericManager> managerList = new List <GenericManager>(); if (aType == UIData.AtomType.hyperball) //|| UIData.bondtype == UIData.BondType.hyperstick) { { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); managerList.Add(hbManager); } else if (aType == UIData.AtomType.sphere) { GameObject spManagerObj = GameObject.FindGameObjectWithTag("SphereManager"); SphereManager spManager = spManagerObj.GetComponent <SphereManager>(); managerList.Add(spManager); } else if (aType == UIData.AtomType.cube) { GameObject cubeManagerObj = GameObject.FindGameObjectWithTag("CubeManager"); CubeManager cubeManager = cubeManagerObj.GetComponent <CubeManager>(); managerList.Add(cubeManager); } else if (aType == UIData.AtomType.particleball) { GameObject psObj = GameObject.FindGameObjectWithTag("ShurikenParticleManager"); ShurikenParticleManager shManager = psObj.GetComponent <ShurikenParticleManager>(); managerList.Add(shManager); } if (UIData.bondtype == UIData.BondType.line) { GameObject lineManagerObj = GameObject.FindGameObjectWithTag("LineManager"); LineManager lineManager = lineManagerObj.GetComponent <LineManager>(); managerList.Add(lineManager); } else if (UIData.bondtype == UIData.BondType.cube) { GameObject cubeBondManagerObj = GameObject.FindGameObjectWithTag("CubeBondManager"); CubeBondManager cubeBondManager = cubeBondManagerObj.GetComponent <CubeBondManager>(); managerList.Add(cubeBondManager); } else if (UIData.bondtype == UIData.BondType.hyperstick) { GameObject hStickManagerObj = GameObject.FindGameObjectWithTag("HStickManager"); HStickManager hStickManager = hStickManagerObj.GetComponent <HStickManager>(); managerList.Add(hStickManager); } return(managerList); }
public static void ToNotParticle(UIData.AtomType previousType, UIData.BondType previousBondType) { if (previousType != UIData.AtomType.noatom && UIData.atomtype != previousType) { GameObject shObject = GameObject.FindGameObjectWithTag("ShurikenParticleManager"); ShurikenParticleManager shManager = shObject.GetComponent <ShurikenParticleManager>(); shManager.pSystem.GetComponent <Renderer>().enabled = false; shManager.enabled = false; UIData.atomtype = previousType; UIData.bondtype = previousBondType; UIData.resetBondDisplay = true; UIData.resetDisplay = true; if (UIData.atomtype == UIData.AtomType.sphere) { UIData.isCubeToSphere = true; UIData.isSphereToCube = false; } else { UIData.isCubeToSphere = false; UIData.isSphereToCube = true; } if (UIData.atomtype == UIData.AtomType.hyperball) { GameObject hbmObject = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbmObject.GetComponent <HBallManager>(); BallUpdate.resetRadii = true; hbManager.EnableRenderers(); hbManager.enabled = true; } Debug.Log("ToHyperBall()"); Debug.Log(UIData.atomtype.ToString()); Debug.Log(UIData.bondtype.ToString()); } }
public static void HideObject() { if (UIData.atomtype != UIData.AtomType.hyperball) { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); hbManager.DisableRenderers(); } if (UIData.atomtype != UIData.AtomType.sphere) { GameObject spManagerObj = GameObject.FindGameObjectWithTag("SphereManager"); SphereManager spManager = spManagerObj.GetComponent <SphereManager>(); spManager.DisableRenderers(); } if (UIData.atomtype != UIData.AtomType.cube) { GameObject cbManagerObj = GameObject.FindGameObjectWithTag("CubeManager"); CubeManager cbManager = cbManagerObj.GetComponent <CubeManager>(); cbManager.DisableRenderers(); } DestroyBondObject(); }
private void DisplayAtomCube(IList coordinates, IList atomModels) { for (int i = 0; i < coordinates.Count; i++) { CreateAtomHB(i, coordinates, atomModels); } if (UIData.atomtype == UIData.AtomType.hyperball) { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); Debug.Log("HBall Manager INIT OUTSIDE"); hbManager.Init(); } else { GameObject cubeManagerObj = GameObject.FindGameObjectWithTag("CubeManager"); CubeManager cubeManager = cubeManagerObj.GetComponent <CubeManager>(); Debug.Log("Cube Manager INIT OUTSIDE"); cubeManager.Init(); } }
public static void SphereToCube() { UIData.resetDisplay = false; // DestroyObject(); HideObject(); if (UIData.atomtype == UIData.AtomType.cube) { GameObject cbmObject = GameObject.FindGameObjectWithTag("CubeManager"); CubeManager cbManager = cbmObject.GetComponent <CubeManager>(); cbManager.EnableRenderers(); if (!UIData.isCubeLoaded) { IAtomStyle displayAtom; Debug.Log("UIData.atomtype :: " + UIData.atomtype); displayAtom = new AtomCubeStyle(); displayAtom.DisplayAtoms(UIData.atomtype); } } else if (UIData.atomtype == UIData.AtomType.hyperball) { GameObject hbmObject = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbmObject.GetComponent <HBallManager>(); hbManager.EnableRenderers(); if (!UIData.isHBallLoaded) { IAtomStyle displayAtom; Debug.Log("UIData.atomtype :: " + UIData.atomtype); displayAtom = new AtomCubeStyle(); displayAtom.DisplayAtoms(UIData.atomtype); } } if (UIData.bondtype == UIData.BondType.cube || UIData.bondtype == UIData.BondType.hyperstick || UIData.bondtype == UIData.BondType.bbhyperstick) { IBondStyle displayBond = new BondCubeStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.line) { IBondStyle displayBond = new BondLineStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.tubestick) { IBondStyle displayBond = new BondTubeStyle(); displayBond.DisplayBonds(); } else if (UIData.bondtype == UIData.BondType.particlestick) { IBondStyle displayBond = new BondParticleStyle(); displayBond.DisplayBonds(); } CreatGameObjectArray(); BallUpdate.resetRadii = true; //BallUpdate.resetColors = true; Debug.Log("Exiting :: SphereToCube"); }
// Update is called once per frame void Update() { // requestPDB.Loading looks actually useless since progress bar is commented (see below) /*if (RequestPDB.isDone){ * requestPDB.Loading = false; * } * else{ * requestPDB.Loading = true; * }*/ if (isControl && (!UIData.cameraStop2)) // Seems to be true as long as the mouse is in the game window and not on the gui { MouseOperate(); KeyOperate(); //SetCenterbySpace(); HiddenOperate(); OpenMenuOperate(); OpenBoundOperate(); } // Always false ? /*if (GUIMoleculeController.toggle_HB_SANIM) { * GUIMoleculeController.shrink += Time.deltaTime * GUIMoleculeController.hb_sanim * GUIMoleculeController.hb_ssign; * if (GUIMoleculeController.shrink > 0.95f ) * GUIMoleculeController.hb_ssign = -1.0f; * if (GUIMoleculeController.shrink < 0.05f ) * GUIMoleculeController.hb_ssign = 1.0f; * }*/ // Always false ? /*if (GUIMoleculeController.toggle_HB_RANIM) { * GUIMoleculeController.globalRadius += Time.deltaTime * GUIMoleculeController.hb_ranim * GUIMoleculeController.hb_rsign; * if (GUIMoleculeController.globalRadius > 0.95f ) * GUIMoleculeController.hb_rsign = -1.0f; * if (GUIMoleculeController.globalRadius < 0.05f ) * GUIMoleculeController.hb_rsign = 1.0f; * }*/ if (GUIMoleculeController.toggle_HB_TRANS) // Always true ? { GUIMoleculeController.transDelta = 25.0f; } else { GUIMoleculeController.transDelta = 1.0f; } if (GUIMoleculeController.transMETAPHOR) { GUIMoleculeController.globalRadius = transition(GUIMoleculeController.globalRadius, GUIMoleculeController.newGlobalRadius, GUIMoleculeController.deltaRadius); GUIMoleculeController.linkScale = transition(GUIMoleculeController.linkScale, GUIMoleculeController.newScale, GUIMoleculeController.deltaScale); GUIMoleculeController.shrink = transition(GUIMoleculeController.shrink, GUIMoleculeController.newShrink, GUIMoleculeController.deltaShrink); if (GUIMoleculeController.globalRadius == GUIMoleculeController.newGlobalRadius && GUIMoleculeController.linkScale == GUIMoleculeController.newScale && GUIMoleculeController.shrink == GUIMoleculeController.newShrink) { GUIMoleculeController.transMETAPHOR = false; } } LineUpdate.scale = GUIMoleculeController.linkScale; StickUpdate.radiusFactor = GUIMoleculeController.globalRadius; StickUpdate.shrink = GUIMoleculeController.shrink; StickUpdate.scale = GUIMoleculeController.linkScale; BallUpdateHB.radiusFactor = GUIMoleculeController.globalRadius; // BallUpdateHB.depthfactor = GUIMoleculeController.depthfactor; HBallManager.depthFactor = GUIMoleculeController.depthfactor; HStickManager.depthFactor = GUIMoleculeController.depthfactor; BallUpdateSphere.radiusFactor = GUIMoleculeController.globalRadius; BallUpdateCube.radiusFactor = GUIMoleculeController.globalRadius; BallUpdateRC.radiusFactor = GUIMoleculeController.globalRadius; BallUpdateHB.drag = GUIMoleculeController.drag; BallUpdateHB.spring = GUIMoleculeController.spring; BallUpdateHB.EnergyGrayColor = GUIMoleculeController.EnergyGrayColor.color; // TODO: This is gross. Should be fixed. GameObject[] FieldLines = GameObject.FindGameObjectsWithTag("FieldLineManager"); foreach (GameObject FieldLine in FieldLines) { LineRenderer curLineRenderer; curLineRenderer = FieldLine.GetComponent <LineRenderer>(); curLineRenderer.material.SetFloat("_timeOff", Time.time); // for benoist video comment next line curLineRenderer.material.SetColor("_Color", GUIMoleculeController.EnergyGrayColor.color); if (GUIMoleculeController.fieldLineColorGradient) { curLineRenderer.material.SetFloat("_colormode", 0f); } else { curLineRenderer.material.SetFloat("_colormode", 1f); } curLineRenderer.material.SetFloat("_Speed", GUIMoleculeController.speed); curLineRenderer.material.SetFloat("_Density", GUIMoleculeController.density); curLineRenderer.material.SetFloat("_Length", GUIMoleculeController.linelength); curLineRenderer.SetWidth(GUIMoleculeController.linewidth, GUIMoleculeController.linewidth); curLineRenderer.material.SetFloat("_depthcut", (GUIMoleculeController.depthCut - maxCamera.currentDistance)); curLineRenderer.material.SetFloat("_adjust", (GUIMoleculeController.adjustFieldLineCut)); curLineRenderer.material.SetVector("_SurfacePos", FieldLine.transform.position); if (GUIMoleculeController.surfaceMobileCut) { curLineRenderer.material.SetFloat("_cut", 2f); } else if (GUIMoleculeController.surfaceStaticCut) { curLineRenderer.material.SetFloat("_cut", 1f); curLineRenderer.material.SetVector("_cutplane", new Vector4(GUIMoleculeController.cutX, GUIMoleculeController.cutY, GUIMoleculeController.cutZ, GUIMoleculeController.depthCut)); } } GameObject[] Surfaces = GameObject.FindGameObjectsWithTag("SurfaceManager"); foreach (GameObject Surface in Surfaces) { if ((GUIMoleculeController.surfaceTexture || GUIMoleculeController.externalSurfaceTexture) && !GUIMoleculeController.surfaceTextureDone) { if (GUIMoleculeController.externalSurfaceTexture) { if (!UIData.grayscalemode) { Surface.renderer.material.SetTexture("_MatCap", GUIMoleculeController.extSurf); } else { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); Surface.renderer.material.SetTexture("_MatCap", hbManager.ToGray(GUIMoleculeController.extSurf)); } Debug.Log("File choose surface texture"); } else { if (!UIData.grayscalemode) { Surface.renderer.material.SetTexture("_MatCap", (Texture)Resources.Load(GUIMoleculeController.surfaceTextureName)); // do not do that every frame! } else { GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); Surface.renderer.material.SetTexture("_MatCap", hbManager.ToGray((Texture)Resources.Load(GUIMoleculeController.surfaceTextureName))); } Debug.Log("Quick choose surface texture"); } } else if ((GUIMoleculeController.buildSurface || GUIMoleculeController.dxRead) && !GUIMoleculeController.buildSurfaceDone) { Surface.renderer.material.SetTexture("_MatCap", (Texture)Resources.Load("lit_spheres/divers/daphz1")); Debug.Log("Default surface texture"); } // send all the paramter to the surface shader // Surface.renderer.material.SetFloat("_Shininess", GUIMoleculeController.intensity); // if (Input.GetKey("n")) // uncoment for benoist Surface.renderer.material.SetColor("_Color", GUIMoleculeController.SurfaceGrayColor.color); Surface.renderer.material.SetColor("_ColorIN", GUIMoleculeController.SurfaceInsideColor.color); //Surface.renderer.material.SetColor("_Color", new Color(1f,1f,1f)); // couleur blanche fixé Surface.renderer.material.SetFloat("_depthcut", GUIMoleculeController.depthCut); Surface.renderer.material.SetFloat("_cutX", GUIMoleculeController.cutX); Surface.renderer.material.SetFloat("_cutY", GUIMoleculeController.cutY); Surface.renderer.material.SetFloat("_cutZ", GUIMoleculeController.cutZ); Surface.renderer.material.SetVector("_SurfacePos", Surface.transform.position); if (GUIMoleculeController.surfaceMobileCut && Surface.renderer.material.shader.name == "Mat Cap Cut") // set the cutting mode { if (Surface.renderer.material.GetFloat("_cut") != 2f) { Surface.renderer.material.SetFloat("_cut", 2f); } } else if (GUIMoleculeController.surfaceStaticCut && Surface.renderer.material.shader.name == "Mat Cap Cut") { if (Surface.renderer.material.GetFloat("_cut") != 1f) { Surface.renderer.material.SetFloat("_cut", 1f); } } else if (Surface.renderer.material.shader.name == "Mat Cap Cut") { if (Surface.renderer.material.GetFloat("_cut") != 0f) { Surface.renderer.material.SetFloat("_cut", 0f); } } } GUIMoleculeController.surfaceTextureDone = true; GUIMoleculeController.buildSurfaceDone = true; //FPS Count timeleft -= Time.deltaTime; accum += Time.timeScale / Time.deltaTime; ++frames; // Interval ended - update GUI text and start new interval if (timeleft <= 0.0f) { // display two fractional digits (f2 format) float fps = accum / frames; //(1 / Time.deltaTime); MoleculeModel.FPS = fps.ToString("f2"); //Write FPS data into file if (fpsLogToggle) { fpsCount++; fpsSum += fps; if (fpsCount > 35) { Debug.Log("Info :; End fps measure"); toggleFPSLog(); fpsCount = 0; fpsSum = 0; GameObject LoadBox = GameObject.Find("LoadBox"); maxCamera comp = LoadBox.GetComponent <maxCamera>(); comp.automove = false; } } timeleft = updateInterval; accum = 0.0f; frames = 0; } //SetVolumetricDensity(); // gUIDisplay.gUIMoleculeController.GetPanelPixel(); }
public static void MDDriverM(int a) { GUIMoleculeController.showMDDriverMenu = LoadTypeGUI.SetTitleExit("MDDriver Client"); GameObject go = GameObject.FindGameObjectWithTag("MDDriver"); if (go != null && MDDriver_isConnected()) { GUILayout.BeginHorizontal(); GUILayout.Label("Connected"); GUILayout.EndHorizontal(); // GUILayout.BeginHorizontal(); // if (GUILayout.Button (new GUIContent("Disconnect", "Disconnect from simulation server"))) { // Debug.Log("Stop: " + MDDriver_stop()); // GUIMoleculeController.toggle_MDDRIVER = false; // } // GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Hydrogen bonds", "Render or no hydrogen bonds"))) { if (MDDriver.hb == false) { PlotManager.Instance.PlotCreate("NHBonds", -1, 40, Color.black, new Vector2(500, 500)); } GameObject bb = GameObject.Instantiate(Resources.Load("VARNABillboard")) as GameObject; GameObject camera = GameObject.Find("Camera"); bb.transform.parent = camera.transform; MDDriver.hb = !MDDriver.hb; } GUILayout.EndHorizontal(); } else { if (go != null) { GUILayout.BeginHorizontal(); GUILayout.Label("Not connected"); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("Server"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); host = GUILayout.TextField(host, 30); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Port"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); portString = GUILayout.TextField(portString, 30); GUILayout.EndHorizontal(); int temp = 0; if (int.TryParse(portString, out temp)) { port = Mathf.Clamp(temp, 0, 99999); } else if (portString == "") { port = 3000; } GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Connect", "Connect to simulation server"))) { instantiateClient(); } GUILayout.EndHorizontal(); } GUILayout.Space(20); if (UIData.atomtype == UIData.AtomType.hyperball) { GUILayout.BeginHorizontal(); GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager"); HBallManager hbManager = hbManagerObj.GetComponent <HBallManager>(); if (hbManager.ellipsoidViewEnabled()) { if (GUILayout.Button(new GUIContent("CG RNA", "Switch to RNA Coarse-Grained representation")) && UIData.atomtype == UIData.AtomType.hyperball) { hbManager.SwitchRendering(); } } else { if (GUILayout.Button(new GUIContent("Ellipsoid RNA", "Switch to RNA ellipsoid representation")) && UIData.atomtype == UIData.AtomType.hyperball) { hbManager.SwitchRendering(); } } GUILayout.EndHorizontal(); } // if (GUILayout.Button (new GUIContent("Benchmark", ""))) // { // GameObject LoadBox; // LoadBox = GameObject.Find ("LoadBox"); // Molecule3D Molecule3DComp = LoadBox.GetComponent<Molecule3D> (); // Molecule3DComp.toggleFPSLog (); // } GUI.enabled = true; GUI.DragWindow(); }