forked from cgvr/DeltaVR
87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
|
|
public class ModelGenerationPipelineStarter : MonoBehaviour
|
|
{
|
|
public Material activeMaterial;
|
|
public Material inactiveMaterial;
|
|
|
|
private MeshRenderer meshRenderer;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
meshRenderer = GetComponent<MeshRenderer>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
KbmController controller = other.GetComponent<KbmController>();
|
|
if (controller != null)
|
|
{
|
|
meshRenderer.material = activeMaterial;
|
|
|
|
StartModeGenerationPipeline();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
KbmController controller = other.GetComponent<KbmController>();
|
|
if (controller != null)
|
|
{
|
|
meshRenderer.material = inactiveMaterial;
|
|
}
|
|
}
|
|
|
|
private async void StartModeGenerationPipeline()
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
string inputPrompt = "Uhm I want I think an epic broadsword with a fancy golden pommel";
|
|
|
|
// Path to your virtual environment's python.exe
|
|
string pythonExe = @"D:\users\henrisel\DeltaVR3DModelGeneration\3d-generation-pipeline\.venv\Scripts\python.exe";
|
|
|
|
// Path to your Python script
|
|
string scriptPath = @"D:\users\henrisel\DeltaVR3DModelGeneration\3d-generation-pipeline\start_pipeline.py";
|
|
|
|
// Arguments to pass to the script
|
|
string arguments = $"{scriptPath} --prompt \"{inputPrompt}\"";
|
|
|
|
ProcessStartInfo psi = new ProcessStartInfo
|
|
{
|
|
FileName = pythonExe,
|
|
Arguments = arguments,
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
CreateNoWindow = true
|
|
};
|
|
|
|
using (Process process = new Process())
|
|
{
|
|
process.StartInfo = psi;
|
|
process.OutputDataReceived += (sender, e) => UnityEngine.Debug.Log(e.Data);
|
|
process.ErrorDataReceived += (sender, e) => UnityEngine.Debug.LogError(e.Data);
|
|
|
|
process.Start();
|
|
process.BeginOutputReadLine();
|
|
process.BeginErrorReadLine();
|
|
process.WaitForExit();
|
|
}
|
|
});
|
|
|
|
UnityEngine.Debug.Log("Python script finished!");
|
|
}
|
|
}
|