Example #1
0
    public void Initialize()
    {
        for (int i = 0; i < 7; i++)
        {
            Channel_GammaLowerBound[i] = 0.0f;
            Channel_GammaUpperBound[i] = 1.0f;
            Channel_GammaCurveValue[i] = 0.5f;
        }


        // for Coroutine test use
        StartCoroutine(LoadTexture());

        string PathRetrieved = PlayerPrefs.GetString("assetPath");

        if (PathRetrieved != "")
        {
            AssetPath = "Assets/" + PathRetrieved;
        }
        Debug.Log("Path retrieved:" + AssetPath);

        if (AssetPath.Contains("Nils"))
        {
            AssetFormat = Option.SINGLECHANNEL;
        }
        else
        {
            AssetFormat = Option.MULTICHANNEL;
        }

        // create cube for raytracing
        GetComponent <MeshFilter>().sharedMesh = buildMesh(pwidth, pheight, pdepth);

        ThisTransform = GetComponent <Transform>();

        ThisFPSCalculator = GetComponent <FPSCalculator>();

        // startup based on asset format
        switch (AssetFormat)
        {
        case Option.SINGLECHANNEL:
            //Resources.LoadAsync
            material        = (Material)Resources.Load("Materials/SingleChannel", typeof(Material));
            NextAssetFormat = Option.SINGLECHANNEL;
            SingleChannelStartup(AssetPath);
            break;

        case Option.MULTICHANNEL:
            material        = (Material)Resources.Load("Materials/MultiChannel", typeof(Material));
            NextAssetFormat = Option.MULTICHANNEL;
            MultiChannelStartup(AssetPath);
            break;

        case Option.VIDEO:
            material        = (Material)Resources.Load("Materials/Video", typeof(Material));
            NextAssetFormat = Option.VIDEO;
            VideoStartup(AssetPath);
            break;

        case Option.MASK:
            material        = (Material)Resources.Load("Materials/Mask", typeof(Material));
            NextAssetFormat = Option.MASK;
            MaskStartup(AssetPath);
            break;
        }

        //
        NextAssetPath = AssetPath;

        // apply material with shader specified for the selected asset format
        GetComponent <MeshRenderer>().sharedMaterial = material;

        // initialize volume dimensions
        material.SetFloat("_Pwidth", pwidth);
        material.SetFloat("_Pheight", pheight);
        material.SetFloat("_Pdepth", pdepth);
        material.SetFloat("_Nwidth", nwidth);
        material.SetFloat("_Nheight", nheight);
        material.SetFloat("_Ndepth", ndepth);
        transform.localScale = dimensions;

        //
        PreviousAssetFormat = NextAssetFormat;
        PreviousAssetPath   = NextAssetPath;

        ScaleCount = 0;

        xscale = transform.localScale.x;
        yscale = transform.localScale.y;
        zscale = transform.localScale.z;

        //GameObject go = GameObject.Find("DesktopCanvas");
        //DesktopSliderManager other = (DesktopSliderManager)go.GetComponent(typeof(DesktopSliderManager));
        //other.SetInitialScaleSliderValue();
    }