Пример #1
0
        protected override void Finish_()
        {
            if (studio.shadow.type == ShadowType.TopDown)
            {
                ObjectHelper.DeleteObject(EditorGlobal.STATIC_SHADOW_NAME);
                studio.shadow.obj = ObjectHelper.GetOrCreateObject(EditorGlobal.DYNAMIC_SHADOW_NAME, EditorGlobal.SHADOW_FOLDER_NAME, Vector3.zero);

                ShadowHelper.LocateShadowToModel(particleModel, studio);
            }
        }
Пример #2
0
        public void OnInitialize()
        {
            try
            {
                if (studio.view.rotationType == RotationType.Model)
                {
                    CameraHelper.LocateMainCameraToModel(model, studio);
                }

                ShadowHelper.LocateShadowToModel(model, studio);

                if (studio.shadow.type == ShadowType.Simple)
                {
                    ShadowHelper.ScaleSimpleShadow(model, studio);
                }
                else if (studio.shadow.type == ShadowType.TopDown)
                {
                    Camera     camera;
                    GameObject fieldObj;
                    ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                    CameraHelper.LookAtModel(camera.transform, model);
                    ShadowHelper.ScaleShadowField(camera, fieldObj);
                }
                else if (studio.shadow.type == ShadowType.Matte)
                {
                    ShadowHelper.ScaleMatteField(meshModel, studio.shadow.obj, studio.lit);
                }

                if (studio.packing.on || studio.trimming.isUnifiedForAllViews)
                {
                    bakingDataList = new BakingData[studio.view.checkedSubViews.Count];
                }

                if (studio.trimming.isUnifiedForAllViews)
                {
                    unifiedTexBound = new IntegerBound();
                }

                fileBaseName = BuildFileBaseName();
                BuildFolderPathAndCreate(modelName);

                viewIndex = 0;

                stateMachine.ChangeState(BakingState.BeginView);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Finish();
            }
        }
Пример #3
0
        public static void DoCameraFollowing(Model model, Vector3 modelPosition, Vector3 vecFromCameraToModel, Studio studio)
        {
            Camera.main.transform.position = modelPosition - vecFromCameraToModel;

            if (studio.shadow.type == ShadowType.TopDown)
            {
                ShadowHelper.LocateShadowToModel(model, studio);
            }

            if (studio.lit.cameraPositionFollow)
            {
                studio.lit.com.transform.position = Camera.main.transform.position;
            }
        }
Пример #4
0
        protected override void OnInitialize_()
        {
            if (studio.shadow.type == ShadowType.TopDown)
            {
                ObjectHelper.DeleteObject(EditorGlobal.DYNAMIC_SHADOW_NAME);
                studio.shadow.obj = ObjectHelper.GetOrCreateObject(EditorGlobal.STATIC_SHADOW_NAME, EditorGlobal.SHADOW_FOLDER_NAME, Vector3.zero);

                ShadowHelper.LocateShadowToModel(particleModel, studio);

                Camera     camera;
                GameObject fieldObj;
                ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                CameraHelper.LookAtModel(camera.transform, particleModel);
                ShadowHelper.ScaleShadowField(camera, fieldObj);
            }
        }
Пример #5
0
        public void OnInitialize()
        {
            try
            {
                if (studio.view.rotationType == RotationType.Model)
                {
                    CameraHelper.LocateMainCameraToModel(model, studio);
                }

                if (studio.shadow.type == ShadowType.TopDown)
                {
                    ObjectHelper.DeleteObject(EditorGlobal.DYNAMIC_SHADOW_NAME);
                    studio.shadow.obj = ObjectHelper.GetOrCreateObject(EditorGlobal.STATIC_SHADOW_NAME, EditorGlobal.SHADOW_FOLDER_NAME, Vector3.zero);

                    ShadowHelper.LocateShadowToModel(model, studio);

                    Camera     camera;
                    GameObject fieldObj;
                    ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                    CameraHelper.LookAtModel(camera.transform, model);
                    ShadowHelper.ScaleShadowField(camera, fieldObj);
                }
                else
                {
                    ShadowHelper.LocateShadowToModel(model, studio);
                }

                particleModel.Animate(Frame.BEGIN); // important for particle simulation

                if (particleModel.selectedFrames.Count > 0)
                {
                    frames = new Frame[particleModel.selectedFrames.Count];
                    particleModel.selectedFrames.CopyTo(frames);
                }
                else
                {
                    frames = new Frame[studio.frame.size];
                    for (int i = 0; i < studio.frame.size; ++i)
                    {
                        float frameRatio = 0.0f;
                        if (i > 0 && i < studio.frame.size)
                        {
                            frameRatio = (float)i / (float)(studio.frame.size - 1);
                        }

                        float time = particleModel.GetTimeForRatio(frameRatio);
                        frames[i] = new Frame(i, time);
                    }
                }

                fileBaseName = BuildFileBaseName();
                BuildFolderPathAndCreate(modelName);

                if (studio.packing.on && studio.output.animatorControllerMake)
                {
                    BuildAnimatorController();
                }

                viewIndex = 0;

                stateMachine.ChangeState(BakingState.BeginView);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Finish();
            }
        }
Пример #6
0
        public void OnInitialize()
        {
            try
            {
                if (studio.view.rotationType == RotationType.Model)
                {
                    CameraHelper.LocateMainCameraToModel(model, studio);
                }

                ShadowHelper.LocateShadowToModel(model, studio);

                if (studio.shadow.type == ShadowType.TopDown)
                {
                    Camera     camera;
                    GameObject fieldObj;
                    ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj);

                    CameraHelper.LookAtModel(camera.transform, model);
                    ShadowHelper.ScaleShadowField(camera, fieldObj);
                }
                else if (studio.shadow.type == ShadowType.Matte)
                {
                    ShadowHelper.ScaleMatteField(meshModel, studio.shadow.obj, studio.lit);
                }

                fileNameForModel = BuildFileBaseName();
                BuildFolderPathAndCreate(modelName);

                if (studio.packing.on)
                {
                    if (DoesMakePrefab())
                    {
                        outRootPrefab = PrefabUtility.InstantiatePrefab(model.spritePrefab) as GameObject;
                        outRootPrefab.gameObject.SetActive(false);

                        if (studio.output.DoesMakeLocationPrefab())
                        {
                            Location[] locations = model.GetComponentsInChildren <Location>();
                            if (locations.Length > 0)
                            {
                                locationMappings = new LocationMapping[locations.Length];
                                for (int i = 0; i < locations.Length; ++i)
                                {
                                    Location   loc    = locations[i];
                                    GameObject locObj = PrefabUtility.InstantiatePrefab(studio.output.locationSpritePrefab) as GameObject;
                                    locObj.transform.parent        = model.prefabBuilder.GetLocationsParent(outRootPrefab);
                                    locObj.transform.localPosition = Vector3.zero;
                                    locObj.transform.localRotation = Quaternion.identity;
                                    locObj.name        += "_" + loc.locationName;
                                    locationMappings[i] = new LocationMapping(loc, locObj);
                                }
                            }
                        }

                        if (outRootPrefab != null && studio.output.animatorControllerMake && studio.output.normalMapMake)
                        {
                            animationTextureDataList = new List <AnimationTextureData>();
                        }
                    }
                }

                AnimationIndex = 0;

                stateMachine.ChangeState(BakingState.BeginAnimation);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                Finish();
            }
        }