/// <summary> /// Initializes a new instance of the <see cref="VertexCompressor"/> class. /// </summary> /// <param name="info">The compression info to use.</param> public VertexCompressor(RenderGeometryCompression info) { _info = info; _xScale = info.X.Upper - info.X.Lower; _yScale = info.Y.Upper - info.Y.Lower; _zScale = info.Z.Upper - info.Z.Lower; _uScale = info.U.Upper - info.U.Lower; _vScale = info.V.Upper - info.V.Lower; }
private RenderGeometryCompression BuildCompressionInfo() { var result = new RenderGeometryCompression(); foreach (var mesh in Meshes) { // TODO: Refactor how vertices work, this is just ugly IEnumerable <RealQuaternion> positions = null; IEnumerable <RealVector2d> texCoords = null; if (mesh.RigidVertices != null) { positions = mesh.RigidVertices.Select(v => v.Position); texCoords = mesh.RigidVertices.Select(v => v.Texcoord); } else if (mesh.SkinnedVertices != null) { positions = mesh.SkinnedVertices.Select(v => v.Position); texCoords = mesh.SkinnedVertices.Select(v => v.Texcoord); } if (positions != null && positions.Count() > 0) { result.X.Lower = Math.Min(result.X.Lower, positions.Min(v => v.I)); result.Y.Lower = Math.Min(result.Y.Lower, positions.Min(v => v.J)); result.Z.Lower = Math.Min(result.Z.Lower, positions.Min(v => v.K)); result.X.Upper = Math.Max(result.X.Upper, positions.Max(v => v.I)); result.Y.Upper = Math.Max(result.Y.Upper, positions.Max(v => v.J)); result.Z.Upper = Math.Max(result.Z.Upper, positions.Max(v => v.K)); } if (texCoords != null && texCoords.Count() > 0) { result.U.Lower = Math.Min(result.U.Lower, texCoords.Min(v => v.I)); result.V.Lower = Math.Min(result.V.Lower, texCoords.Min(v => v.J)); result.U.Upper = Math.Max(result.U.Upper, texCoords.Max(v => v.I)); result.V.Upper = Math.Max(result.V.Upper, texCoords.Max(v => v.J)); } } _model.Geometry.Compression = new List <RenderGeometryCompression> { result }; return(result); }