// Update is called once per frame
    void LateUpdate()
    {
        if (Input.GetMouseButton(1))
        {
            Ray        sRay = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit sHit;
            if (!Physics.Raycast(sRay, out sHit))
            {
                //	MonoBehaviour.print(Input.mousePosition);
                Vector3 pos = Input.mousePosition;
                pos.z = 1;
                pos   = Camera.main.ScreenToWorldPoint(pos);
                pos.z = -8;
                //			pos.x *= Camera.main.pixelWidth;
                //			pos.y *= Camera.main.pixelHeight;
                //
                MonoBehaviour.print(pos);
                GameObject Atom;
                Atom = GameObject.CreatePrimitive(PrimitiveType.Cube);
                Atom.transform.position = pos;
                Material newMat = new Material(Shader.Find("FvNano/Single Cube Sphere Raycasting new"));
                newMat.SetColor("_Color", new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
                Atom.renderer.material = newMat;
                Atom.AddComponent("BallUpdateHB");
                BallUpdateHB comp = Atom.GetComponent <BallUpdateHB>();
                comp.rayon = 1.0f;


                Atom.AddComponent <Rigidbody>();
                Atom.rigidbody.useGravity    = false;
                Atom.rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
                Atom.rigidbody.drag          = 0.6f;
                Atom.AddComponent <SpringJoint>();
                Atom.AddComponent <MouseOverMolecule>();

                if (last != null)
                {
                    GameObject bond    = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    Material   bondMat = new Material(Shader.Find("FvNano/Hyperbole Stick new"));
                    bondMat.SetFloat("_Shrink", 0.03f);
                    bond.renderer.material = bondMat;
                    bond.AddComponent("StickUpdate");
                    StickUpdate bondComp = bond.GetComponent <StickUpdate>();
                    bondComp.atompointer1 = last;
                    bondComp.atompointer2 = Atom;
                    //last.GetComponent<SpringJoint>().connectedBody = Atom.GetComponent<Rigidbody>();
                }

                last = Atom;
            }
        }
    }
Example #2
0
        //Hypersticks
        private void CreateCylinderByShader(int start)
        {
            GameObject Stick;
            int        i = start;

            int[] atomsIds = bondEPList[i] as int[];
            Stick = GameObject.CreatePrimitive(PrimitiveType.Cube);
            RuntimePlatform platform = Application.platform;

            switch (platform)
            {
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsWebPlayer:
            case RuntimePlatform.WindowsEditor:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;

            default:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;
            }
            StickUpdate comp = Stick.AddComponent <StickUpdate>();

            //Debug.Log("BOND : " + atomsIds[0] + " - " + atomsIds[1]);
            //comp.atompointer1=(GameObject)MoleculeModel.atoms[atomsIds[0]];
            //comp.atompointer2=(GameObject)MoleculeModel.atoms[atomsIds[1]];

            if (UI.UIData.atomtype == UI.UIData.AtomType.particleball)
            {
                comp.atompointer1 = (GameObject)MoleculeModel.atoms[atomsIds[0]];
                comp.atompointer2 = (GameObject)MoleculeModel.atoms[atomsIds[1]];
            }
            else
            {
                GenericManager manager = Molecule.View.DisplayMolecule.GetManagers()[0];
                comp.atompointer1 = manager.GetBall(Molecule.Model.MoleculeModel.atoms.Count - 1 - atomsIds[0]);
                comp.atompointer2 = manager.GetBall(Molecule.Model.MoleculeModel.atoms.Count - 1 - atomsIds[1]);
            }

            comp.enabled = true;
            Stick.renderer.material.SetFloat("_Shrink", StickUpdate.shrink);
            Stick.tag = "Club";
            Stick.collider.enabled   = false;
            Stick.transform.position = comp.atompointer1.transform.position;
            Stick.transform.parent   = BondCubeParent.transform;
        }
Example #3
0
        //Billboard hypersticks
        private void CreateBBCylinderByShader(int i)
        {
            GameObject Stick;

            if (UIData.toggleClip)
            {
                Stick = Clip4HyperStick.CreateClip();
            }
            else
            {
                Stick = GameObject.CreatePrimitive(PrimitiveType.Plane);
            }

            int[] atomsIds = bondEPList[i] as int[];

            Stick.transform.Rotate(new Vector3(0, -180, 0));
            Stick.AddComponent("CameraFacingBillboard");
            Stick.GetComponent <CameraFacingBillboard>().cameraToLookAt = GameObject.Find("Camera").camera;
            RuntimePlatform platform = Application.platform;

            switch (platform)
            {
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsWebPlayer:
            case RuntimePlatform.WindowsEditor:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;

            default:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;
            }
            Stick.AddComponent("StickUpdate");

            StickUpdate comp = Stick.GetComponent <StickUpdate>();

            comp.atompointer1 = (GameObject)MoleculeModel.atoms[atomsIds[0]];
            comp.atompointer2 = (GameObject)MoleculeModel.atoms[atomsIds[1]];

            comp.enabled = true;
            Stick.renderer.material.SetFloat("_Shrink", 0.01f);
            Stick.tag = "Club";
            Stick.transform.parent = BondCubeParent.transform;
        }