forked from cgvr/DeltaVR
add TrellisClient, use it for model generation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,18 +8,12 @@ public class ModelGenerationBox : MonoBehaviour
|
||||
public Material loadingMaterial;
|
||||
|
||||
public Transform modelSpawnPoint;
|
||||
public VoiceTranscriptionBox voiceTranscriptionTestBox;
|
||||
public ImageGenerationBox imageGenerationBox;
|
||||
|
||||
private MeshRenderer meshRenderer;
|
||||
private bool isLoading;
|
||||
|
||||
private string lastModelPath;
|
||||
public string LastModelPath
|
||||
{
|
||||
get {
|
||||
return lastModelPath;
|
||||
}
|
||||
}
|
||||
public GameObject GeneratedModel { get; private set; }
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -40,18 +35,18 @@ public class ModelGenerationBox : MonoBehaviour
|
||||
XROrigin playerOrigin = other.GetComponent<XROrigin>();
|
||||
if (controller != null || playerOrigin != null)
|
||||
{
|
||||
string inputPrompt = voiceTranscriptionTestBox.LastTextOutput;
|
||||
|
||||
isLoading = true;
|
||||
meshRenderer.material = loadingMaterial;
|
||||
|
||||
string modelPath = await PipelineManager.Instance.GenerateModelAsync(inputPrompt);
|
||||
lastModelPath = modelPath;
|
||||
|
||||
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath);
|
||||
Texture2D inputTexture = imageGenerationBox.LastTexture;
|
||||
string encodedTexture = Convert.ToBase64String(inputTexture.EncodeToJPG());
|
||||
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
|
||||
|
||||
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(encodedModel);
|
||||
spawnedObject.AddComponent<Rigidbody>();
|
||||
spawnedObject.transform.parent = modelSpawnPoint;
|
||||
spawnedObject.transform.position = modelSpawnPoint.position;
|
||||
GeneratedModel = spawnedObject;
|
||||
|
||||
isLoading = false;
|
||||
meshRenderer.material = inactiveMaterial;
|
||||
|
||||
Reference in New Issue
Block a user