Inheritance: MonoBehaviour
コード例 #1
0
    void Update()
    {
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            if (!MeshDeformation.experiment_running)
            {
                GameObject go = GameObject.Find("start_text");

                go.GetComponent <Renderer>().enabled = false;

                for (int i = 0; i < 2; i++)
                {
                    MeshDeformation script = meshScripts[i];
                    script.mesh_file_location     = beams[mesh_indices[cur_mesh_index, i]];
                    script.emb_mesh_file_location = beams[beams.Length - 1];
                    script.ms_delay  = ms_delays[mesh_indices[cur_mesh_index, i]];
                    script.YM_factor = YM_factors[mesh_indices[cur_mesh_index, i]];
                    script.myStart();
                }
                MeshDeformation.experiment_running = true;
                return;
            }

            for (int i = 0; i < 2; i++)
            {
                MeshDeformation script = meshScripts[i];
                if (script.controllerStates[0].isGrabbing)
                {
                    logChosenBar(i);
                    resetObjects();
                    return; // Can only grab one object at a time so return here
                }
            }
        }
    }
コード例 #2
0
    void resetObjects()
    {
        cur_mesh_index++;
        if (cur_mesh_index == mesh_indices.GetLength(0))
        {
            //We are done
            GameObject go = GameObject.Find("thank_you_text");

            go.GetComponent <Renderer>().enabled = true;

            for (int i = 0; i < 2; i++)
            {
                MeshDeformation script = meshScripts[i];
                script.meshThreadFinished = true;
            }

            return;
        }

        for (int i = 0; i < 2; i++)
        {
            MeshDeformation script = meshScripts[i];
            script.mesh_file_location   = beams[mesh_indices[cur_mesh_index, i]];
            script.ms_delay             = ms_delays[mesh_indices[cur_mesh_index, i]];
            script.YM_factor            = YM_factors[mesh_indices[cur_mesh_index, i]];
            script.reset_timestamp      = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            script.reset_object_pending = true; // Need to do this so we don't reset the object while the thread is running
        }
        //SteamVR_Fade.View(Color.white, 1000f);
        //SteamVR_Skybox.SetOverride();
    }
コード例 #3
0
    void HandleInputLower(Ray inputRay)
    {
        //Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(inputRay, out hit))
        {
            MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>();
            if (deformer)
            {
                Vector3 point = hit.point;
                point += hit.normal * forceOffset;
                deformer.AddHeight(point, hit.normal, -force, radius);
            }
        }
    }
コード例 #4
0
    // Update is called once per frame

    /*
     *  void Update () {
     *          if (Input.GetMouseButton(0)) {
     *      //HandleSlap();
     *      HandleInputLower();
     *          }
     *          if (Input.GetMouseButton(1)) {
     *                  HandleInputRaise();
     *          }
     *  }
     */
    void HandleSlap()
    {
        Ray        inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(inputRay, out hit))
        {
            MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation> ();
            if (deformer)
            {
                Vector3 point = hit.point;
                point += hit.normal * forceOffset;
                deformer.AddDeformingForce(point, force);
            }
        }
    }
コード例 #5
0
ファイル: GenerateTerrain.cs プロジェクト: cking20/GodGameVR
    private void RandomMesh()
    {
        float           minRand = -200f;
        float           maxRand = 200f;
        Mesh            m       = GetComponent <MeshFilter>().sharedMesh;
        MeshDeformation md      = GetComponent <MeshDeformation>();
        ColorVertexes   cv      = GetComponent <ColorVertexes>();

        //raise and lower at random
        print("GenTerr vernum = " + m.vertices.Length);
        Vector3[] v = m.vertices;
        for (int i = 0; i < v.Length; i++)
        {
            float force = Random.Range(minRand, maxRand);
            md.GenAddHeight(v[i], v[i] + v[i], force, 1000);
        }
        cv.UpdateColors();
    }
