VeLightNode.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.Collections.Generic;
  28. using System.Diagnostics;
  29. #endregion
  30. namespace Everquest2.Visualization
  31. {
  32. public class VeLightNode : VeNode
  33. {
  34. public enum FalloffType : uint
  35. {
  36. Linear = 0,
  37. Constant = 1,
  38. ExpQuarter = 2,
  39. ExpHalf = 3,
  40. Exp2 = 4,
  41. Bilinear = 5
  42. }
  43. public enum LightType : uint
  44. {
  45. Direction = 0,
  46. Point = 1,
  47. ConeSpot = 2,
  48. BoxSpot = 3
  49. }
  50. public VeLightNode()
  51. {
  52. }
  53. /// <summary>
  54. /// Special constructor used when deserializing the instance of the class.
  55. /// </summary>
  56. /// <param name="reader">Reader used to read the instance data.</param>
  57. protected VeLightNode(Util.Eq2Reader reader, Util.StreamingContext context) : base(reader, context)
  58. {
  59. byte classVersion = context.ClassVersions[typeof(VeLightNode)];
  60. #region Preconditions
  61. Debug.Assert(classVersion <= 13, "Unsupported VeLightNode class version " + classVersion + " (maximum 13)");
  62. #endregion
  63. direction[0] = reader.ReadSingle();
  64. direction[1] = reader.ReadSingle();
  65. direction[2] = reader.ReadSingle();
  66. position[0] = reader.ReadSingle();
  67. position[1] = reader.ReadSingle();
  68. position[2] = reader.ReadSingle();
  69. if (classVersion > 6)
  70. {
  71. for (uint i = 0; i < 16; ++i) transformMatrix[i] = reader.ReadSingle();
  72. spotX = reader.ReadSingle();
  73. spotY = reader.ReadSingle();
  74. }
  75. if (classVersion > 7)
  76. {
  77. // Image: don't see this in qey_harbor_qey_terrain_harbor_geo11_2.voc
  78. // spotTextureFileName = reader.ReadString(2);
  79. }
  80. rgba[0] = reader.ReadSingle();
  81. rgba[1] = reader.ReadSingle();
  82. rgba[2] = reader.ReadSingle();
  83. radius = reader.ReadSingle();
  84. lightType = (LightType)reader.ReadUInt32();
  85. falloffType = (FalloffType)reader.ReadUInt32();
  86. unk10 = reader.ReadSingle();
  87. update = reader.ReadBoolean();
  88. if (classVersion > 0) unk12 = reader.ReadUInt32();
  89. if (classVersion > 3) sunShadow = reader.ReadBoolean();
  90. if (classVersion > 8) negative = reader.ReadBoolean();
  91. if (classVersion > 9) fogRadius = reader.ReadSingle();
  92. if (classVersion > 10) fog = reader.ReadBoolean();
  93. if (classVersion > 12) orientSunShadow = reader.ReadByte();
  94. if ((orientSunShadow & 2) == 2) reader.ReadUInt32();
  95. if (classVersion > 2)
  96. {
  97. minColor[0] = reader.ReadSingle();
  98. minColor[1] = reader.ReadSingle();
  99. minColor[2] = reader.ReadSingle();
  100. maxColor[0] = reader.ReadSingle();
  101. maxColor[1] = reader.ReadSingle();
  102. maxColor[2] = reader.ReadSingle();
  103. minRadius = reader.ReadSingle();
  104. maxRadius = reader.ReadSingle();
  105. colorRate = reader.ReadSingle();
  106. }
  107. if (classVersion > 4)
  108. {
  109. minLightPriority = reader.ReadUInt32();
  110. maxLightPriority = reader.ReadUInt32();
  111. minShadowPriority = reader.ReadUInt32();
  112. maxShadowPriority = reader.ReadUInt32();
  113. }
  114. if (classVersion > 5)
  115. {
  116. offTimeHour = reader.ReadByte();
  117. offTimeMinute = reader.ReadByte();
  118. onTimeHour = reader.ReadByte();
  119. onTimeMinute = reader.ReadByte();
  120. }
  121. }
  122. public float[] direction = new float[3];
  123. public float[] position = new float[3];
  124. public float[] transformMatrix = new float[16];
  125. public float spotX;
  126. public float spotY;
  127. public string spotTextureFileName;
  128. public float[] rgba = new float[3];
  129. public float radius;
  130. public LightType lightType;
  131. public FalloffType falloffType;
  132. public float unk10;
  133. public bool update;
  134. public uint unk12;
  135. public bool sunShadow;
  136. public bool negative;
  137. public float fogRadius;
  138. public bool fog;
  139. public byte orientSunShadow;
  140. public float[] minColor = new float[3];
  141. public float[] maxColor = new float[3];
  142. public float minRadius;
  143. public float maxRadius;
  144. public float colorRate;
  145. public uint minLightPriority;
  146. public uint maxLightPriority;
  147. public uint minShadowPriority;
  148. public uint maxShadowPriority;
  149. public byte onTimeHour;
  150. public byte onTimeMinute;
  151. public byte offTimeHour;
  152. public byte offTimeMinute;
  153. }
  154. }