using System; using System.Collections.Generic; using FlaxEngine; namespace Game { [ExecuteInEditMode] public class QBrush : Script { Model model; public MaterialBase material; public override void OnAwake() { model = Content.CreateVirtualAsset(); model.SetupLODs(new int[] { 1 }); { var mesh = model.LODs[0].Meshes[0]; const float X = 0.525731112119133606f * 100f; const float Z = 0.850650808352039932f * 100f; const float N = 0.0f; var vertices = new[] { new Vector3(-X, N, Z), new Vector3(X, N, Z), new Vector3(-X, N, -Z), new Vector3(X, N, -Z), new Vector3(N, Z, X), new Vector3(N, Z, -X), new Vector3(N, -Z, X), new Vector3(N, -Z, -X), new Vector3(Z, X, N), new Vector3(-Z, X, N), new Vector3(Z, -X, N), new Vector3(-Z, -X, N) }; var triangles = new[] { 1, 4, 0, 4, 9, 0, 4, 5, 9, 8, 5, 4, 1, 8, 4, 1, 10, 8, 10, 3, 8, 8, 3, 5, 3, 2, 5, 3, 7, 2, 3, 10, 7, 10, 6, 7, 6, 11, 7, 6, 0, 11, 6, 1, 0, 10, 1, 6, 11, 0, 9, 2, 11, 9, 5, 2, 9, 11, 2, 7 }; mesh.UpdateMesh(vertices, triangles, vertices); } StaticModel childModel = Actor.GetOrAddChild(); childModel.Model = model; childModel.SetMaterial(0, material); } public override void OnDestroy() { Destroy(ref model); } } }