private IEnumerator MainProcessCoroutine(float waitTime) { float anglePace = 180 / (m_anglesCount - 1); float volumePace = m_fullVolume / (m_volumesCount - 1); float minH = 9999, maxH = -9999; m_angles = new float[m_anglesCount]; m_volumes = new float[m_volumesCount]; m_datas = new float[m_anglesCount][]; for (int i = 0; i < m_anglesCount; i++) { m_datas[i] = new float[m_volumesCount]; m_angles[i] = anglePace * i; } for (int i = 0; i < m_volumesCount; i++) { m_volumes[i] = volumePace * i; } // 1) Pour chaque orientation for (int angleStep = 0; angleStep < m_anglesCount; angleStep++) { float minHeight, maxHeight; // Get MinH et MaxH GetMinMaxHighnessOfMesh(out minHeight, out maxHeight); // 2) Pour chaque hauteur (entre MinH et MaxH) for (int volumeStep = 0; volumeStep < m_volumesCount; volumeStep++) { float volumeToFind = volumeStep * volumePace; // Trouver meilleure hauteur float height = HeightFromVolumeDichotomy(volumeToFind, m_heightAccuracy, minHeight, maxHeight); minH = Mathf.Min(height, minH); maxH = Mathf.Max(height, maxH); m_datas[angleStep][volumeStep] = height; yield return(new WaitForSeconds(waitTime)); // Supprimer les parties } transform.Rotate(Vector3.right, anglePace); } // Interpolation InterpoLagrange2D interpoLagrange2D = new InterpoLagrange2D(m_angles, m_volumes, m_datas, m_clearThreshold); float conf = interpoLagrange2D.Confidence(); Debug.Log(m_meshID.ToString() + " : Confiance à : " + (conf * 100).ToString().Substring(0, 2) + "%"); float relativeVolume = m_fullVolume / (transform.lossyScale.x * transform.lossyScale.y * transform.lossyScale.z); XmlMeshFormula.SaveFormula(new MeshVolumeFormula(interpoLagrange2D.polynome2D, m_meshID, relativeVolume), m_forceUpdate); }
// Precal #region Precalculated Volume-Rotation-Height Datas protected void LoadMeshFormula() { MeshVolumeFormula xmlMeshFormula = XmlMeshFormula.FormulaForMesh(m_meshID); if (xmlMeshFormula == null) { this.enabled = false; return; } m_heightFormula = xmlMeshFormula.formula; m_scaleFactor = transform.lossyScale.x * transform.lossyScale.y * transform.lossyScale.z; m_fullVolume = xmlMeshFormula.relativeVolume * m_scaleFactor; m_currentVolume = m_fullVolume * m_volumePercentage; }