1
0
forked from cgvr/DeltaVR

shape checker nice materials, generated object grabbable

This commit is contained in:
2026-01-13 17:17:59 +02:00
parent 3097c404ba
commit 1cd97e4d0a
14 changed files with 773 additions and 29 deletions

View File

@@ -8,7 +8,6 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
public PushableButton imageGenerationButton;
public PushableButton modelGenerationButton;
public string imageGenerationPromptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
public Texture2D GeneratedTexture { get; private set; }
public Image imageDisplay;
@@ -42,10 +41,7 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
private async void InvokeImageGeneration()
{
string inputPrompt = microphoneStand.GetTextOutput();
string refinedPrompt = inputPrompt + imageGenerationPromptSuffix;
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(refinedPrompt);
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
GeneratedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
imageDisplay.sprite = sprite;

View File

@@ -11,7 +11,6 @@ public class ImageGenerationBox : MonoBehaviour
public VoiceTranscriptionBox voiceTranscriptionBox;
public Image imageDisplay;
public Texture2D LastTexture { get; private set; }
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
private MeshRenderer meshRenderer;
private bool isLoading;
@@ -37,13 +36,11 @@ void Start()
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
{
string inputPrompt = voiceTranscriptionBox.GetTextOutput();
string refinedPrompt = inputPrompt + promptSuffix;
isLoading = true;
meshRenderer.material = loadingMaterial;
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(refinedPrompt);
string inputPrompt = voiceTranscriptionBox.GetTextOutput();
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
LastTexture = ModelGenerationUtils.CreateTexture(imageBytes);
Sprite sprite = ModelGenerationUtils.CreateSprite(LastTexture);
imageDisplay.sprite = sprite;

View File

@@ -17,6 +17,7 @@ public class InvokeAiClient : MonoBehaviour
public string INVOKEAI_BASE_URL;
public string DEFAULT_QUEUE_ID = "default";
public string MODEL_KEY;
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
private HttpClient httpClient;
@@ -519,9 +520,10 @@ public class InvokeAiClient : MonoBehaviour
public async Task<byte[]> GenerateImage(string prompt)
{
string refinedPrompt = prompt + promptSuffix;
JObject args = new JObject()
{
["prompt"] = prompt,
["prompt"] = refinedPrompt,
["width"] = 512,
["height"] = 512,
["model_key"] = MODEL_KEY,

View File

@@ -3,14 +3,13 @@ using FishNet.Object;
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit;
public class ShapeDetectionMinigameController : MonoBehaviour
{
public MicrophoneStand microphoneStand;
public PushableButton imageGenerationButton;
public PushableButton modelGenerationButton;
public string imageGenerationPromptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
public Texture2D GeneratedTexture { get; private set; }
public Image imageDisplay;
@@ -37,9 +36,7 @@ public class ShapeDetectionMinigameController : MonoBehaviour
private async void InvokeImageGeneration()
{
string inputPrompt = microphoneStand.GetTextOutput();
string refinedPrompt = inputPrompt + imageGenerationPromptSuffix;
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(refinedPrompt);
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
GeneratedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
imageDisplay.sprite = sprite;
@@ -71,12 +68,16 @@ public class ShapeDetectionMinigameController : MonoBehaviour
private void InitializeSpawnedObject(GameObject spawnedObject)
{
Rigidbody rigidbody = spawnedObject.AddComponent<Rigidbody>();
rigidbody.useGravity = false;
rigidbody.isKinematic = true;
spawnedObject.AddComponent<NetworkObject>();
spawnedObject.AddComponent<NetworkTransform>();
//spawnedObject.AddComponent<NetworkObject>();
//spawnedObject.AddComponent<NetworkTransform>();
spawnedObject.transform.parent = modelSpawnPoint;
spawnedObject.transform.position = modelSpawnPoint.position;
spawnedObject.tag = shapeScannerTag;
spawnedObject.SetActive(true);
spawnedObject.AddComponent<XRGrabInteractable>();
}
}