VeLightNode.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. spotTextureFileName = reader.ReadString(2);
  78. }
  79. rgba[0] = reader.ReadSingle();
  80. rgba[1] = reader.ReadSingle();
  81. rgba[2] = reader.ReadSingle();
  82. radius = reader.ReadSingle();
  83. lightType = (LightType)reader.ReadUInt32();
  84. falloffType = (FalloffType)reader.ReadUInt32();
  85. unk10 = reader.ReadSingle();
  86. update = reader.ReadBoolean();
  87. if (classVersion > 0) unk12 = reader.ReadUInt32();
  88. if (classVersion > 3) sunShadow = reader.ReadBoolean();
  89. if (classVersion > 8) negative = reader.ReadBoolean();
  90. if (classVersion > 9) fogRadius = reader.ReadSingle();
  91. if (classVersion > 10) fog = reader.ReadBoolean();
  92. if (classVersion > 12) orientSunShadow = reader.ReadByte();
  93. if ((orientSunShadow & 2) == 2) reader.ReadUInt32();
  94. if (classVersion > 2)
  95. {
  96. minColor[0] = reader.ReadSingle();
  97. minColor[1] = reader.ReadSingle();
  98. minColor[2] = reader.ReadSingle();
  99. maxColor[0] = reader.ReadSingle();
  100. maxColor[1] = reader.ReadSingle();
  101. maxColor[2] = reader.ReadSingle();
  102. minRadius = reader.ReadSingle();
  103. maxRadius = reader.ReadSingle();
  104. colorRate = reader.ReadSingle();
  105. }
  106. if (classVersion > 4)
  107. {
  108. minLightPriority = reader.ReadUInt32();
  109. maxLightPriority = reader.ReadUInt32();
  110. minShadowPriority = reader.ReadUInt32();
  111. maxShadowPriority = reader.ReadUInt32();
  112. }
  113. if (classVersion > 5)
  114. {
  115. offTimeHour = reader.ReadByte();
  116. offTimeMinute = reader.ReadByte();
  117. onTimeHour = reader.ReadByte();
  118. onTimeMinute = reader.ReadByte();
  119. }
  120. }
  121. public float[] direction = new float[3];
  122. public float[] position = new float[3];
  123. public float[] transformMatrix = new float[16];
  124. public float spotX;
  125. public float spotY;
  126. public string spotTextureFileName;
  127. public float[] rgba = new float[3];
  128. public float radius;
  129. public LightType lightType;
  130. public FalloffType falloffType;
  131. public float unk10;
  132. public bool update;
  133. public uint unk12;
  134. public bool sunShadow;
  135. public bool negative;
  136. public float fogRadius;
  137. public bool fog;
  138. public byte orientSunShadow;
  139. public float[] minColor = new float[3];
  140. public float[] maxColor = new float[3];
  141. public float minRadius;
  142. public float maxRadius;
  143. public float colorRate;
  144. public uint minLightPriority;
  145. public uint maxLightPriority;
  146. public uint minShadowPriority;
  147. public uint maxShadowPriority;
  148. public byte onTimeHour;
  149. public byte onTimeMinute;
  150. public byte offTimeHour;
  151. public byte offTimeMinute;
  152. }
  153. }