protected override void OnCaptureFrame_() { if (studio.shadow.type == ShadowType.TopDown) { Camera camera; GameObject fieldObj; ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj); ShadowHelper.BakeStaticShadow(camera, fieldObj, particleModel, studio); } }
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(); } }
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); } }
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(); } }
public void OnCaptureFrame() { try { double deltaTime = EditorApplication.timeSinceStartup - prevTime; if (deltaTime < studio.frame.delay) { return; } prevTime = EditorApplication.timeSinceStartup; if (studio.shadow.type == ShadowType.TopDown) { Camera camera; GameObject fieldObj; ShadowHelper.GetCameraAndFieldObject(studio.shadow.obj, out camera, out fieldObj); ShadowHelper.BakeStaticShadow(camera, fieldObj, particleModel, studio); } Texture2D tex = CapturingHelper.CaptureModelManagingShadow(model, studio); IntegerBound texBound = new IntegerBound(); if (!TextureHelper.CalcTextureBound(tex, pivot2D, texBound)) { texBound.min.x = pivot2D.x - 1; texBound.max.x = pivot2D.x + 1; texBound.min.y = pivot2D.y - 1; texBound.max.y = pivot2D.y + 1; } if (studio.trimming.on) { if (studio.trimming.isUnifiedForAllViews) { TextureHelper.MakeUnifiedBound(pivot2D, texBound, unifiedTexBound); } else { pivot2D.SubtractWithMargin(texBound.min, studio.trimming.margin); tex = TextureHelper.TrimTexture(tex, texBound, studio.trimming.margin, EngineGlobal.CLEAR_COLOR32); } } if (studio.packing.on || studio.trimming.isUnifiedForAllViews) { frameModelTextures[frameIndex] = tex; framePivots[frameIndex] = pivot2D; } else // !studio.packing.on && !studio.trim.isUnifiedSize { BakeIndividually(tex, pivot2D, viewName, frameIndex); } stateMachine.ChangeState(BakingState.EndFrame); } catch (Exception e) { Debug.LogException(e); Finish(); } }
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(); } }