public static StaticGeometryComponent CreateStaticGeometry(Entity parent, TransformComponent xform, ICollisionInfo[] collisionInfos, ShaderInfo[] shaders) { return(new StaticGeometryComponent(parent, xform) { Collider = TriangleMeshCollider.Create(collisionInfos, MatLookup(shaders)) }); }
public static StaticTerrainComponent CreateTerrain(Entity parent, ICollisionInfo[] collisionInfos, ShaderInfo[] shaders) { return(new StaticTerrainComponent(parent) { Collider = TriangleMeshCollider.Create(collisionInfos, MatLookup(shaders)) }); }
public static ICollider GetTriangleColliderForHlmt(H2vMap map, HaloModelTag hlmt, int damageLevel = 0) { if (hlmt.ColliderId.IsInvalid) { return(DefaultCollider); } if (map.TryGetTag(hlmt.ColliderId, out var coll) == false) { Console.WriteLine($"Couldn't find COLL[{hlmt.ColliderId.Id}]"); return(DefaultCollider); } if (coll.ColliderComponents.Length == 0 || coll.ColliderComponents[0].DamageLevels.Length <= damageLevel || coll.ColliderComponents[0].DamageLevels[damageLevel].Parts.Length == 0) { Console.WriteLine($"No colliders defined in coll[{hlmt.ColliderId}] for damage level {damageLevel}"); return(DefaultCollider); } var colliderMeshes = new List <TriangleMeshCollider>(); foreach (var component in coll.ColliderComponents) { var container = component.DamageLevels[damageLevel]; // TODO material lookup colliderMeshes.Add(TriangleMeshCollider.Create(container.Parts, i => - 1)); } // TODO: relative transforms? var collider = new TriangleModelCollider() { MeshColliders = colliderMeshes.ToArray() }; return(collider); }