/// <summary> /// Generates avatar with the selected set of resources and displayed it in AvatarViewer scene /// </summary> protected override IEnumerator GenerateAndDisplayHead(byte[] photoBytes, PipelineType pipeline) { //Get selected resources AvatarResources avatarResources = GetSelectedResources(); Debug.Log(CoreTools.GetAvatarCalculationParamsJson(avatarResources)); yield return(Await(null)); // generate avatar from the photo and get its code in the Result of request /* * var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", pipeline, avatarResources); * yield return Await(initializeRequest); * string avatarCode = initializeRequest.Result; * * StartCoroutine(SampleUtils.DisplayPhotoPreview(avatarCode, photoPreview)); * * var calculateRequest = avatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode); * yield return Await(calculateRequest); * * AvatarViewer.SetSceneParams(new AvatarViewer.SceneParams() * { * avatarCode = avatarCode, * showSettings = false, * sceneToReturn = SceneManager.GetActiveScene().name, * avatarProvider = avatarProvider, * useAnimations = false * }); * SceneManager.LoadScene(Scenes.GetSceneName(SceneType.AVATAR_VIEWER)); */ }
public ReportGenerator(IDataProviderFactory dataProviderFactory, PipelineType pipelineType, ILogger logger) { _logger = logger; _dataProviders = dataProviderFactory.GetPipelineDataProviders(); _dataPostProcessors = dataProviderFactory.GetPostProcessors(); _pipelineType = pipelineType; }
private IEnumerator Await(AsyncRequest r, PipelineType pipelineType) { while (!r.IsDone) { yield return(null); if (r.IsError) { Debug.LogError(r.ErrorMessage); yield break; } if (pipelineType == PipelineType.HEAD) { var progress = new List <string>(); AsyncRequest request = r; while (request != null) { progress.Add(string.Format("{0}: {1}%", request.State, request.ProgressPercent.ToString("0.0"))); request = request.CurrentSubrequest; } progressText.text = string.Join("\n", progress.ToArray()); } } if (pipelineType == PipelineType.HEAD) { progressText.text = string.Empty; } }
private AsyncRequest DownloadAvatarAsync(AvatarData avatar, PipelineType pipelineType) { var request = new AsyncRequest(); AvatarSdkMgr.SpawnCoroutine(DownloadAvatarFunc(avatar, pipelineType, request)); return(request); }
/// <summary> /// <para>Initializes an instance of the <see cref="ComponentPipeline"/> class.</para> /// </summary> /// <param name="pipelineType"> /// The type of pipeline (send/receive). /// </param> public ComponentPipeline(PipelineType pipelineType) { this.pipelineType = pipelineType; instanceManagerCollection = new List <ComponentInstanceManager>(); AddComponent(typeof(DefaultPassThroughComponent)); }
public ObservableCollection <Pipeline> GetAllPipelinesByType(PipelineType type) { return(new ObservableCollection <Pipeline>( this._catalog.Pipelines .Cast <Pipeline>() .Where(x => x.Type == type) .OrderBy(x => x.FullName) )); }
protected Material SolidColorMaterial(PipelineType pipelineType, Vector4 color) { return(new Material() { Ambient = 0.2f, Color = color, PipelineType = pipelineType, }); }
protected override void EndWork() { var type = PipelineType.ToString(); if (type == "ImportLoadFile") { CleanUpImportLoadFileResources(); } }
public IndirectArgument(PipelineType pipeline, CameraType camera, bool hasTransparency, Vector3 location, string binding, IndirectDrawIndexedArguments arguments) { Pipeline = pipeline; Camera = camera; HasTransparency = hasTransparency; Location = location; Binding = binding; Arguments = arguments; }
protected Material SolidTextureMaterial(PipelineType pipelineType) { return(new Material() { DiffuseTexture = Texture.GetFromFile("Textures/woodenbox.png"), SpecularTexture = Texture.GetFromFile("Textures/woodenbox_specular.png"), Ambient = 0.2f, PipelineType = pipelineType, }); }
public void OnPipelineTypeToggleChanged(bool isChecked) { if (facePipelineToggle.isOn) { pipelineType = PipelineType.FACE; } else if (headPipelineToggle.isOn) { pipelineType = PipelineType.HEAD; } }
public BufferGroup(PipelineType pipeline, CameraType camera, bool hasTransparency, Vector3 location, string binding, uint offset, uint count) { Pipeline = pipeline; Camera = camera; HasTransparency = hasTransparency; Location = location; Binding = binding; Offset = offset; Count = count; }
public static string GetPipelineTypeName(this PipelineType pipelineType) { switch (pipelineType) { case PipelineType.HEAD: return("head"); case PipelineType.FACE: default: return("animated_face"); } }
/// <summary> /// Create avatar and save photo to disk. /// </summary> private IEnumerator CreateNewAvatar(byte[] photoBytes) { PipelineType pipeline = pipelineType; // Choose default set of resources to generate var resourcesRequest = avatarProvider.ResourceManager.GetResourcesAsync(AvatarResourcesSubset.DEFAULT, pipelineType); yield return(resourcesRequest); if (resourcesRequest.IsError) { yield break; } var initializeAvatar = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", pipeline, resourcesRequest.Result); yield return(Await(initializeAvatar, null)); string avatarCode = initializeAvatar.Result; if (initializeAvatar.IsError) { UpdateAvatarState(avatarCode, GalleryAvatarState.FAILED); yield break; } yield return(UpdateAvatarList()); UpdateAvatarState(avatarCode, GalleryAvatarState.GENERATING); var calculateAvatar = avatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode); yield return(Await(calculateAvatar, avatarCode)); if (calculateAvatar.IsError) { UpdateAvatarState(avatarCode, GalleryAvatarState.FAILED); yield break; } var downloadAvatar = avatarProvider.MoveAvatarModelToLocalStorageAsync(avatarCode, pipeline == PipelineType.FACE, true); yield return(Await(downloadAvatar, avatarCode)); if (downloadAvatar.IsError) { UpdateAvatarState(avatarCode, GalleryAvatarState.FAILED); yield break; } UpdateAvatarState(avatarCode, GalleryAvatarState.COMPLETED); }
private IEnumerator DownloadAvatarFunc(AvatarData avatar, PipelineType pipelineType, AsyncRequest request) { //Update avatar info int retryCount = 3; bool gotAvatar = false; while (!gotAvatar) { if (retryCount == 0) { request.SetError("Unable to download avatar"); yield break; } var updateAvatar = connection.GetAvatarAsync(avatar.code); yield return(Await(updateAvatar, pipelineType)); if (!updateAvatar.IsError) { gotAvatar = true; avatar = updateAvatar.Result; } retryCount--; } // download avatar files retryCount = 3; bool isDownloaded = false; while (!isDownloaded) { if (retryCount == 0) { request.SetError("Unable to download avatar"); yield break; } var downloadAvatar = avatarProvider.DownloadAndSaveAvatarModelAsync(avatar, pipelineType == PipelineType.FACE, true); yield return(Await(downloadAvatar, pipelineType)); isDownloaded = !downloadAvatar.IsError; if (downloadAvatar.IsError) { yield return(new WaitForSeconds(3)); } retryCount--; } request.IsDone = true; }
/// <summary> /// To make Getting Started sample as simple as possible all code required for creating and /// displaying an avatar is placed here in a single function. This function is also a good example of how to /// chain asynchronous requests, just like in traditional sequential code. /// </summary> protected virtual IEnumerator GenerateAndDisplayHead(byte[] photoBytes, PipelineType pipeline) { // Choose default set of resources to generate var resourcesRequest = avatarProvider.ResourceManager.GetResourcesAsync(AvatarResourcesSubset.DEFAULT, pipelineType); yield return(Await(resourcesRequest)); // generate avatar from the photo and get its code in the Result of request var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", pipeline, resourcesRequest.Result); yield return(Await(initializeRequest)); string avatarCode = initializeRequest.Result; StartCoroutine(SampleUtils.DisplayPhotoPreview(avatarCode, photoPreview)); var calculateRequest = avatarProvider.StartAndAwaitAvatarCalculationAsync(avatarCode); yield return(Await(calculateRequest)); // with known avatar code we can get TexturedMesh for head in order to show it further var avatarHeadRequest = avatarProvider.GetHeadMeshAsync(avatarCode, false); yield return(Await(avatarHeadRequest)); TexturedMesh headTexturedMesh = avatarHeadRequest.Result; TexturedMesh haircutTexturedMesh = null; // get identities of all haircuts available for the generated avatar var haircutsIdRequest = avatarProvider.GetHaircutsIdAsync(avatarCode); yield return(Await(haircutsIdRequest)); // randomly select a haircut var haircuts = haircutsIdRequest.Result; if (haircuts != null && haircuts.Length > 0) { var haircutIdx = UnityEngine.Random.Range(0, haircuts.Length); var haircut = haircuts[haircutIdx]; // load TexturedMesh for the chosen haircut var haircutRequest = avatarProvider.GetHaircutMeshAsync(avatarCode, haircut); yield return(Await(haircutRequest)); haircutTexturedMesh = haircutRequest.Result; } DisplayHead(headTexturedMesh, haircutTexturedMesh); }
static void SetPipelineType() { PipelineType type = GetPipelineType(); var targetPlatform = EditorUserBuildSettings.selectedBuildTargetGroup; string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetPlatform); bool isEmpty = false; if (string.IsNullOrEmpty(defines)) { isEmpty = true; } switch (GetPipelineType()) { case PipelineType.BuiltIn: Debug.Log("Screenshotter Set to Built In"); if (!defines.Contains(DEFINE_BUILTIN)) { defines += (isEmpty) ? DEFINE_BUILTIN : ";" + DEFINE_BUILTIN; } break; case PipelineType.HighDefinition: Debug.Log("Screenshotter Set to High Definition"); if (!defines.Contains(DEFINE_HDRP)) { defines += (isEmpty) ? DEFINE_HDRP : ";" + DEFINE_HDRP; } break; case PipelineType.Universal: Debug.Log("Screenshotter Set to Universal"); if (!defines.Contains(DEFINE_URP)) { defines += (isEmpty) ? DEFINE_URP : ";" + DEFINE_URP; } break; case PipelineType.None: Debug.LogError("No Pipeline Type is available! Screenshotter not supported in this version of Unity!"); break; } PlayerSettings.SetScriptingDefineSymbolsForGroup(targetPlatform, defines); EditorApplication.update -= SetPipelineType; }
public static string TranslatedSRPTextureName(string BuiltinName) { if (CurrentPipeline == PipelineType.NotSet) { CurrentPipeline = DetectPipeline(); } if (PipelineTranslations.ContainsKey(CurrentPipeline)) { var textureTranslation = PipelineTranslations[CurrentPipeline]; if (textureTranslation.ContainsKey(BuiltinName)) { return(textureTranslation[BuiltinName]); } } return(BuiltinName); }
/// <summary> /// Request to get available resources for the pipeline /// </summary> public virtual AsyncWebRequest <string> GetResourcesAsync(PipelineType pipelineType, AvatarResourcesSubset resourcesSubset) { string subsetStr = "available"; if (resourcesSubset == AvatarResourcesSubset.DEFAULT) { subsetStr = "default"; } var url = GetUrl("resources", subsetStr, pipelineType.GetPipelineTypeName()); url = UrlWithParams(url, "pipeline_subtype", pipeline_subtype); var request = new AsyncWebRequest <string>(Strings.GettingResourcesList); AvatarSdkMgr.SpawnCoroutine(AwaitStringDataAsync(() => HttpGet(url), request)); return(request); }
// Helpers for adding pipelines from modules private static TBootstrapper AddPipeline <TBootstrapper>( this TBootstrapper bootstrapper, IEnumerable <string> dependencies, PipelineType pipelineType, string name, IEnumerable <IModule> inputModules, IEnumerable <IModule> processModules, IEnumerable <IModule> transformModules, IEnumerable <IModule> outputModules) where TBootstrapper : IBootstrapper => bootstrapper.BuildPipeline(name, builder => { ConfigureBuilder(builder, dependencies, pipelineType) .WithInputModules(inputModules) .WithProcessModules(processModules) .WithPostProcessModules(transformModules) .WithOutputModules(outputModules); });
internal ComponentInstanceManager(Type componentType, PropertyCollection configuration, PipelineType pipelineType) { syncLock = new ReaderWriterLock(); instanceDictionary = new Dictionary <object, PipelineComponent>(); this.componentType = componentType; this.configuration = configuration; this.pipelineType = pipelineType; this.componentConstructor = componentType.GetConstructor(new Type[] { typeof(PropertyCollection) }); if (configuration != null) { configuration.Lock(); } persistenceMode = ((PersistenceAttribute)componentType.GetCustomAttributes(typeof(PersistenceAttribute), true)[0]).PersistenceMode; }
public static Pipeline InitializePipeline(PipelineType typeOfPipeline) { Pipeline return_pipeline = null; switch (typeOfPipeline) { case PipelineType.TEST: TestPipeline test = new TestPipeline(); return_pipeline = test; break; case PipelineType.EMPTY: EmptyPipeline empty = new EmptyPipeline(); return_pipeline = empty; break; } return return_pipeline; }
protected void SetPipelineToggleValue(PipelineType pipeline) { switch (pipeline) { case PipelineType.FACE: if (facePipelineToggle != null) { facePipelineToggle.isOn = true; } break; case PipelineType.HEAD: if (headPipelineToggle != null) { headPipelineToggle.isOn = true; } break; } }
private static TBootstrapper AddPipeline <TBootstrapper>( this TBootstrapper bootstrapper, IEnumerable <string> dependencies, PipelineType pipelineType, string name, string readFilesPattern, Config <NormalizedPath> destinationPath, IEnumerable <IModule> processModules, IEnumerable <IModule> transformModules) where TBootstrapper : IBootstrapper => bootstrapper.BuildPipeline(name, builder => { ConfigureBuilder(builder, dependencies, pipelineType) .WithProcessModules(processModules) .WithPostProcessModules(transformModules) .WithOutputWriteFiles(destinationPath); if (readFilesPattern != null) { builder.WithInputReadFiles(readFilesPattern); } });
protected override IEnumerator GenerateAndDisplayHead(byte[] photoBytes, PipelineType pipeline) { // We don't need blendshapes nor haircuts. So create an empty avatar resources set var initializeRequest = avatarProvider.InitializeAvatarAsync(photoBytes, "name", "description", pipeline, AvatarResources.Empty); yield return(Await(initializeRequest)); currentAvatarCode = initializeRequest.Result; StartCoroutine(SampleUtils.DisplayPhotoPreview(currentAvatarCode, photoPreview)); var calculateRequest = avatarProvider.StartAndAwaitAvatarCalculationAsync(currentAvatarCode); yield return(Await(calculateRequest)); var avatarHeadRequest = avatarProvider.GetHeadMeshAsync(currentAvatarCode, false, currentDetailsLevel); yield return(Await(avatarHeadRequest)); DisplayHead(avatarHeadRequest.Result, null); detailsLevelText.text = string.Format("Triangles count:\n{0}", avatarHeadRequest.Result.mesh.triangles.Length / 3); }
private IEnumerator GetResourcesFunc(AvatarResourcesSubset resourcesSubset, PipelineType pipelineType, AsyncRequest <AvatarResources> request) { if (avatarResourcesCache[pipelineType].ContainsKey(resourcesSubset)) { request.Result = avatarResourcesCache[pipelineType][resourcesSubset]; request.IsDone = true; } else { var resourcesWebRequest = connection.GetResourcesAsync(pipelineType, resourcesSubset); yield return(resourcesWebRequest); if (resourcesWebRequest.IsError) { Debug.LogError(resourcesWebRequest.ErrorMessage); request.SetError(resourcesWebRequest.ErrorMessage); yield break; } AvatarResources avatarResources = GetResourcesFromJson(resourcesWebRequest.Result); avatarResourcesCache[pipelineType].Add(resourcesSubset, avatarResources); request.IsDone = true; request.Result = avatarResources; } }
private void UpdateAvatarState(WebglAvatarState state, PipelineType pipelineType) { Debug.LogFormat("Pipeline: {0}, state: {1}", pipelineType, state); if (pipelineType == PipelineType.FACE) { // Don't display avatar status of animated face pipeline // It is being calculated in background return; } avatarState = state; statusText.text = string.Format("State: {0}", StatePretty(state)); uploadButton.gameObject.SetActive(false); showButton.gameObject.SetActive(false); statusText.gameObject.SetActive(true); progressText.gameObject.SetActive(true); if (state == WebglAvatarState.FAILED) { return; } switch (state) { case WebglAvatarState.FINISHED: showButton.gameObject.SetActive(true); statusText.gameObject.SetActive(false); progressText.gameObject.SetActive(false); break; default: break; } }
public DataPipeName(string machineName, PipelineType pipelineType, string pipelineId, string sectionName) : base(machineName) { PipelineType = pipelineType; PipelineId = pipelineId; SectionName = sectionName; }
public BufferGroup(PipelineType pipeline, CameraType camera, Vector3 location, string binding, uint offset, uint count) : this(pipeline, camera, true, location, binding, offset, count) { }
public BufferGroup(PipelineType pipeline, CameraType camera, Vector3 location, uint offset, uint count) : this(pipeline, camera, location, string.Empty, offset, count) { }
public BufferGroup(PipelineType pipeline, CameraType camera, string binding, uint offset, uint count) : this(pipeline, camera, false, Vector3.Zero, binding, offset, count) { }
public SimpleRenderable(Buffer buffer, PipelineType pipeline, int indexOffset, int indexCount) : this(buffer, new [] { pipeline }, indexOffset, indexCount) { }
public ReportPipeName(string machineName, PipelineType pipelineType, string pipelineId) : base(machineName) { PipelineType = pipelineType; PipelineId = pipelineId; }