Exemple #1
0
        public static void InstantiateImportExport(ProjectorBrain projectorBrain, ProjectorMount mount, KinectBrain kinectBrain, string name, string path)
        {
            GameObject go = new GameObject(name + " ImportExport");

            go.transform.position = Vector3.zero;

            ImportExportSettings asset = ScriptableObject.CreateInstance <ImportExportSettings>();

            AssetDatabase.CreateAsset(asset, "Assets/" + path + "/Import_Export_Settings.asset");
            EditorUtility.SetDirty(asset);

            ImportExportSystem importExport = go.AddComponent <ImportExportSystem>();

            importExport.Settings       = asset;
            importExport.EnableInEditor = false;
            importExport.Entries        = new List <ImportExportEntry>();

            importExport.Entries.Add(new ImportExportEntry(projectorBrain.gameObject, projectorBrain.Settings));

            ProjectorEmitter[] emitters = mount.Get();

            for (int i = emitters.Length - 1; i >= 0; --i)
            {
                importExport.Entries.Add(new ImportExportEntry(emitters[i].gameObject, emitters[i].Configuration));
            }

            importExport.Entries.Add(new ImportExportEntry(kinectBrain.gameObject, kinectBrain.Settings));
        }
Exemple #2
0
        public static void InstantiateMenu(ProjectorBrain projectorBrain, ProjectorMount mount, KinectBrain kinectBrain, string name)
        {
            GameObject eventSystem = PrefabUtility.InstantiatePrefab("EventSystem");

            eventSystem.name = "EventSystem";

            GameObject menu = PrefabUtility.InstantiatePrefab("Menu");

            menu.name = name + " Menu";

            ProjectorEmitter[] emitters = mount.Get();

            Camera menuCamera = null;

            for (int i = emitters.Length - 1; i >= 0; --i)
            {
                if (emitters[i].Configuration.DisplayName == "Front")
                {
                    menuCamera = emitters[i].GetComponent <Camera>();
                    break;
                }
            }

            if (menuCamera == null)
            {
                menuCamera = emitters[0].Camera.GetComponent <Camera>();
            }

            MenuManager menuManager = menu.GetComponent <MenuManager>();

            menuManager.MenuCamera     = menuCamera;
            menuManager.ProjectorBrain = projectorBrain;
            menuManager.KinectBrain    = kinectBrain;
        }
Exemple #3
0
        public static ProjectorEyes CreateEyes(ProjectorBrain brain, string name = "Head")
        {
            GameObject go = new GameObject(name);

            go.transform.parent        = brain.transform;
            go.transform.localPosition = new Vector3(0f, 1.8f, 0f);

            return(go.AddComponent <ProjectorEyes>());
        }
Exemple #4
0
        public static ProjectorPlane CreatePlane(ProjectorBrain brain, Vector3 position, Vector3 angles, string name = "Projector Plane")
        {
            GameObject go = new GameObject(name);

            go.transform.parent           = brain.transform;
            go.transform.localPosition    = position;
            go.transform.localEulerAngles = angles;

            return(go.AddComponent <ProjectorPlane>());
        }
Exemple #5
0
        private ProjectorPlane CreatePlane(ProjectorBrain brain, Vector3 position, Vector3 angles)
        {
            GameObject go = new GameObject();

            go.transform.parent           = brain.transform;
            go.transform.localPosition    = position;
            go.transform.localEulerAngles = angles;

            go.name = "Plane " + RotationToName(go.transform.localEulerAngles);

            return(go.AddComponent <ProjectorPlane>());
        }
Exemple #6
0
        public static ProjectorMount CreateMount(ProjectorBrain brain, ProjectorEyes eyes, string name = "Projector Mount")
        {
            GameObject go = new GameObject(name);

            go.transform.parent        = brain.transform;;
            go.transform.localPosition = new Vector3(0f, 1f, 0f);

            ProjectorMount mount = go.AddComponent <ProjectorMount>();

            mount.Target = eyes.transform;
            return(mount);
        }
