public WmoGroup(string fileName, WmoRoot root) { Batches = new List <WmoBatch>(); Indices = new List <ushort>(); Vertices = new WmoVertex[0]; DisableRendering = false; mFileName = fileName; mParent = new WeakReference <WmoRoot>(root); }
private bool CombineVertexData() { WmoRoot parent; if (!mParent.TryGetTarget(out parent)) { Log.Fatal("FATAL ERROR! Parent of WMO group is null!!"); return(false); } mVertices = new WmoVertex[mPositions.Length]; if (mColors == null) { mColors = new uint[mPositions.Length]; for (var i = 0; i < mPositions.Length; ++i) { mColors[i] = IsIndoor ? 0xFF7F7F7Fu : 0x00000000u; } } if (mColors.Length < mVertices.Length) { var colors = mColors; mColors = new uint[mVertices.Length]; if (colors.Length > 0) { Buffer.BlockCopy(colors, 0, mColors, 0, colors.Length * 4); } for (var i = colors.Length; i < mColors.Length; ++i) { mColors[i] = IsIndoor ? 0xFF7F7F7Fu : 0x00000000u; } } var parentAmbient = parent.AmbientColor; var ar = parentAmbient & 0xFF; var ag = (parentAmbient >> 8) & 0xFF; var ab = (parentAmbient >> 16) & 0xFF; var aa = (parentAmbient >> 24) & 0xFF; var minPos = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); var maxPos = new Vector3(float.MinValue, float.MinValue, float.MinValue); for (var i = 0; i < mVertices.Length; ++i) { var clr = mColors[i]; if (parent.UseParentAmbient && IsIndoor) { var r = Math.Min((clr & 0xFF) + ar, 255); var g = Math.Min(((clr >> 8) & 0xFF) + ag, 255); var b = Math.Min(((clr >> 16) & 0xFF) + ab, 255); var a = Math.Min(((clr >> 24) & 0xFF) + aa, 255); clr = r | (g << 8) | (b << 16) | (a << 24); } var v = mPositions[i]; mVertices[i] = new WmoVertex { Position = v, Normal = mNormals[i], TexCoord = mTexCoords[i], Color = clr }; if (v.X < minPos.X) { minPos.X = v.X; } if (v.Y < minPos.Y) { minPos.Y = v.Y; } if (v.Z < minPos.Z) { minPos.Z = v.Z; } if (v.X > maxPos.X) { maxPos.X = v.X; } if (v.Y > maxPos.Y) { maxPos.Y = v.Y; } if (v.Z > maxPos.Z) { maxPos.Z = v.Z; } } BoundingBox = new BoundingBox(minPos, maxPos); Vertices = mVertices.ToList().AsReadOnly(); return(true); }
private bool CombineVertexData() { WmoRoot parent; if (!mParent.TryGetTarget(out parent)) { Log.Fatal("FATAL ERROR! Parent of WMO group is null!!"); return false; } mVertices = new WmoVertex[mPositions.Length]; if (mColors == null) { mColors = new uint[mPositions.Length]; for (var i = 0; i < mPositions.Length; ++i) mColors[i] = IsIndoor ? 0xFF7F7F7Fu : 0x00000000u; } if (mColors.Length < mVertices.Length) { var colors = mColors; mColors = new uint[mVertices.Length]; if (colors.Length > 0) Buffer.BlockCopy(colors, 0, mColors, 0, colors.Length * 4); for (var i = colors.Length; i < mColors.Length; ++i) mColors[i] = IsIndoor ? 0xFF7F7F7Fu : 0x00000000u; } var parentAmbient = parent.AmbientColor; var ar = parentAmbient & 0xFF; var ag = (parentAmbient >> 8) & 0xFF; var ab = (parentAmbient >> 16) & 0xFF; var aa = (parentAmbient >> 24) & 0xFF; var minPos = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); var maxPos = new Vector3(float.MinValue, float.MinValue, float.MinValue); for (var i = 0; i < mVertices.Length; ++i) { var clr = mColors[i]; if (parent.UseParentAmbient && IsIndoor) { var r = Math.Min((clr & 0xFF) + ar, 255); var g = Math.Min(((clr >> 8) & 0xFF) + ag, 255); var b = Math.Min(((clr >> 16) & 0xFF) + ab, 255); var a = Math.Min(((clr >> 24) % 0xFF) + aa, 255); clr = r | (g << 8) | (b << 16) | (a << 24); } var v = mPositions[i]; mVertices[i] = new WmoVertex { Position = v, Normal = mNormals[i], TexCoord = mTexCoords[i], Color = clr }; if (v.X < minPos.X) minPos.X = v.X; if (v.Y < minPos.Y) minPos.Y = v.Y; if (v.Z < minPos.Z) minPos.Z = v.Z; if (v.X > maxPos.X) maxPos.X = v.X; if (v.Y > maxPos.Y) maxPos.Y = v.Y; if (v.Z > maxPos.Z) maxPos.Z = v.Z; } BoundingBox = new BoundingBox(minPos, maxPos); Vertices = mVertices.ToList().AsReadOnly(); return true; }