-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [SDK-588](https://ready-player-me.atlassian.net/browse/SDK-588) ## Description - Updated render api - Updated samples and tests
- Loading branch information
1 parent
8f02c60
commit f47abc5
Showing
17 changed files
with
1,384 additions
and
1,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,79 @@ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using UnityEngine; | ||
|
||
namespace ReadyPlayerMe.Core | ||
{ | ||
[System.Serializable] | ||
public struct BlendShape | ||
{ | ||
public string Name; | ||
public float Value; | ||
public BlendShape(string name, float value) | ||
{ | ||
Name = name; | ||
Value = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// This structure holds all the data required a request to the Avatar Render API. | ||
/// </summary> | ||
public struct AvatarRenderSettings | ||
[System.Serializable] | ||
public class AvatarRenderSettings | ||
{ | ||
public string Model; | ||
public AvatarRenderScene Scene; | ||
public string[] BlendShapeMeshes; | ||
public Dictionary<string, float> BlendShapes; | ||
public Expression Expression = Expression.None; | ||
public RenderPose Pose = RenderPose.Relaxed; | ||
public RenderCamera Camera = RenderCamera.Portrait; | ||
public int Quality = 100; | ||
public int Size = 800; | ||
public Color Background = Color.white; | ||
public bool IsTransparent; | ||
public List<BlendShape> BlendShapes; | ||
|
||
public string GetParametersAsString() | ||
{ | ||
BlendShapes ??= new Dictionary<string, float>(); | ||
var queryBuilder = new QueryBuilder(); | ||
queryBuilder.AddKeyValue(AvatarAPIParameters.RENDER_SCENE, Scene.GetSceneNameAsString()); | ||
foreach (KeyValuePair<string, float> blendShape in BlendShapes) | ||
if (Expression != Expression.None) | ||
{ | ||
foreach (var blendShapeMesh in BlendShapeMeshes) | ||
queryBuilder.AddKeyValue(nameof(Core.Expression).ToCamelCase(), Expression.ToString().ToCamelCase()); | ||
} | ||
|
||
queryBuilder.AddKeyValue(nameof(Pose).ToCamelCase(), RenderSettingsHelper.RenderPoseMap[Pose]); | ||
|
||
if (BlendShapes != null) | ||
{ | ||
foreach (var blendShape in BlendShapes) | ||
{ | ||
string key = $"{AvatarAPIParameters.RENDER_BLEND_SHAPES}[{blendShapeMesh}][{blendShape.Key}]"; | ||
string value = blendShape.Value.ToString(CultureInfo.InvariantCulture); | ||
var key = $"{AvatarAPIParameters.RENDER_BLEND_SHAPES}[{blendShape.Name}]"; | ||
var value = blendShape.Value.ToString(CultureInfo.InvariantCulture); | ||
queryBuilder.AddKeyValue(key, value); | ||
} | ||
} | ||
|
||
|
||
queryBuilder.AddKeyValue(nameof(Camera).ToCamelCase(), Camera.ToString().ToLower()); | ||
|
||
// TODO Quality is only supported by jpg. Find better approach for this. | ||
// if (Quality == 0) | ||
// { | ||
// Quality = 100; | ||
// } | ||
// queryBuilder.AddKeyValue(nameof(Quality).ToCamelCase(), Quality.ToString()); | ||
|
||
if (Size == 0) | ||
{ | ||
Size = 800; | ||
} | ||
|
||
queryBuilder.AddKeyValue(nameof(Size).ToCamelCase(), Size.ToString()); | ||
|
||
if (!IsTransparent) | ||
{ | ||
queryBuilder.AddKeyValue(nameof(Background).ToCamelCase(), RenderSettingsHelper.FloatToRGBString(Background)); | ||
} | ||
|
||
return queryBuilder.Query; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace ReadyPlayerMe.Core | ||
{ | ||
public static class RenderSettingsHelper | ||
{ | ||
public static string ToCamelCase(this string str) | ||
{ | ||
if (string.IsNullOrEmpty(str)) | ||
return string.Empty; | ||
|
||
var letters = str.ToCharArray(); | ||
letters[0] = char.ToLower(letters[0]); | ||
return new string(letters); | ||
} | ||
|
||
public static Dictionary<RenderPose, string> RenderPoseMap = new Dictionary<RenderPose, string>() | ||
{ | ||
{ RenderPose.PowerStance, "power-stance" }, | ||
{ RenderPose.Relaxed, "relaxed" }, | ||
{ RenderPose.Standing, "standing" }, | ||
{ RenderPose.ThumbsUp, "thumbs-up" } | ||
}; | ||
|
||
public static string FloatToRGBString(Color color) | ||
{ | ||
return $"{(int) (color.r * 255)},{(int) (color.g * 255)},{(int) (color.b * 255)}"; | ||
} | ||
} | ||
} |
File renamed without changes.
76 changes: 0 additions & 76 deletions
76
Samples~/AvatarRenderSamples/MultipleRenders/MultipleAvatarRenderExample.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
Samples~/AvatarRenderSamples/MultipleRenders/MultipleAvatarRenderExample.cs.meta
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.