forked from cgvr/DeltaVR
Cube that starts generation pipeline on collision
This commit is contained in:
8
Assets/_PROJECT/Scripts/3DModeGeneration.meta
Normal file
8
Assets/_PROJECT/Scripts/3DModeGeneration.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ec3982ba49c4b84ea95332cb090e115
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
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!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46e67223dce9b7a4783ed36b8ed65f19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user