Index: AssetTypes.cs
===================================================================
--- AssetTypes.cs (revision 2588)
+++ AssetTypes.cs (working copy)
@@ -207,6 +207,78 @@
}
///
+ /// Represents a Landmark with RegionID and Position vector
+ ///
+ public class AssetLandmark : Asset
+ {
+ /// Override the base classes AssetType
+ public override AssetType AssetType { get { return AssetType.Landmark; } }
+
+ /// UUID of the Landmark target region
+ public UUID RegionID = UUID.Zero;
+ /// Local position of the target
+ public Vector3 Position = Vector3.Zero;
+
+ /// Construct an Asset of type Landmark
+ public AssetLandmark() { }
+
+ ///
+ /// Construct an Asset object of type Landmark
+ ///
+ /// A unique specific to this asset
+ /// A byte array containing the raw asset data
+ public AssetLandmark(UUID assetID, byte[] assetData)
+ : base(assetID, assetData)
+ {
+ Decode();
+ }
+
+ ///
+ /// Constuct an asset of type Landmark
+ ///
+ /// UUID of the target region
+ /// Local position of landmark
+ public AssetLandmark(UUID regionID, Vector3 pos)
+ {
+ RegionID = regionID;
+ Position = pos;
+ Encode();
+ }
+
+ ///
+ /// Encode the raw contents of a string with the specific Landmark format
+ ///
+ public override void Encode()
+ {
+ string temp = "Landmark version 2\n";
+ temp += "region_id " + RegionID + "\n";
+ temp += String.Format("local_pos {0:0.00} {1:0.00} {2:0.00}\n", Position.X, Position.Y, Position.Z);
+ AssetData = Utils.StringToBytes(temp);
+ }
+
+ ///
+ /// Decode the raw asset data, populating the RegionID and Position
+ ///
+ /// true if the AssetData was successfully decoded to a UUID and Vector
+ public override bool Decode()
+ {
+ String text = Utils.BytesToString(AssetData);
+ if(text.ToLower().Contains("landmark version 2"))
+ {
+ RegionID = new UUID(text.Substring(text.IndexOf("region_id") + 10, 36));
+ String vecDelim = " ";
+ String[] vecStrings = text.Substring(text.IndexOf("local_pos") + 10).Split(vecDelim.ToCharArray());
+ if(vecStrings.Length == 3)
+ {
+ Position = new Vector3(float.Parse(vecStrings[0]), float.Parse(vecStrings[1]), float.Parse(vecStrings[2]));
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ ///
/// Represents an LSL Text object containing a string of UTF encoded characters
///
public class AssetScriptText : Asset