internal LodFactory(PartFactory part, NodeCollection lodNode, int index, float threshold) { Part = part; _lodNode = lodNode; _index = index; if (threshold > 0 && threshold < float.PositiveInfinity) { // OPT LOD thresholds are based on distance. Unity is based on screen height. _threshold = (float)(1 / (DetailImprovementFudgeFactor * Math.Atan(1 / threshold))); } else { _threshold = 0; } }
private void CraftFactoryImpl() { // Determine total size of the craft. Used for LOD size. bool foundDescriptor = false; Vector3 upperBound = new Vector3(); // upper bound Vector3 lowerBound = new Vector3(); // lower bound foreach (var descriptor in Opt.OfType <PartDescriptor <Vector3> >()) { var huc = descriptor.HitboxUpperCorner; var hlc = descriptor.HitboxLowerCorner; // In case origin is outside of all hitbox demensions, // set the bounds based on first hitbox found and expand from there. if (foundDescriptor) { upperBound = Vector3.Max(upperBound, huc); lowerBound = Vector3.Min(lowerBound, hlc); } else { upperBound = new Vector3(huc.x, huc.y, huc.z); lowerBound = new Vector3(hlc.x, hlc.y, hlc.z); foundDescriptor = true; } } if (foundDescriptor) { Size = (upperBound - lowerBound).magnitude; } else { // TODO: Vertex based size calculation Size = float.PositiveInfinity; } foreach (NodeCollection shipPart in Opt.RootNodes.OfType <NodeCollection>()) { var factory = new PartFactory(this, shipPart); if (null == factory.descriptor || null == TargetingGroupBase) { nonTargetGroupedParts.Add(factory); factory.CreateChildTarget = true; } else { var groupTuple = new DistinctTargetGroupTuple(factory.descriptor); if (targetGroups.TryGetValue(groupTuple, out TargetGroupFactory group)) { group.Add(factory); } else { group = new TargetGroupFactory(groupTuple, this); group.Add(factory); targetGroups.Add(groupTuple, group); } } } textures = Opt.OfType <XWOpt.OptNode.Texture>().ToList(); TextureAtlas = new TextureAtlas(textures, PartShader, "OPT Craft Atlas", Opt.Version, makeEmissiveTexture ? emissiveExponent : (float?)null); }
internal void Add(PartFactory part) { parts.Add(part); }