IEnumerator InitScene(RequestPDB requestPDB)
    {
        StartCoroutine(requestPDB.LoadPDBWWW(UIData.server_url + "Scenes/fieldlines/fieldline.pdb"));
        while (!RequestPDB.isDone)
        {
            pdb_progress = requestPDB.progress;
            Debug.Log(pdb_progress);
            yield return(new WaitForEndOfFrame());
        }
        pdb_progress = 1.0f;

        UIData.atomtype = UIData.AtomType.particleball;
        UIData.bondtype = UIData.BondType.nobond;
        GUIMoleculeController.showOpenMenu = false;
        GUIMoleculeController.showAtomMenu = true;
        SendMessage("Display", SendMessageOptions.DontRequireReceiver);

        StartCoroutine(requestPDB.LoadJsonWWW(UIData.server_url + "Scenes/fieldlines/fieldline.json", MoleculeModel.Offset));
        while (!RequestPDB.isDone)
        {
            json_progress = requestPDB.progress;
            yield return(new WaitForEndOfFrame());
        }
        json_progress = 1.0f;
        MoleculeModel.fieldLineFileExists    = true;
        GUIMoleculeController.showFieldLines = true;
        FieldLineStyle.DisplayFieldLine();

        StartCoroutine(requestPDB.LoadOBJWWW(UIData.server_url + "Scenes/fieldlines/fieldline.obj"));
        while (!RequestPDB.isDone)
        {
            obj_progress = requestPDB.progress;
            yield return(new WaitForEndOfFrame());
        }
        obj_progress = 1.0f;
        MoleculeModel.surfaceFileExists = true;
        GUIMoleculeController.modif     = true;
    }
Exemple #2
0
 public void PlotWithFieldLines(SuperCell superCell, PlotStyle plotStyle, FieldLineStyle fieldLines, double density)
 {
     Pause();
     SetPlotInfo(superCell, plotStyle);
     this.fieldLineStyle = fieldLines;
     fieldLineList = new List<FieldLine>();
     fieldLineList.Add(new FieldLine());
     if (fieldLines == FieldLineStyle.Full) GrabAllFieldLines();
     UnPause();
     if (!isRunning)
     {
         runGameThread = new Thread(PlotInit);
         runGameThread.Start();
         isRunning = true;
     }
 }
Exemple #3
0
        private void SetPlotInfo(SuperCell superCell, PlotStyle thisPlotStyle)
        {
            currentCell = superCell;
            plotStyle = thisPlotStyle;
            fieldLineStyle = FieldLineStyle.None;
            miscInfo = new MiscInfo();
            displayList = new List<Vector3d>();
            extents = new double[] { double.MaxValue, double.MinValue, double.MaxValue, double.MinValue, double.MaxValue, double.MinValue };
            up = new Vector3d(0.0, 1.0, 0.0);
            right = new Vector3d(1.0, 0.0, 0.0);
            miscInfo.planeNormal = Calculator.Num2TK(Calculator.CrossProduct(superCell.latticeVectors.Column(0), superCell.latticeVectors.Column(1)));
            miscInfo.pointOnPlane = Calculator.Num2TK(superCell.centroids.Row(0));
            rotationLocked = false;
            Vector3d oldTarget = target;
            if (!isRunning)
            {
                target = new Vector3d(0.0, 0.0, 0.0);
                theta = 0.0;
                phi = -Math.PI / 2;
            }
            switch (plotStyle)
            {
                case PlotStyle.Molecules:
                    string[] distinctTypes = superCell.types.Distinct().ToArray();
                    miscInfo.colorOrder = new Color4[superCell.types.Length];
                    miscInfo.colorList = new List<Color4>();
                    for (int i = 0; i < superCell.types.Length; i++)
                    {
                        int index = 0;
                        while (true)
                        {
                            if (superCell.types[i] == distinctTypes[index]) break;
                            index++;
                        }
                        miscInfo.colorOrder[i] = molColors[index];
                    }
                    for (int i = 0; i < superCell.mols.Count; i++)
                    {
                        Vector3d myCentroid = Calculator.Num2TK(superCell.mols[i].centroid);
                        for (int j = 0; j < superCell.bonds.GetLength(0); j++)
                        {
                            miscInfo.colorList.Add(miscInfo.colorOrder[superCell.bonds[j, 0]-1]);
                            Vector3d atom = Calculator.Num2TK(superCell.mols[i].atoms.Row(superCell.bonds[j, 0] - 1)) + myCentroid;
                            extents = Calculator.UpdateExtents(extents, atom);
                            target += atom;
                            displayList.Add(atom);

                            miscInfo.colorList.Add(miscInfo.colorOrder[superCell.bonds[j, 1]-1]);
                            atom = Calculator.Num2TK(superCell.mols[i].atoms.Row(superCell.bonds[j, 1] - 1)) + myCentroid;
                            extents = Calculator.UpdateExtents(extents, atom);
                            target += atom;
                            displayList.Add(atom);
                        }
                    }
                    break;
                case PlotStyle.Centers:
                    for (int i = 0; i < superCell.centroids.RowCount; i++)
                    {
                        Vector3d centroid = Calculator.Num2TK(superCell.centroids.Row(i));
                        extents = Calculator.UpdateExtents(extents, centroid);
                        target += centroid;
                        displayList.Add(centroid);
                    }
                    break;
                case PlotStyle.Directions:
                    GrabDirections(superCell,false);
                    break;
                case PlotStyle.Curl:
                    GrabDirections(superCell,true);
                    break;
            }
            target /= (double)displayList.Count;
            if (!isRunning)
            {
                gameWidth = (extents[1] - extents[0]) * 1.1;
                gameHeight = (extents[3] - extents[2]) * 1.1;
                gameDepth = extents[5] - extents[4];
                depthClipPlane = Math.Max(Math.Max(gameWidth, gameDepth), gameDepth);
                eye = new Vector3d(target.X, target.Y, depthClipPlane * 2.0);
            }
            else
            {
                target = oldTarget;
                UpdateView();
            }
            r = (eye - target).Length;
        }
Exemple #4
0
        public static void DisplayFieldLine()
        {
//			FieldLineStyle fieldlinestyle=new FieldLineStyle();
            FieldLineStyle.DisplayFieldLine();
        }