public void AddInstance(R_EnvCell envCell) { var origin = envCell.EnvCell.Pos.GetWorldPos(); var orientation = envCell.EnvCell.Pos.Frame.Orientation.ToXna(); origin.Z += 0.05f; // avoid z-fight for building floors Instances_Env.Add(new VertexInstanceEnv(origin, orientation)); }
public InstanceBatch(R_EnvCell envCell) { Init(); BuildModel(envCell); BuildTextures(); AddInstance(envCell); R_Environment = envCell.Environment; }
public void BuildModel(R_EnvCell envCell) { foreach (var cellStruct in envCell.Environment.R_CellStructs.Values) { var vertices = cellStruct.VertexArray; foreach (var polygon in cellStruct.Polygons) { var surfaceIdx = polygon._polygon.PosSurface; var surfaceID = envCell.EnvCell._envCell.Surfaces[surfaceIdx]; var texture = TextureCache.Get(surfaceID); //Console.WriteLine($"Texture: {surfaceID:X8} Size: {texture.Width}x{texture.Height}"); var textureFormat = new TextureFormat(texture.Format, texture.Width, texture.Height, cellStruct.HasWrappingUVs); if (!DrawCalls.TryGetValue(textureFormat, out var batch)) { batch = new InstanceBatchDraw(textureFormat); DrawCalls.Add(textureFormat, batch); } batch.AddPolygon(vertices, polygon, surfaceID); } } }
public TextureSet(R_EnvCell envCell) { Environment = envCell.EnvCell.EnvironmentID; SurfaceIDs = envCell.EnvCell._envCell.Surfaces; }