Initial commit

This commit is contained in:
2026-03-17 13:40:09 +02:00
commit 91fb7fdad5
1055 changed files with 388166 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectAirProperties : MonoBehaviour
{
[Header("Âëàñòèâîñò³")]
public float crossSectionArea = 0.05f;
public float dragCoefficient = 0.47f;
void Start()
{
AnalyzeObject();
}
void AnalyzeObject()
{
Renderer renderer = GetComponent<Renderer>();
if (renderer == null) return;
Bounds bounds = renderer.bounds;
Vector3 size = bounds.size;
float[] dimensions = new float[] { size.x, size.y, size.z };
System.Array.Sort(dimensions);
System.Array.Reverse(dimensions);
float largest = dimensions[0];
float middle = dimensions[1];
float smallest = dimensions[2];
float ratio1 = middle / largest;
float ratio2 = smallest / largest;
if (ratio1 > 0.8f && ratio2 > 0.8f)
{
DetectSphereOrCube(bounds);
}
else if (ratio2 < 0.3f)
{
crossSectionArea = largest * middle;
dragCoefficient = 1.28f;
}
else if (ratio1 > 0.7f && ratio2 < 0.7f)
{
float radius = Mathf.Max(largest, middle) * 0.5f;
crossSectionArea = Mathf.PI * radius * radius;
dragCoefficient = 0.82f;
}
else
{
crossSectionArea = Mathf.Max(
size.x * size.y,
size.x * size.z,
size.y * size.z
);
dragCoefficient = 1.05f;
}
}
void DetectSphereOrCube(Bounds bounds)
{
MeshFilter meshFilter = GetComponent<MeshFilter>();
if (meshFilter != null && meshFilter.sharedMesh != null)
{
int vertexCount = meshFilter.sharedMesh.vertexCount;
if (vertexCount > 100)
{
float radius = Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z) * 0.5f;
crossSectionArea = Mathf.PI * radius * radius;
dragCoefficient = 0.47f;
}
else
{
crossSectionArea = Mathf.Max(
bounds.size.x * bounds.size.y,
bounds.size.x * bounds.size.z,
bounds.size.y * bounds.size.z
);
dragCoefficient = 1.05f;
}
}
else
{
crossSectionArea = Mathf.Max(
bounds.size.x * bounds.size.y,
bounds.size.x * bounds.size.z,
bounds.size.y * bounds.size.z
);
dragCoefficient = 1.05f;
}
}
}