Exemple #7
0
        public static void AttachController(ProjectorBrain brain, ProjectorEyes eyes, bool joycon)
        {
            GenericController controller = brain.gameObject.AddComponent <GenericController>();

            controller.Head        = eyes.transform;
            controller.Speed       = 5f;
            controller.Snappyness  = 4f;
            controller.Sensitivity = 2f;

            brain.gameObject.AddComponent <MouseKeyboardUserControl>();

            if (joycon)
            {
                brain.gameObject.AddComponent <JoyconUserControl>();
            }
        }
Exemple #8
0
        public static void AttachKinect(ProjectorBrain brain, ProjectorEyes eyes, Vector3 location, string path)
        {
            KinectBrain kinectBrain = brain.gameObject.AddComponent <KinectBrain>();

            eyes.gameObject.AddComponent <KinectActor>();
            eyes.gameObject.AddComponent <KinectHead>();

            KinectSettings asset = ScriptableObject.CreateInstance <KinectSettings>();

            asset.SensorLocation = location;
            asset.TrackingArea   = new Rect(0f, 0f, 2f, 2f);

            AssetDatabase.CreateAsset(asset, "Assets/" + path + "/Kinect_Settings.asset");
            EditorUtility.SetDirty(asset);

            kinectBrain.Settings = asset;
        }
Exemple #9
0
        public override void Build(ModuleMaker maker, GameObject root, GameObject head)
        {
            ProjectorBrain brain = root.AddComponent <ProjectorBrain>();

            brain.transform.position = this.position;

            ProjectorEyes eyes = head.AddComponent <ProjectorEyes>();

            eyes.transform.parent        = brain.transform;
            eyes.transform.localPosition = new Vector3(0f, 1.8f, 0f);

            ProjectorMount mount = (new GameObject("Mount")).AddComponent <ProjectorMount>();

            mount.transform.parent        = brain.transform;
            mount.transform.localPosition = eyes.transform.localPosition;
            mount.Eyes = eyes;

            if (this.selection.HasFlag(ProjectorSelection.Front))
            {
                ProjectorPlane  plane  = CreatePlane(brain, new Vector3(0, this.height * 0.5f, this.length * 0.5f), Vector3.zero);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Front), this.width, this.height);
            }

            if (this.selection.HasFlag(ProjectorSelection.Back))
            {
                ProjectorPlane  plane  = CreatePlane(brain, new Vector3(0, this.height * 0.5f, -this.length * 0.5f), Vector3.up * 180f);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Back), this.width, this.height);
            }

            if (this.selection.HasFlag(ProjectorSelection.Top))
            {
                ProjectorPlane  plane  = CreatePlane(brain, new Vector3(0, this.height, 0), Vector3.right * -90f);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Top), this.width, this.length);
            }

            if (this.selection.HasFlag(ProjectorSelection.Bottom))
            {
                ProjectorPlane  plane  = CreatePlane(brain, Vector3.zero, Vector3.right * 90f);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Bottom), this.width, this.length);
            }

            if (this.selection.HasFlag(ProjectorSelection.Left))
            {
                ProjectorPlane  plane  = CreatePlane(brain, new Vector3(-this.width * 0.5f, this.height * 0.5f, 0), Vector3.up * -90f);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Left), this.length, this.height);
            }

            if (this.selection.HasFlag(ProjectorSelection.Right))
            {
                ProjectorPlane  plane  = CreatePlane(brain, new Vector3(this.width * 0.5f, this.height * 0.5f, 0), Vector3.up * 90f);
                ProjectorCamera camera = CreateCamera(mount, plane);
                CreateCameraConfiguration(camera, SelectionToDisplayId(ProjectorSelection.Right), this.length, this.height);
            }

            string            assetPath = ModuleMaker.AssetPath + "/Projector Settings.asset";
            ProjectorSettings asset     = AssetDatabase.LoadAssetAtPath <ProjectorSettings>(assetPath);

            if (asset == null)
            {
                asset = ScriptableObject.CreateInstance <ProjectorSettings>();
                asset.CameraTarget      = this.target;
                asset.ForceFullScreen   = false;
                asset.StereoSeparation  = 0.064f;
                asset.StereoConvergence = 10f;
                asset.NearClipPlane     = 0.01f;
                asset.FarClipPlane      = 1000f;
                AssetDatabase.CreateAsset(asset, assetPath);
            }

            brain.Settings = asset;
        }
