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

@@ -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>();
}
}