|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
public class FluidSimInputController : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
|
FluidSim3DProject.SmokeFluidSim fluidSimulation;
|
|
|
|
|
|
public SmokeFluidSimUniforms uniforms;
|
|
|
|
|
|
|
|
|
|
|
|
List<Transform> children = new List<Transform>();
|
|
|
|
|
|
int child_index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
children.Clear();
|
|
|
|
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = transform.GetChild(i);
|
|
|
|
|
|
if (child.gameObject.activeSelf)
|
|
|
|
|
|
children.Add(child);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 size = fluidSimulation.GridSize;
|
|
|
|
|
|
Vector3 root = fluidSimulation.GridRoot;
|
|
|
|
|
|
Vector3 inv_size = new Vector3(1.0f / size.x, 1.0f / size.y, 1.0f / size.z);
|
|
|
|
|
|
|
|
|
|
|
|
if (children.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
child_index %= children.Count;
|
|
|
|
|
|
|
|
|
|
|
|
var trans = children[child_index];
|
|
|
|
|
|
Vector3 pos = Vector3.Scale(trans.position - root, inv_size);
|
|
|
|
|
|
pos.x = Mathf.Clamp01(pos.x);
|
|
|
|
|
|
pos.y = Mathf.Clamp01(pos.y);
|
|
|
|
|
|
pos.z = Mathf.Clamp01(pos.z);
|
|
|
|
|
|
|
|
|
|
|
|
fluidSimulation.m_inputPos = pos;
|
|
|
|
|
|
fluidSimulation.m_inputRadius = trans.lossyScale.x / size.x;
|
|
|
|
|
|
|
|
|
|
|
|
child_index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
fluidSimulation.m_inputPos = Vector4.zero;
|
|
|
|
|
|
fluidSimulation.m_inputRadius = 0.0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
fluidSimulation.m_vorticityStrength = uniforms.m_vorticityStrength;
|
|
|
|
|
|
fluidSimulation.m_densityAmount = uniforms.m_densityAmount;
|
|
|
|
|
|
fluidSimulation.m_densityDissipation = uniforms.m_densityDissipation;
|
|
|
|
|
|
fluidSimulation.m_densityBuoyancy = uniforms.m_densityBuoyancy;
|
|
|
|
|
|
fluidSimulation.m_densityWeight = uniforms.m_densityWeight;
|
|
|
|
|
|
fluidSimulation.m_temperatureAmount = uniforms.m_temperatureAmount;
|
|
|
|
|
|
fluidSimulation.m_temperatureDissipation = uniforms.m_temperatureDissipation;
|
|
|
|
|
|
fluidSimulation.m_velocityDissipation = uniforms.m_velocityDissipation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|