Ejemplo n.º 1
0
    void Start()
    {
        camTransform       = this.gameObject.transform;
        initialCamposition = this.gameObject.transform.position;
        initialCamRotation = this.gameObject.transform.rotation;

        barracudaRunner = GameObject.Find("BarracudaRunner").GetComponent <VNectBarracudaRunner>();
        uiScript        = GameObject.Find("UICanvas").GetComponent <UIScript>();
        mainCamera      = GetComponent <Camera>();
    }
Ejemplo n.º 2
0
    void Start()
    {
        skeletonMaterial = Resources.Load("Skeleton", typeof(Material)) as Material;

        barracudaRunner = GameObject.Find("BarracudaRunner").GetComponent <VNectBarracudaRunner>();
        barracudaRunner.ModelQuality = configurationSetting.TrainedModel;

        videoCapture = GameObject.Find("MainTexrure").GetComponent <VideoCapture>();

        Menu        = GameObject.Find("Menu");
        cameraMover = GameObject.Find("MainCamera").GetComponent <CameraMover>();

        sourceDevice = GameObject.Find("SourceDevice").GetComponent <Dropdown>();
        WebCamDevice[] devices = WebCamTexture.devices;
        foreach (var d in devices)
        {
            sourceDevice.options.Add(new Dropdown.OptionData(d.name));
        }
        sourceDevice.value = 0;

        btnPause     = GameObject.Find("btnPause").GetComponent <Button>();
        ifFrame      = GameObject.Find("ifFrame").GetComponent <InputField>();
        txFrameCount = GameObject.Find("txFrameCount").GetComponent <Text>();
        btnSkip      = GameObject.Find("btnSkip").GetComponent <Button>();
        pnlVideoIF   = GameObject.Find("pnlVideoIF");
        pnlVideoIF.SetActive(false);

        btnSourceDevice = GameObject.Find("btnSourceDevice").GetComponent <Button>();
        txtFPS          = GameObject.Find("txtFPS").GetComponent <Text>();
        btnRecord       = GameObject.Find("btnRecord").GetComponent <Button>();

        avatars = GameObject.Find("Avatars").GetComponent <Dropdown>();

        avatarSetting = GameObject.Find("AvatarSetting").GetComponent <AvatarSettingScript>();
        avatarSetting.Init();
        avatarSetting.gameObject.SetActive(false);
        configuration = GameObject.Find("Configuration").GetComponent <ConfigurationScript>();
        configuration.Init();
        configuration.gameObject.SetActive(false);

        ReflectConfiguration(configurationSetting);

        var settings = PlayerPrefs.GetString("AvatarSettings", "");

        //settings = "";
        // Decode Avatar Setting
        string[] asStr = settings.Split(';');
        foreach (var s in asStr)
        {
            string[] col = s.Split(',');
            if (col.Length != 16)
            {
                continue;
            }
            var setting = new AvatarSetting();

            if (!int.TryParse(col[0], out setting.AvatarType))
            {
                continue;
            }
            if (setting.AvatarType < 0)
            {
            }
            else if (setting.AvatarType == 0)
            {
                setting.VRMFilePath = col[1];
            }
            else if (setting.AvatarType == 1)
            {
                setting.FBXFilePath = col[1];
            }
            setting.AvatarName = col[2];
            if (!float.TryParse(col[3], out setting.PosX))
            {
                continue;
            }
            if (!float.TryParse(col[4], out setting.PosY))
            {
                continue;
            }
            if (!float.TryParse(col[5], out setting.PosZ))
            {
                continue;
            }
            if (!float.TryParse(col[6], out setting.DepthScale))
            {
                continue;
            }
            if (!float.TryParse(col[7], out setting.Scale))
            {
                continue;
            }
            if (!float.TryParse(col[8], out setting.FaceOriX))
            {
                continue;
            }
            if (!float.TryParse(col[9], out setting.FaceOriY))
            {
                continue;
            }
            if (!float.TryParse(col[10], out setting.FaceOriZ))
            {
                continue;
            }
            if (!int.TryParse(col[11], out setting.SkeletonVisible))
            {
                continue;
            }
            if (!float.TryParse(col[12], out setting.SkeletonPosX))
            {
                continue;
            }
            if (!float.TryParse(col[13], out setting.SkeletonPosY))
            {
                continue;
            }
            if (!float.TryParse(col[14], out setting.SkeletonPosZ))
            {
                continue;
            }
            if (!float.TryParse(col[15], out setting.SkeletonScale))
            {
                continue;
            }

            AvatarList.Add(setting);
        }
        ;

        if (AvatarList.Count == 0)
        {
            var setting = new AvatarSetting()
            {
                AvatarType = -1,
                AvatarName = "unity-chan",
                Avatar     = GameObject.Find("unitychan").GetComponent <VNectModel>(),
            };
            setting.Avatar.SetNose(setting.FaceOriX, setting.FaceOriY, setting.FaceOriZ);
            AvatarList.Add(setting);
            barracudaRunner.InitVNectModel(setting.Avatar);

            setting = new AvatarSetting()
            {
                AvatarType = -2,
                AvatarName = "yukihiko-chan",
                Avatar     = GameObject.Find("YukihikoAoyagi").GetComponent <VNectModel>(),
            };
            setting.Avatar.SetNose(setting.FaceOriX, setting.FaceOriY, setting.FaceOriZ);
            AvatarList.Add(setting);
            barracudaRunner.InitVNectModel(setting.Avatar);
        }

        avatars.options.Clear();
        foreach (var setting in AvatarList)
        {
            if (setting.AvatarType >= 0)
            {
                LoadAvatar(setting);
            }
            else if (setting.AvatarType < 0)
            {
                avatars.options.Add(new Dropdown.OptionData(setting.AvatarName));

                switch (setting.AvatarType)
                {
                case -1:
                    setting.Avatar = GameObject.Find("unitychan").GetComponent <VNectModel>();
                    break;

                case -2:
                    setting.Avatar = GameObject.Find("YukihikoAoyagi").GetComponent <VNectModel>();
                    break;
                }

                setting.Avatar.SetNose(setting.FaceOriX, setting.FaceOriY, setting.FaceOriZ);
                barracudaRunner.InitVNectModel(setting.Avatar);
            }
        }
        avatars.value = 0;
        ChangedAvatar(0);
    }