Exemple #10
0
        public static void CreateRig(RigInfo rigInfo)
        {
            RigUtility.CreateAssetsFolder(rigInfo.assetsFolder);

            ProjectorBrain brain = RigUtility.CreateBrain(rigInfo.position, rigInfo.name);
            ProjectorEyes  eyes  = RigUtility.CreateEyes(brain);
            ProjectorMount mount = RigUtility.CreateMount(brain, eyes);

            if (rigInfo.selection.HasFlag(RigSelection.Front))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, new Vector3(0, rigInfo.height * 0.5f, rigInfo.length * 0.5f), Vector3.zero, "Projector Plane Front");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Front");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Front");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.width, rigInfo.height, 2, "Front");
                }
            }

            if (rigInfo.selection.HasFlag(RigSelection.Back))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, new Vector3(0, rigInfo.height * 0.5f, -rigInfo.length * 0.5f), Vector3.up * 180f, "Projector Plane Back");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Back");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Back");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.width, rigInfo.height, 4, "Back");
                }
            }

            if (rigInfo.selection.HasFlag(RigSelection.Top))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, new Vector3(0, rigInfo.height, 0), Vector3.right * -90f, "Projector Plane Top");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Top");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Top");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.width, rigInfo.length, 5, "Top");
                }
            }

            if (rigInfo.selection.HasFlag(RigSelection.Bottom))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, Vector3.zero, Vector3.right * 90f, "Projector Plane Bottom");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Bottom");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Bottom");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.width, rigInfo.length, 6, "Bottom");
                }
            }

            if (rigInfo.selection.HasFlag(RigSelection.Left))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, new Vector3(-rigInfo.width * 0.5f, rigInfo.height * 0.5f, 0), Vector3.up * -90f, "Projector Plane Left");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Left");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Left");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.length, rigInfo.height, 1, "Left");
                }
            }

            if (rigInfo.selection.HasFlag(RigSelection.Right))
            {
                ProjectorPlane   plane   = RigUtility.CreatePlane(brain, new Vector3(rigInfo.width * 0.5f, rigInfo.height * 0.5f, 0), Vector3.up * 90f, "Projector Plane Right");
                ProjectorEmitter emitter = RigUtility.CreateEmitter(mount, plane, "Projector Emitter Right");

                if (rigInfo.buildReady)
                {
                    emitter.Configuration = RigUtility.CreateConfiguration(emitter, rigInfo.assetsFolder, "Projector_Configuration_Right");
                    RigUtility.DefaultConfiguration(emitter.Configuration, rigInfo.length, rigInfo.height, 3, "Right");
                }
            }

            if (rigInfo.buildReady)
            {
                brain.Settings = RigUtility.CreateSettings(rigInfo.assetsFolder);
                RigUtility.DefaultSettings(brain.Settings);
                RigUtility.AttachController(brain, eyes, rigInfo.joycon);
            }

            if (rigInfo.sceneTools)
            {
                mount.Gizmos = ProjectorGizmos.Viewport | ProjectorGizmos.Wireframe;
            }

            if (rigInfo.kinect)
            {
                RigUtility.AttachKinect(brain, eyes, new Vector3(0f, rigInfo.height + 0.25f, rigInfo.length * 0.5f), rigInfo.assetsFolder);
            }

            RigUtility.InstantiateImportExport(brain, mount, brain.GetComponent <KinectBrain>(), rigInfo.name, rigInfo.assetsFolder);

            if (rigInfo.menu)
            {
                RigUtility.InstantiateMenu(brain, mount, brain.GetComponent <KinectBrain>(), rigInfo.name);
            }

            if (rigInfo.joycon)
            {
                RigUtility.InstantiateJoycons();
            }

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }