VeMeshGeometryNode.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #region License information
  2. // ----------------------------------------------------------------------------
  3. //
  4. // libeq2 - A library for analyzing the Everquest II File Format
  5. // Blaz (blaz@blazlabs.com)
  6. //
  7. // This program is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU General Public License
  9. // as published by the Free Software Foundation; either version 2
  10. // of the License, or (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. //
  21. // ( The full text of the license can be found in the License.txt file )
  22. //
  23. // ----------------------------------------------------------------------------
  24. #endregion
  25. #region Using directives
  26. using System;
  27. using System.IO;
  28. using System.Collections.Generic;
  29. using System.Diagnostics;
  30. using Everquest2.Util;
  31. #endregion
  32. namespace Everquest2.Visualization
  33. {
  34. public class VeMeshGeometryNode : VeGeometryNode
  35. {
  36. public VeMeshGeometryNode()
  37. {
  38. }
  39. /// <summary>
  40. /// Special constructor used when deserializing the instance of the class.
  41. /// </summary>
  42. /// <param name="reader">Reader used to read the instance data.</param>
  43. protected VeMeshGeometryNode(Util.Eq2Reader reader, Util.StreamingContext context) : base(reader, context)
  44. {
  45. byte classVersion = context.ClassVersions[typeof(VeMeshGeometryNode)];
  46. if (classVersion == 0 || classVersion > 7)
  47. {
  48. throw new Util.DeserializationException("VeMeshGeometryNode version " + classVersion + " not supported");
  49. }
  50. lodCount = reader.ReadUInt32();
  51. Debug.Assert(lodCount <= 10/*Configuration.GetValue<uint>("cl_max_lods")*/);
  52. extraLodCount = 0;
  53. renderMeshNames = new string[lodCount][];
  54. for (uint i = 0; i < lodCount; ++i)
  55. {
  56. uint renderMeshNameCount;
  57. if (classVersion >= 5)
  58. {
  59. renderMeshNameCount = reader.ReadUInt32();
  60. }
  61. else
  62. {
  63. renderMeshNameCount = 1;
  64. }
  65. renderMeshNames[i] = new string[renderMeshNameCount];
  66. for (uint j = 0; j < renderMeshNameCount; ++j)
  67. {
  68. renderMeshNames[i][j] = reader.ReadString(2);
  69. if (renderMeshNames[i][j].Contains("qey_terrain_harbor_geo11_l0"))
  70. {
  71. int test = 0;
  72. }
  73. }
  74. }
  75. bool shaderPaletteIsInline = false;
  76. if (classVersion >= 6) shaderPaletteIsInline = reader.ReadBoolean();
  77. shaderPaletteNames = new string[lodCount];
  78. shaderPalettes = new VeShaderPalette[lodCount];
  79. for (uint i = 0; i < lodCount; ++i)
  80. {
  81. shaderPaletteNames[i] = reader.ReadString(2);
  82. if (shaderPaletteIsInline)
  83. {
  84. shaderPalettes[i] = (VeShaderPalette)reader.ReadObject();
  85. }
  86. }
  87. collisionMeshName = reader.ReadString(2);
  88. if (classVersion == 2) legacyNavigationMeshName = reader.ReadString(2);
  89. if (classVersion < 4)
  90. {
  91. shadowMeshNames = new string[lodCount];
  92. for (uint i = 0; i < lodCount; ++i)
  93. {
  94. shadowMeshNames[i] = reader.ReadString(2);
  95. }
  96. occluderMeshName = reader.ReadString(2);
  97. }
  98. lodDistances = new float[lodCount];
  99. for (uint i = 0; i < lodCount; ++i)
  100. {
  101. lodDistances[i] = reader.ReadSingle();
  102. }
  103. if (classVersion >= 7)
  104. {
  105. byte unk1 = reader.ReadByte();
  106. }
  107. }
  108. public uint lodCount;
  109. public uint extraLodCount;
  110. public string[][] renderMeshNames;
  111. public string[] shaderPaletteNames;
  112. public VeShaderPalette[] shaderPalettes;
  113. public string collisionMeshName;
  114. public string legacyNavigationMeshName;
  115. public string[] shadowMeshNames;
  116. public string occluderMeshName;
  117. public float[] lodDistances;
  118. }
  119. }