public RigidModelPart Clone(bool withChildren = false) { var newp = new RigidModelPart() { Name = Name, Path = Path, Mesh = Mesh, Wireframe = Wireframe, Hardpoints = new List <Hardpoint>() }; if (Construct != null) { newp.Construct = Construct.Clone(); } foreach (var hp in Hardpoints) { newp.Hardpoints.Add(new Hardpoint(hp.Definition, newp)); } if (withChildren && Children != null) { newp.Children = new List <RigidModelPart>(); foreach (var c in Children) { newp.Children.Add(c.Clone(true)); } } return(newp); }
int GetLevel(RigidModelPart file, Vector3 center, Vector3 camera) { float[] ranges = LODRanges ?? file.Mesh.Switch2; var dsq = Vector3.DistanceSquared(center, camera); if (ranges == null) { CurrentLevel = 0; return(0); } int lvl = -1; for (int i = 0; i < ranges.Length; i++) { var d = ranges[i]; if (i > 0 && ranges[i] < ranges[i - 1]) { break; } if (dsq < (d * sysr.LODMultiplier) * (d * sysr.LODMultiplier)) { break; } if (i >= file.Mesh.Levels.Length) { CurrentLevel = -1; return(-1); } CurrentLevel = lvl = i; } return(lvl); }
public Hardpoint(HardpointDefinition def, RigidModelPart parent) { Parent = parent; Definition = def; if (Definition == null) { Definition = new FixedHardpointDefinition("dummy"); } Name = def == null ? "Dummy Hardpoint" : def.Name; Revolute = def as RevoluteHardpointDefinition; }
public void ChildDebris(GameObject parent, RigidModelPart part, float mass, Vector3 initialforce) { var cp = new PhysicsComponent(parent) { SurPath = this.SurPath, Mass = mass, PlainCrc = CrcTool.FLModelCrc(part.Name), }; DisablePart(part); parent.PhysicsComponent = cp; cp.Register(pworld); cp.Body.Impulse(initialforce); parent.Components.Add(cp); }
public void DisablePart(RigidModelPart part) { sur.RemovePart(part); partRemoved = true; }