forked from cgvr/DeltaVR
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using FMOD.Studio;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ModelDisplay : MonoBehaviour
|
|
{
|
|
public Transform displayPoint;
|
|
public Transform glassTransform;
|
|
public Material modelDisplayActiveMaterial;
|
|
public MeshRenderer[] wires;
|
|
public Material wireActiveMaterial;
|
|
|
|
public GameObject Model { get; private set; }
|
|
public float generatedObjectRotationSpeed = 10f;
|
|
|
|
private EventInstance printingSound;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
printingSound = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Printing);
|
|
printingSound.setParameterByName("3DPrinterPrintingJob", 1);
|
|
printingSound.setParameterByName("Occlusion", 0);
|
|
printingSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(displayPoint));
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Model != null)
|
|
{
|
|
Model.transform.Rotate(Vector3.up, generatedObjectRotationSpeed * Time.deltaTime);
|
|
}
|
|
}
|
|
|
|
public void StartPrinting()
|
|
{
|
|
printingSound.start();
|
|
printingSound.setParameterByName("3DPrinterPrintingJob", 0);
|
|
}
|
|
|
|
public void DisplayModel(GameObject modelObject)
|
|
{
|
|
foreach (MeshRenderer meshRenderer in wires)
|
|
{
|
|
meshRenderer.material = wireActiveMaterial;
|
|
}
|
|
|
|
glassTransform.GetComponent<MeshRenderer>().material = modelDisplayActiveMaterial;
|
|
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.ShapeScannerSuccess, gameObject);
|
|
|
|
// Destroy previous generated object
|
|
Destroy(Model);
|
|
modelObject.transform.parent = displayPoint;
|
|
modelObject.transform.position = displayPoint.position;
|
|
Model = modelObject;
|
|
|
|
printingSound.setParameterByName("3DPrinterPrintingJob", 1);
|
|
}
|
|
}
|