コード例 #6
0
    public void HandleInput(Ray inputRay, float mult)
    {
        /*
         *      Ray inputRay = Camera.main.ScreenPointToRay (Input.mousePosition);
         */
        RaycastHit hit;

        if (Physics.Raycast(inputRay, out hit))
        {
            print(hit.transform.name);
            MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>();
            if (deformer)
            {
                Vector3 point = hit.point;
                point += hit.normal * forceOffset;
                deformer.AddHeight(point, hit.normal, force * mult, radius);
            }
        }
    }
コード例 #7
0
    void HandleInput()
    {
        Ray        inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(inputRay, out hit))
        {
            MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>();

            //Debug.Log("object: "+ hit.collider.gameObject.name);

            if (deformer)
            {
                //Debug.Log("hit at point: "+ hit.point);
                Vector3 point = hit.point;
                point += hit.normal * forceOffset;
                deformer.AddDeformingForce(point, force);
            }
        }
    }
コード例 #8
0
    void AddDeformerTo(GameObject obj, float rayRange)
    {
        Vector3    downVec = (-obj.transform.up);
        float      rayDirectionOffsetFromObject = 0.1f;
        RaycastHit hit;

        if (Physics.Raycast(obj.transform.position + (downVec * rayDirectionOffsetFromObject), downVec, out hit, rayRange))
        {
            // Use to debug the Physics.RayCast.
            //Debug.DrawRay(obj.transform.position + (downVec * rayDirectionOffsetFromObject), downVec * rayRange, Color.red);

            MeshDeformation deformer = hit.collider.GetComponent <MeshDeformation>();

            //Debug.Log("object: "+ hit.collider.gameObject.name);

            if (deformer)
            {
                //Debug.Log("hit at point: "+ hit.point);
                Vector3 point = hit.point;
                point += hit.normal * forceOffset;
                deformer.AddDeformingForce(point, force);
            }
        }
    }
コード例 #9
0
ファイル: Planet.cs プロジェクト: cking20/GodGameVR
    public void GeneratePlanet()
    {
        ColorVertexes cv = GetComponent <ColorVertexes>();

        cv.DirtLevel  = terrainRadius - 3;
        cv.GrassLevel = terrainRadius + 1;
        cv.RockLevel  = terrainRadius + 4;
        cv.SnowLevel  = terrainRadius + 7;


        CubeSphere cs = GetComponent <CubeSphere>();

        cs.radius   = terrainRadius;
        cs.gridSize = detailLevel;
        cs.Build();

        MeshDeformation md = GetComponent <MeshDeformation>();

        md.Build();

        GetComponent <GenerateTerrain>().GenTerrain();
        //water
        transform.GetChild(0).localScale = new Vector3(terrainRadius * 2, terrainRadius * 2, terrainRadius * 2);
        transform.GetChild(0).gameObject.SetActive(true);
        //atmos
        transform.GetChild(1).localScale = new Vector3((terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2, (terrainRadius + atmosphereRadius) * 2);
        transform.GetChild(1).gameObject.SetActive(true);
        //clouds
        //ParticleSystem.ShapeModule shapeModule = transform.GetChild(2).GetComponent<ParticleSystem>().shape;
        //shapeModule.radius = atmosphereRadius + terrainRadius;
        //ParticleSystem.MainModule mainMondule = transform.GetChild(2).GetComponent<ParticleSystem>().main;
        //mainMondule.maxParticles = (int)atmosphereRadius * 2;

        //objects
        GetComponent <PlanetObjectsHandler>().Build();
    }
コード例 #10
0
ファイル: PlayerControl.cs プロジェクト: gylesis/Spike-N-Ball
 private void Start()
 {
     Rigidbody    = GetComponent <Rigidbody>();
     _deformation = GetComponent <MeshDeformation>();
 }
コード例 #11
0
ファイル: MDEditor.cs プロジェクト: anviettrung/Brick-Laying
 private void Awake()
 {
     mTarget = (MeshDeformation)target;
 }