PrimitiveBaseShape.cs 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Drawing;
  30. using System.Drawing.Imaging;
  31. using System.IO;
  32. using System.Reflection;
  33. using System.Xml;
  34. using System.Xml.Schema;
  35. using System.Xml.Serialization;
  36. using log4net;
  37. using OpenMetaverse;
  38. using OpenMetaverse.StructuredData;
  39. namespace OpenSim.Framework
  40. {
  41. public enum ProfileShape : byte
  42. {
  43. Circle = 0,
  44. Square = 1,
  45. IsometricTriangle = 2,
  46. EquilateralTriangle = 3,
  47. RightTriangle = 4,
  48. HalfCircle = 5
  49. }
  50. public enum HollowShape : byte
  51. {
  52. Same = 0,
  53. Circle = 16,
  54. Square = 32,
  55. Triangle = 48
  56. }
  57. public enum PCodeEnum : byte
  58. {
  59. Primitive = 9,
  60. Avatar = 47,
  61. Grass = 95,
  62. NewTree = 111,
  63. ParticleSystem = 143,
  64. Tree = 255
  65. }
  66. public enum Extrusion : byte
  67. {
  68. Straight = 16,
  69. Curve1 = 32,
  70. Curve2 = 48,
  71. Flexible = 128
  72. }
  73. [Serializable]
  74. public class PrimitiveBaseShape
  75. {
  76. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  77. private static readonly byte[] DEFAULT_TEXTURE = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f")).GetBytes();
  78. private byte[] m_textureEntry;
  79. private ushort _pathBegin;
  80. private byte _pathCurve;
  81. private ushort _pathEnd;
  82. private sbyte _pathRadiusOffset;
  83. private byte _pathRevolutions;
  84. private byte _pathScaleX;
  85. private byte _pathScaleY;
  86. private byte _pathShearX;
  87. private byte _pathShearY;
  88. private sbyte _pathSkew;
  89. private sbyte _pathTaperX;
  90. private sbyte _pathTaperY;
  91. private sbyte _pathTwist;
  92. private sbyte _pathTwistBegin;
  93. private byte _pCode;
  94. private ushort _profileBegin;
  95. private ushort _profileEnd;
  96. private ushort _profileHollow;
  97. private Vector3 _scale;
  98. private byte _state;
  99. private ProfileShape _profileShape;
  100. private HollowShape _hollowShape;
  101. // Sculpted
  102. [XmlIgnore] private UUID _sculptTexture;
  103. [XmlIgnore] private byte _sculptType;
  104. [XmlIgnore] private byte[] _sculptData = Utils.EmptyBytes;
  105. // Flexi
  106. [XmlIgnore] private int _flexiSoftness;
  107. [XmlIgnore] private float _flexiTension;
  108. [XmlIgnore] private float _flexiDrag;
  109. [XmlIgnore] private float _flexiGravity;
  110. [XmlIgnore] private float _flexiWind;
  111. [XmlIgnore] private float _flexiForceX;
  112. [XmlIgnore] private float _flexiForceY;
  113. [XmlIgnore] private float _flexiForceZ;
  114. //Bright n sparkly
  115. [XmlIgnore] private float _lightColorR;
  116. [XmlIgnore] private float _lightColorG;
  117. [XmlIgnore] private float _lightColorB;
  118. [XmlIgnore] private float _lightColorA = 1.0f;
  119. [XmlIgnore] private float _lightRadius;
  120. [XmlIgnore] private float _lightCutoff;
  121. [XmlIgnore] private float _lightFalloff;
  122. [XmlIgnore] private float _lightIntensity = 1.0f;
  123. [XmlIgnore] private bool _flexiEntry;
  124. [XmlIgnore] private bool _lightEntry;
  125. [XmlIgnore] private bool _sculptEntry;
  126. // Light Projection Filter
  127. [XmlIgnore] private bool _projectionEntry;
  128. [XmlIgnore] private UUID _projectionTextureID;
  129. [XmlIgnore] private float _projectionFOV;
  130. [XmlIgnore] private float _projectionFocus;
  131. [XmlIgnore] private float _projectionAmb;
  132. public byte ProfileCurve
  133. {
  134. get { return (byte)((byte)HollowShape | (byte)ProfileShape); }
  135. set
  136. {
  137. // Handle hollow shape component
  138. byte hollowShapeByte = (byte)(value & 0xf0);
  139. if (!Enum.IsDefined(typeof(HollowShape), hollowShapeByte))
  140. {
  141. m_log.WarnFormat(
  142. "[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.",
  143. hollowShapeByte);
  144. this._hollowShape = HollowShape.Same;
  145. }
  146. else
  147. {
  148. this._hollowShape = (HollowShape)hollowShapeByte;
  149. }
  150. // Handle profile shape component
  151. byte profileShapeByte = (byte)(value & 0xf);
  152. if (!Enum.IsDefined(typeof(ProfileShape), profileShapeByte))
  153. {
  154. m_log.WarnFormat(
  155. "[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.",
  156. profileShapeByte);
  157. this._profileShape = ProfileShape.Square;
  158. }
  159. else
  160. {
  161. this._profileShape = (ProfileShape)profileShapeByte;
  162. }
  163. }
  164. }
  165. /// <summary>
  166. /// Entries to store media textures on each face
  167. /// </summary>
  168. /// Do not change this value directly - always do it through an IMoapModule.
  169. /// Lock before manipulating.
  170. public MediaList Media { get; set; }
  171. public PrimitiveBaseShape()
  172. {
  173. PCode = (byte) PCodeEnum.Primitive;
  174. ExtraParams = new byte[1];
  175. m_textureEntry = DEFAULT_TEXTURE;
  176. }
  177. public PrimitiveBaseShape(bool noShape)
  178. {
  179. if (noShape)
  180. return;
  181. PCode = (byte)PCodeEnum.Primitive;
  182. ExtraParams = new byte[1];
  183. m_textureEntry = DEFAULT_TEXTURE;
  184. }
  185. /// <summary>
  186. /// Construct a PrimitiveBaseShape object from a OpenMetaverse.Primitive object
  187. /// </summary>
  188. /// <param name="prim"></param>
  189. public PrimitiveBaseShape(Primitive prim)
  190. {
  191. // m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID);
  192. PCode = (byte)prim.PrimData.PCode;
  193. ExtraParams = new byte[1];
  194. State = prim.PrimData.State;
  195. PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
  196. PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
  197. PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
  198. PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
  199. PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX);
  200. PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY);
  201. PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
  202. ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
  203. ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
  204. Scale = prim.Scale;
  205. PathCurve = (byte)prim.PrimData.PathCurve;
  206. ProfileCurve = (byte)prim.PrimData.ProfileCurve;
  207. ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
  208. PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
  209. PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
  210. PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
  211. PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
  212. PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
  213. PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);
  214. m_textureEntry = prim.Textures.GetBytes();
  215. SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None);
  216. SculptData = prim.Sculpt.GetBytes();
  217. SculptTexture = prim.Sculpt.SculptTexture;
  218. SculptType = (byte)prim.Sculpt.Type;
  219. }
  220. [XmlIgnore]
  221. public Primitive.TextureEntry Textures
  222. {
  223. get
  224. {
  225. // m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
  226. try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
  227. catch { }
  228. m_log.Warn("[SHAPE]: Failed to decode texture, length=" + ((m_textureEntry != null) ? m_textureEntry.Length : 0));
  229. return new Primitive.TextureEntry(UUID.Zero);
  230. }
  231. set { m_textureEntry = value.GetBytes(); }
  232. }
  233. public byte[] TextureEntry
  234. {
  235. get { return m_textureEntry; }
  236. set
  237. {
  238. if (value == null)
  239. m_textureEntry = new byte[1];
  240. else
  241. m_textureEntry = value;
  242. }
  243. }
  244. public static PrimitiveBaseShape Default
  245. {
  246. get
  247. {
  248. PrimitiveBaseShape boxShape = CreateBox();
  249. boxShape.SetScale(0.5f);
  250. return boxShape;
  251. }
  252. }
  253. public static PrimitiveBaseShape Create()
  254. {
  255. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  256. return shape;
  257. }
  258. public static PrimitiveBaseShape CreateBox()
  259. {
  260. PrimitiveBaseShape shape = Create();
  261. shape._pathCurve = (byte) Extrusion.Straight;
  262. shape._profileShape = ProfileShape.Square;
  263. shape._pathScaleX = 100;
  264. shape._pathScaleY = 100;
  265. return shape;
  266. }
  267. public static PrimitiveBaseShape CreateSphere()
  268. {
  269. PrimitiveBaseShape shape = Create();
  270. shape._pathCurve = (byte) Extrusion.Curve1;
  271. shape._profileShape = ProfileShape.HalfCircle;
  272. shape._pathScaleX = 100;
  273. shape._pathScaleY = 100;
  274. return shape;
  275. }
  276. public static PrimitiveBaseShape CreateCylinder()
  277. {
  278. PrimitiveBaseShape shape = Create();
  279. shape._pathCurve = (byte) Extrusion.Curve1;
  280. shape._profileShape = ProfileShape.Square;
  281. shape._pathScaleX = 100;
  282. shape._pathScaleY = 100;
  283. return shape;
  284. }
  285. public void SetScale(float side)
  286. {
  287. _scale = new Vector3(side, side, side);
  288. }
  289. public void SetHeigth(float heigth)
  290. {
  291. _scale.Z = heigth;
  292. }
  293. public void SetRadius(float radius)
  294. {
  295. _scale.X = _scale.Y = radius * 2f;
  296. }
  297. // TODO: void returns need to change of course
  298. public virtual void GetMesh()
  299. {
  300. }
  301. public PrimitiveBaseShape Copy()
  302. {
  303. return (PrimitiveBaseShape) MemberwiseClone();
  304. }
  305. public static PrimitiveBaseShape CreateCylinder(float radius, float heigth)
  306. {
  307. PrimitiveBaseShape shape = CreateCylinder();
  308. shape.SetHeigth(heigth);
  309. shape.SetRadius(radius);
  310. return shape;
  311. }
  312. public void SetPathRange(Vector3 pathRange)
  313. {
  314. _pathBegin = Primitive.PackBeginCut(pathRange.X);
  315. _pathEnd = Primitive.PackEndCut(pathRange.Y);
  316. }
  317. public void SetPathRange(float begin, float end)
  318. {
  319. _pathBegin = Primitive.PackBeginCut(begin);
  320. _pathEnd = Primitive.PackEndCut(end);
  321. }
  322. public void SetSculptProperties(byte sculptType, UUID SculptTextureUUID)
  323. {
  324. _sculptType = sculptType;
  325. _sculptTexture = SculptTextureUUID;
  326. }
  327. public void SetProfileRange(Vector3 profileRange)
  328. {
  329. _profileBegin = Primitive.PackBeginCut(profileRange.X);
  330. _profileEnd = Primitive.PackEndCut(profileRange.Y);
  331. }
  332. public void SetProfileRange(float begin, float end)
  333. {
  334. _profileBegin = Primitive.PackBeginCut(begin);
  335. _profileEnd = Primitive.PackEndCut(end);
  336. }
  337. public byte[] ExtraParams
  338. {
  339. get
  340. {
  341. return ExtraParamsToBytes();
  342. }
  343. set
  344. {
  345. ReadInExtraParamsBytes(value);
  346. }
  347. }
  348. public ushort PathBegin {
  349. get {
  350. return _pathBegin;
  351. }
  352. set {
  353. _pathBegin = value;
  354. }
  355. }
  356. public byte PathCurve {
  357. get {
  358. return _pathCurve;
  359. }
  360. set {
  361. _pathCurve = value;
  362. }
  363. }
  364. public ushort PathEnd {
  365. get {
  366. return _pathEnd;
  367. }
  368. set {
  369. _pathEnd = value;
  370. }
  371. }
  372. public sbyte PathRadiusOffset {
  373. get {
  374. return _pathRadiusOffset;
  375. }
  376. set {
  377. _pathRadiusOffset = value;
  378. }
  379. }
  380. public byte PathRevolutions {
  381. get {
  382. return _pathRevolutions;
  383. }
  384. set {
  385. _pathRevolutions = value;
  386. }
  387. }
  388. public byte PathScaleX {
  389. get {
  390. return _pathScaleX;
  391. }
  392. set {
  393. _pathScaleX = value;
  394. }
  395. }
  396. public byte PathScaleY {
  397. get {
  398. return _pathScaleY;
  399. }
  400. set {
  401. _pathScaleY = value;
  402. }
  403. }
  404. public byte PathShearX {
  405. get {
  406. return _pathShearX;
  407. }
  408. set {
  409. _pathShearX = value;
  410. }
  411. }
  412. public byte PathShearY {
  413. get {
  414. return _pathShearY;
  415. }
  416. set {
  417. _pathShearY = value;
  418. }
  419. }
  420. public sbyte PathSkew {
  421. get {
  422. return _pathSkew;
  423. }
  424. set {
  425. _pathSkew = value;
  426. }
  427. }
  428. public sbyte PathTaperX {
  429. get {
  430. return _pathTaperX;
  431. }
  432. set {
  433. _pathTaperX = value;
  434. }
  435. }
  436. public sbyte PathTaperY {
  437. get {
  438. return _pathTaperY;
  439. }
  440. set {
  441. _pathTaperY = value;
  442. }
  443. }
  444. public sbyte PathTwist {
  445. get {
  446. return _pathTwist;
  447. }
  448. set {
  449. _pathTwist = value;
  450. }
  451. }
  452. public sbyte PathTwistBegin {
  453. get {
  454. return _pathTwistBegin;
  455. }
  456. set {
  457. _pathTwistBegin = value;
  458. }
  459. }
  460. public byte PCode {
  461. get {
  462. return _pCode;
  463. }
  464. set {
  465. _pCode = value;
  466. }
  467. }
  468. public ushort ProfileBegin {
  469. get {
  470. return _profileBegin;
  471. }
  472. set {
  473. _profileBegin = value;
  474. }
  475. }
  476. public ushort ProfileEnd {
  477. get {
  478. return _profileEnd;
  479. }
  480. set {
  481. _profileEnd = value;
  482. }
  483. }
  484. public ushort ProfileHollow {
  485. get {
  486. return _profileHollow;
  487. }
  488. set {
  489. _profileHollow = value;
  490. }
  491. }
  492. public Vector3 Scale {
  493. get {
  494. return _scale;
  495. }
  496. set {
  497. _scale = value;
  498. }
  499. }
  500. public byte State {
  501. get {
  502. return _state;
  503. }
  504. set {
  505. _state = value;
  506. }
  507. }
  508. public ProfileShape ProfileShape {
  509. get {
  510. return _profileShape;
  511. }
  512. set {
  513. _profileShape = value;
  514. }
  515. }
  516. public HollowShape HollowShape {
  517. get {
  518. return _hollowShape;
  519. }
  520. set {
  521. _hollowShape = value;
  522. }
  523. }
  524. public UUID SculptTexture {
  525. get {
  526. return _sculptTexture;
  527. }
  528. set {
  529. _sculptTexture = value;
  530. }
  531. }
  532. public byte SculptType
  533. {
  534. get
  535. {
  536. return _sculptType;
  537. }
  538. set
  539. {
  540. _sculptType = value;
  541. }
  542. }
  543. public byte[] SculptData
  544. {
  545. get
  546. {
  547. return _sculptData;
  548. }
  549. set
  550. {
  551. // m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Setting SculptData to data with length {0}", value.Length);
  552. _sculptData = value;
  553. }
  554. }
  555. public int FlexiSoftness
  556. {
  557. get
  558. {
  559. return _flexiSoftness;
  560. }
  561. set
  562. {
  563. _flexiSoftness = value;
  564. }
  565. }
  566. public float FlexiTension {
  567. get {
  568. return _flexiTension;
  569. }
  570. set {
  571. _flexiTension = value;
  572. }
  573. }
  574. public float FlexiDrag {
  575. get {
  576. return _flexiDrag;
  577. }
  578. set {
  579. _flexiDrag = value;
  580. }
  581. }
  582. public float FlexiGravity {
  583. get {
  584. return _flexiGravity;
  585. }
  586. set {
  587. _flexiGravity = value;
  588. }
  589. }
  590. public float FlexiWind {
  591. get {
  592. return _flexiWind;
  593. }
  594. set {
  595. _flexiWind = value;
  596. }
  597. }
  598. public float FlexiForceX {
  599. get {
  600. return _flexiForceX;
  601. }
  602. set {
  603. _flexiForceX = value;
  604. }
  605. }
  606. public float FlexiForceY {
  607. get {
  608. return _flexiForceY;
  609. }
  610. set {
  611. _flexiForceY = value;
  612. }
  613. }
  614. public float FlexiForceZ {
  615. get {
  616. return _flexiForceZ;
  617. }
  618. set {
  619. _flexiForceZ = value;
  620. }
  621. }
  622. public float LightColorR {
  623. get {
  624. return _lightColorR;
  625. }
  626. set {
  627. _lightColorR = value;
  628. }
  629. }
  630. public float LightColorG {
  631. get {
  632. return _lightColorG;
  633. }
  634. set {
  635. _lightColorG = value;
  636. }
  637. }
  638. public float LightColorB {
  639. get {
  640. return _lightColorB;
  641. }
  642. set {
  643. _lightColorB = value;
  644. }
  645. }
  646. public float LightColorA {
  647. get {
  648. return _lightColorA;
  649. }
  650. set {
  651. _lightColorA = value;
  652. }
  653. }
  654. public float LightRadius {
  655. get {
  656. return _lightRadius;
  657. }
  658. set {
  659. _lightRadius = value;
  660. }
  661. }
  662. public float LightCutoff {
  663. get {
  664. return _lightCutoff;
  665. }
  666. set {
  667. _lightCutoff = value;
  668. }
  669. }
  670. public float LightFalloff {
  671. get {
  672. return _lightFalloff;
  673. }
  674. set {
  675. _lightFalloff = value;
  676. }
  677. }
  678. public float LightIntensity {
  679. get {
  680. return _lightIntensity;
  681. }
  682. set {
  683. _lightIntensity = value;
  684. }
  685. }
  686. public bool FlexiEntry {
  687. get {
  688. return _flexiEntry;
  689. }
  690. set {
  691. _flexiEntry = value;
  692. }
  693. }
  694. public bool LightEntry {
  695. get {
  696. return _lightEntry;
  697. }
  698. set {
  699. _lightEntry = value;
  700. }
  701. }
  702. public bool SculptEntry {
  703. get {
  704. return _sculptEntry;
  705. }
  706. set {
  707. _sculptEntry = value;
  708. }
  709. }
  710. public bool ProjectionEntry {
  711. get {
  712. return _projectionEntry;
  713. }
  714. set {
  715. _projectionEntry = value;
  716. }
  717. }
  718. public UUID ProjectionTextureUUID {
  719. get {
  720. return _projectionTextureID;
  721. }
  722. set {
  723. _projectionTextureID = value;
  724. }
  725. }
  726. public float ProjectionFOV {
  727. get {
  728. return _projectionFOV;
  729. }
  730. set {
  731. _projectionFOV = value;
  732. }
  733. }
  734. public float ProjectionFocus {
  735. get {
  736. return _projectionFocus;
  737. }
  738. set {
  739. _projectionFocus = value;
  740. }
  741. }
  742. public float ProjectionAmbiance {
  743. get {
  744. return _projectionAmb;
  745. }
  746. set {
  747. _projectionAmb = value;
  748. }
  749. }
  750. public byte[] ExtraParamsToBytes()
  751. {
  752. // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()");
  753. ushort FlexiEP = 0x10;
  754. ushort LightEP = 0x20;
  755. ushort SculptEP = 0x30;
  756. ushort ProjectionEP = 0x40;
  757. int i = 0;
  758. uint TotalBytesLength = 1; // ExtraParamsNum
  759. uint ExtraParamsNum = 0;
  760. if (_flexiEntry)
  761. {
  762. ExtraParamsNum++;
  763. TotalBytesLength += 16;// data
  764. TotalBytesLength += 2 + 4; // type
  765. }
  766. if (_lightEntry)
  767. {
  768. ExtraParamsNum++;
  769. TotalBytesLength += 16;// data
  770. TotalBytesLength += 2 + 4; // type
  771. }
  772. if (_sculptEntry)
  773. {
  774. ExtraParamsNum++;
  775. TotalBytesLength += 17;// data
  776. TotalBytesLength += 2 + 4; // type
  777. }
  778. if (_projectionEntry)
  779. {
  780. ExtraParamsNum++;
  781. TotalBytesLength += 28;// data
  782. TotalBytesLength += 2 + 4;// type
  783. }
  784. byte[] returnbytes = new byte[TotalBytesLength];
  785. // uint paramlength = ExtraParamsNum;
  786. // Stick in the number of parameters
  787. returnbytes[i++] = (byte)ExtraParamsNum;
  788. if (_flexiEntry)
  789. {
  790. byte[] FlexiData = GetFlexiBytes();
  791. returnbytes[i++] = (byte)(FlexiEP % 256);
  792. returnbytes[i++] = (byte)((FlexiEP >> 8) % 256);
  793. returnbytes[i++] = (byte)(FlexiData.Length % 256);
  794. returnbytes[i++] = (byte)((FlexiData.Length >> 8) % 256);
  795. returnbytes[i++] = (byte)((FlexiData.Length >> 16) % 256);
  796. returnbytes[i++] = (byte)((FlexiData.Length >> 24) % 256);
  797. Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length);
  798. i += FlexiData.Length;
  799. }
  800. if (_lightEntry)
  801. {
  802. byte[] LightData = GetLightBytes();
  803. returnbytes[i++] = (byte)(LightEP % 256);
  804. returnbytes[i++] = (byte)((LightEP >> 8) % 256);
  805. returnbytes[i++] = (byte)(LightData.Length % 256);
  806. returnbytes[i++] = (byte)((LightData.Length >> 8) % 256);
  807. returnbytes[i++] = (byte)((LightData.Length >> 16) % 256);
  808. returnbytes[i++] = (byte)((LightData.Length >> 24) % 256);
  809. Array.Copy(LightData, 0, returnbytes, i, LightData.Length);
  810. i += LightData.Length;
  811. }
  812. if (_sculptEntry)
  813. {
  814. byte[] SculptData = GetSculptBytes();
  815. returnbytes[i++] = (byte)(SculptEP % 256);
  816. returnbytes[i++] = (byte)((SculptEP >> 8) % 256);
  817. returnbytes[i++] = (byte)(SculptData.Length % 256);
  818. returnbytes[i++] = (byte)((SculptData.Length >> 8) % 256);
  819. returnbytes[i++] = (byte)((SculptData.Length >> 16) % 256);
  820. returnbytes[i++] = (byte)((SculptData.Length >> 24) % 256);
  821. Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
  822. i += SculptData.Length;
  823. }
  824. if (_projectionEntry)
  825. {
  826. byte[] ProjectionData = GetProjectionBytes();
  827. returnbytes[i++] = (byte)(ProjectionEP % 256);
  828. returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256);
  829. returnbytes[i++] = (byte)((ProjectionData.Length) % 256);
  830. returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256);
  831. returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256);
  832. returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256);
  833. Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
  834. i += ProjectionData.Length;
  835. }
  836. if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry)
  837. {
  838. byte[] returnbyte = new byte[1];
  839. returnbyte[0] = 0;
  840. return returnbyte;
  841. }
  842. return returnbytes;
  843. }
  844. public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data)
  845. {
  846. const ushort FlexiEP = 0x10;
  847. const ushort LightEP = 0x20;
  848. const ushort SculptEP = 0x30;
  849. const ushort ProjectionEP = 0x40;
  850. switch (type)
  851. {
  852. case FlexiEP:
  853. if (!inUse)
  854. {
  855. _flexiEntry = false;
  856. return;
  857. }
  858. ReadFlexiData(data, 0);
  859. break;
  860. case LightEP:
  861. if (!inUse)
  862. {
  863. _lightEntry = false;
  864. return;
  865. }
  866. ReadLightData(data, 0);
  867. break;
  868. case SculptEP:
  869. if (!inUse)
  870. {
  871. _sculptEntry = false;
  872. return;
  873. }
  874. ReadSculptData(data, 0);
  875. break;
  876. case ProjectionEP:
  877. if (!inUse)
  878. {
  879. _projectionEntry = false;
  880. return;
  881. }
  882. ReadProjectionData(data, 0);
  883. break;
  884. }
  885. }
  886. public void ReadInExtraParamsBytes(byte[] data)
  887. {
  888. if (data == null || data.Length == 1)
  889. return;
  890. const ushort FlexiEP = 0x10;
  891. const ushort LightEP = 0x20;
  892. const ushort SculptEP = 0x30;
  893. const ushort ProjectionEP = 0x40;
  894. bool lGotFlexi = false;
  895. bool lGotLight = false;
  896. bool lGotSculpt = false;
  897. bool lGotFilter = false;
  898. int i = 0;
  899. byte extraParamCount = 0;
  900. if (data.Length > 0)
  901. {
  902. extraParamCount = data[i++];
  903. }
  904. for (int k = 0; k < extraParamCount; k++)
  905. {
  906. ushort epType = Utils.BytesToUInt16(data, i);
  907. i += 2;
  908. // uint paramLength = Helpers.BytesToUIntBig(data, i);
  909. i += 4;
  910. switch (epType)
  911. {
  912. case FlexiEP:
  913. ReadFlexiData(data, i);
  914. i += 16;
  915. lGotFlexi = true;
  916. break;
  917. case LightEP:
  918. ReadLightData(data, i);
  919. i += 16;
  920. lGotLight = true;
  921. break;
  922. case SculptEP:
  923. ReadSculptData(data, i);
  924. i += 17;
  925. lGotSculpt = true;
  926. break;
  927. case ProjectionEP:
  928. ReadProjectionData(data, i);
  929. i += 28;
  930. lGotFilter = true;
  931. break;
  932. }
  933. }
  934. if (!lGotFlexi)
  935. _flexiEntry = false;
  936. if (!lGotLight)
  937. _lightEntry = false;
  938. if (!lGotSculpt)
  939. _sculptEntry = false;
  940. if (!lGotFilter)
  941. _projectionEntry = false;
  942. }
  943. public void ReadSculptData(byte[] data, int pos)
  944. {
  945. byte[] SculptTextureUUID = new byte[16];
  946. UUID SculptUUID = UUID.Zero;
  947. byte SculptTypel = data[16+pos];
  948. if (data.Length+pos >= 17)
  949. {
  950. _sculptEntry = true;
  951. SculptTextureUUID = new byte[16];
  952. SculptTypel = data[16 + pos];
  953. Array.Copy(data, pos, SculptTextureUUID,0, 16);
  954. SculptUUID = new UUID(SculptTextureUUID, 0);
  955. }
  956. else
  957. {
  958. _sculptEntry = false;
  959. SculptUUID = UUID.Zero;
  960. SculptTypel = 0x00;
  961. }
  962. if (_sculptEntry)
  963. {
  964. if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4)
  965. _sculptType = 4;
  966. }
  967. _sculptTexture = SculptUUID;
  968. _sculptType = SculptTypel;
  969. //m_log.Info("[SCULPT]:" + SculptUUID.ToString());
  970. }
  971. public byte[] GetSculptBytes()
  972. {
  973. byte[] data = new byte[17];
  974. _sculptTexture.GetBytes().CopyTo(data, 0);
  975. data[16] = (byte)_sculptType;
  976. return data;
  977. }
  978. public void ReadFlexiData(byte[] data, int pos)
  979. {
  980. if (data.Length-pos >= 16)
  981. {
  982. _flexiEntry = true;
  983. _flexiSoftness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7);
  984. _flexiTension = (float)(data[pos++] & 0x7F) / 10.0f;
  985. _flexiDrag = (float)(data[pos++] & 0x7F) / 10.0f;
  986. _flexiGravity = (float)(data[pos++] / 10.0f) - 10.0f;
  987. _flexiWind = (float)data[pos++] / 10.0f;
  988. Vector3 lForce = new Vector3(data, pos);
  989. _flexiForceX = lForce.X;
  990. _flexiForceY = lForce.Y;
  991. _flexiForceZ = lForce.Z;
  992. }
  993. else
  994. {
  995. _flexiEntry = false;
  996. _flexiSoftness = 0;
  997. _flexiTension = 0.0f;
  998. _flexiDrag = 0.0f;
  999. _flexiGravity = 0.0f;
  1000. _flexiWind = 0.0f;
  1001. _flexiForceX = 0f;
  1002. _flexiForceY = 0f;
  1003. _flexiForceZ = 0f;
  1004. }
  1005. }
  1006. public byte[] GetFlexiBytes()
  1007. {
  1008. byte[] data = new byte[16];
  1009. int i = 0;
  1010. // Softness is packed in the upper bits of tension and drag
  1011. data[i] = (byte)((_flexiSoftness & 2) << 6);
  1012. data[i + 1] = (byte)((_flexiSoftness & 1) << 7);
  1013. data[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F);
  1014. data[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F);
  1015. data[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f);
  1016. data[i++] = (byte)(_flexiWind * 10.01f);
  1017. Vector3 lForce = new Vector3(_flexiForceX, _flexiForceY, _flexiForceZ);
  1018. lForce.GetBytes().CopyTo(data, i);
  1019. return data;
  1020. }
  1021. public void ReadLightData(byte[] data, int pos)
  1022. {
  1023. if (data.Length - pos >= 16)
  1024. {
  1025. _lightEntry = true;
  1026. Color4 lColor = new Color4(data, pos, false);
  1027. _lightIntensity = lColor.A;
  1028. _lightColorA = 1f;
  1029. _lightColorR = lColor.R;
  1030. _lightColorG = lColor.G;
  1031. _lightColorB = lColor.B;
  1032. _lightRadius = Utils.BytesToFloat(data, pos + 4);
  1033. _lightCutoff = Utils.BytesToFloat(data, pos + 8);
  1034. _lightFalloff = Utils.BytesToFloat(data, pos + 12);
  1035. }
  1036. else
  1037. {
  1038. _lightEntry = false;
  1039. _lightColorA = 1f;
  1040. _lightColorR = 0f;
  1041. _lightColorG = 0f;
  1042. _lightColorB = 0f;
  1043. _lightRadius = 0f;
  1044. _lightCutoff = 0f;
  1045. _lightFalloff = 0f;
  1046. _lightIntensity = 0f;
  1047. }
  1048. }
  1049. public byte[] GetLightBytes()
  1050. {
  1051. byte[] data = new byte[16];
  1052. // Alpha channel in color is intensity
  1053. Color4 tmpColor = new Color4(_lightColorR,_lightColorG,_lightColorB,_lightIntensity);
  1054. tmpColor.GetBytes().CopyTo(data, 0);
  1055. Utils.FloatToBytes(_lightRadius).CopyTo(data, 4);
  1056. Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8);
  1057. Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12);
  1058. return data;
  1059. }
  1060. public void ReadProjectionData(byte[] data, int pos)
  1061. {
  1062. byte[] ProjectionTextureUUID = new byte[16];
  1063. if (data.Length - pos >= 28)
  1064. {
  1065. _projectionEntry = true;
  1066. Array.Copy(data, pos, ProjectionTextureUUID,0, 16);
  1067. _projectionTextureID = new UUID(ProjectionTextureUUID, 0);
  1068. _projectionFOV = Utils.BytesToFloat(data, pos + 16);
  1069. _projectionFocus = Utils.BytesToFloat(data, pos + 20);
  1070. _projectionAmb = Utils.BytesToFloat(data, pos + 24);
  1071. }
  1072. else
  1073. {
  1074. _projectionEntry = false;
  1075. _projectionTextureID = UUID.Zero;
  1076. _projectionFOV = 0f;
  1077. _projectionFocus = 0f;
  1078. _projectionAmb = 0f;
  1079. }
  1080. }
  1081. public byte[] GetProjectionBytes()
  1082. {
  1083. byte[] data = new byte[28];
  1084. _projectionTextureID.GetBytes().CopyTo(data, 0);
  1085. Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16);
  1086. Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20);
  1087. Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24);
  1088. return data;
  1089. }
  1090. /// <summary>
  1091. /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values
  1092. /// </summary>
  1093. /// <returns></returns>
  1094. public Primitive ToOmvPrimitive()
  1095. {
  1096. // position and rotation defaults here since they are not available in PrimitiveBaseShape
  1097. return ToOmvPrimitive(new Vector3(0.0f, 0.0f, 0.0f),
  1098. new Quaternion(0.0f, 0.0f, 0.0f, 1.0f));
  1099. }
  1100. /// <summary>
  1101. /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values
  1102. /// </summary>
  1103. /// <param name="position"></param>
  1104. /// <param name="rotation"></param>
  1105. /// <returns></returns>
  1106. public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation)
  1107. {
  1108. OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive();
  1109. prim.Scale = this.Scale;
  1110. prim.Position = position;
  1111. prim.Rotation = rotation;
  1112. if (this.SculptEntry)
  1113. {
  1114. prim.Sculpt = new Primitive.SculptData();
  1115. prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType;
  1116. prim.Sculpt.SculptTexture = this.SculptTexture;
  1117. }
  1118. prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f;
  1119. prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f;
  1120. prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f;
  1121. prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f;
  1122. prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f;
  1123. prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f;
  1124. prim.PrimData.PathTaperX = this.PathTaperX * 0.01f;
  1125. prim.PrimData.PathTaperY = this.PathTaperY * 0.01f;
  1126. prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f;
  1127. prim.PrimData.PathTwist = this.PathTwist * 0.01f;
  1128. prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f;
  1129. prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f;
  1130. prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f;
  1131. prim.PrimData.profileCurve = this.ProfileCurve;
  1132. prim.PrimData.ProfileHole = (HoleType)this.HollowShape;
  1133. prim.PrimData.PathCurve = (PathCurve)this.PathCurve;
  1134. prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset;
  1135. prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions;
  1136. prim.PrimData.PathSkew = 0.01f * this.PathSkew;
  1137. prim.PrimData.PCode = OpenMetaverse.PCode.Prim;
  1138. prim.PrimData.State = 0;
  1139. if (this.FlexiEntry)
  1140. {
  1141. prim.Flexible = new Primitive.FlexibleData();
  1142. prim.Flexible.Drag = this.FlexiDrag;
  1143. prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ);
  1144. prim.Flexible.Gravity = this.FlexiGravity;
  1145. prim.Flexible.Softness = this.FlexiSoftness;
  1146. prim.Flexible.Tension = this.FlexiTension;
  1147. prim.Flexible.Wind = this.FlexiWind;
  1148. }
  1149. if (this.LightEntry)
  1150. {
  1151. prim.Light = new Primitive.LightData();
  1152. prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA);
  1153. prim.Light.Cutoff = this.LightCutoff;
  1154. prim.Light.Falloff = this.LightFalloff;
  1155. prim.Light.Intensity = this.LightIntensity;
  1156. prim.Light.Radius = this.LightRadius;
  1157. }
  1158. prim.Textures = this.Textures;
  1159. prim.Properties = new Primitive.ObjectProperties();
  1160. prim.Properties.Name = "Primitive";
  1161. prim.Properties.Description = "";
  1162. prim.Properties.CreatorID = UUID.Zero;
  1163. prim.Properties.GroupID = UUID.Zero;
  1164. prim.Properties.OwnerID = UUID.Zero;
  1165. prim.Properties.Permissions = new Permissions();
  1166. prim.Properties.SalePrice = 10;
  1167. prim.Properties.SaleType = new SaleType();
  1168. return prim;
  1169. }
  1170. /// <summary>
  1171. /// Encapsulates a list of media entries.
  1172. /// </summary>
  1173. /// This class is necessary because we want to replace auto-serialization of MediaEntry with something more
  1174. /// OSD like and less vulnerable to change.
  1175. public class MediaList : List<MediaEntry>, IXmlSerializable
  1176. {
  1177. public const string MEDIA_TEXTURE_TYPE = "sl";
  1178. public MediaList() : base() {}
  1179. public MediaList(IEnumerable<MediaEntry> collection) : base(collection) {}
  1180. public MediaList(int capacity) : base(capacity) {}
  1181. public XmlSchema GetSchema()
  1182. {
  1183. return null;
  1184. }
  1185. public string ToXml()
  1186. {
  1187. lock (this)
  1188. {
  1189. using (StringWriter sw = new StringWriter())
  1190. {
  1191. using (XmlTextWriter xtw = new XmlTextWriter(sw))
  1192. {
  1193. xtw.WriteStartElement("OSMedia");
  1194. xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE);
  1195. xtw.WriteAttributeString("version", "0.1");
  1196. OSDArray meArray = new OSDArray();
  1197. foreach (MediaEntry me in this)
  1198. {
  1199. OSD osd = (null == me ? new OSD() : me.GetOSD());
  1200. meArray.Add(osd);
  1201. }
  1202. xtw.WriteStartElement("OSData");
  1203. xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
  1204. xtw.WriteEndElement();
  1205. xtw.WriteEndElement();
  1206. xtw.Flush();
  1207. return sw.ToString();
  1208. }
  1209. }
  1210. }
  1211. }
  1212. public void WriteXml(XmlWriter writer)
  1213. {
  1214. writer.WriteRaw(ToXml());
  1215. }
  1216. public static MediaList FromXml(string rawXml)
  1217. {
  1218. MediaList ml = new MediaList();
  1219. ml.ReadXml(rawXml);
  1220. return ml;
  1221. }
  1222. public void ReadXml(string rawXml)
  1223. {
  1224. using (StringReader sr = new StringReader(rawXml))
  1225. {
  1226. using (XmlTextReader xtr = new XmlTextReader(sr))
  1227. {
  1228. xtr.MoveToContent();
  1229. string type = xtr.GetAttribute("type");
  1230. //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
  1231. if (type != MEDIA_TEXTURE_TYPE)
  1232. return;
  1233. xtr.ReadStartElement("OSMedia");
  1234. OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
  1235. foreach (OSD osdMe in osdMeArray)
  1236. {
  1237. MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
  1238. Add(me);
  1239. }
  1240. xtr.ReadEndElement();
  1241. }
  1242. }
  1243. }
  1244. public void ReadXml(XmlReader reader)
  1245. {
  1246. if (reader.IsEmptyElement)
  1247. return;
  1248. ReadXml(reader.ReadInnerXml());
  1249. }
  1250. }
  1251. }
  1252. }