예제 #1
0
    /*
     * when a new custom index of refraction is entered
     */
    public string NewIndex(RefractableMaterial rm, string input)
    {
        float newRefraction = CheckFieldInputs(input, 0.0f, 10.0f);

        rm.SetCustomRefraction(newRefraction);

        return("" + rm.GetIndexOfRefraction());
    }
예제 #2
0
    /*
     * set up world from json string
     */
    public void SetUpWorld(string json)
    {
        // generate lab instance model object from json string
        LabInstance li = JsonUtility.FromJson <LabInstance>(json);

        // set laser object from json
        laser.transform.position = li.lm.pos;
        laser.transform.rotation = li.lm.rot;

        // set lab manager's refratable material componenet from json
        rm.SetPresetRefraction((RefractableMaterial.IndexesOfRefraction)Enum.ToObject(typeof(RefractableMaterial.IndexesOfRefraction), li.worldRM.presetRefraction));
        rm.SetCustomRefraction(li.worldRM.n);

        int x = 0;

        // set available refratable materials
        foreach (RefractableMaterial rm in rms)
        {
            rm.transform.position = li.refractableMaterials.materials[x].pos;
            rm.transform.rotation = li.refractableMaterials.materials[x].rot;
            rm.SetPresetRefraction((RefractableMaterial.IndexesOfRefraction)Enum.ToObject(typeof(RefractableMaterial.IndexesOfRefraction), li.refractableMaterials.materials[x].presetRefraction));
            rm.SetCustomRefraction(li.refractableMaterials.materials[x].n);

            x++;
        }

        // if there are more materials to generate, create new ones
        while (rms.Count < li.refractableMaterials.materials.Count)
        {
            RefractableMaterial temp = AddObject();

            temp.transform.position = li.refractableMaterials.materials[x].pos;
            temp.transform.rotation = li.refractableMaterials.materials[x].rot;
            temp.SetPresetRefraction((RefractableMaterial.IndexesOfRefraction)Enum.ToObject(typeof(RefractableMaterial.IndexesOfRefraction), li.refractableMaterials.materials[x].presetRefraction));

            Debug.Log(li.refractableMaterials.materials[x].presetRefraction);
            Debug.Log("PR: " + temp.GetPresetIndex());

            temp.SetCustomRefraction(li.refractableMaterials.materials[x].n);

            x++;
        }
    }