Skip to content

Commit

Permalink
Begin Material asset support
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Aug 12, 2024
1 parent a293409 commit 2615706
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
3 changes: 2 additions & 1 deletion LibreMetaverse.Types/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ public enum InventoryType : sbyte
Animation = 19,
/// <summary></summary>
Gesture = 20,

/// <summary></summary>
Mesh = 22,
/// <summary></summary>
Settings = 23,
/// <summary></summary>
Material = 24,
}

/// <summary>
Expand Down
57 changes: 57 additions & 0 deletions LibreMetaverse/Assets/AssetTypes/AssetMaterial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2024, Sjofn LLC
* All rights reserved.
*
* - Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Neither the name of the openmetaverse.co nor the names
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace OpenMetaverse.Assets
{
public class AssetMaterial : Asset
{
public override AssetType AssetType => AssetType.Material;

/// <summary>Initializes a new instance of an AssetMaterial object</summary>
public AssetMaterial() { }

/// <summary>
/// Construct an Asset object of type Material
/// </summary>
/// <param name="assetId">A unique <see cref="UUID"/> specific to this asset</param>
/// <param name="assetData">A byte array containing the raw asset data</param>
public AssetMaterial(UUID assetId, byte[] assetData)
: base(assetId, assetData)
{
Decode();
}

public override void Encode()
{
throw new System.NotImplementedException();
}

public sealed override bool Decode()
{
throw new System.NotImplementedException();
}
}
}
23 changes: 23 additions & 0 deletions LibreMetaverse/InventoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,29 @@ public InventorySettings(SerializationInfo info, StreamingContext ctxt) : base(i
}
}

/// <inheritdoc />
/// <summary>
/// InventoryMaterial, material as an asset
/// </summary>
[Serializable]
public class InventoryMaterial : InventoryItem
{
/// <summary>
/// Construct an InventorySettings object
/// </summary>
/// <param name="itemID">A <seealso cref="UUID"/> which becomes the
/// <seealso cref="InventoryItem"/> objects AssetUUID</param>
public InventoryMaterial(UUID itemID) : base(itemID)
{
InventoryType = InventoryType.Settings;
}

public InventoryMaterial(SerializationInfo info, StreamingContext ctxt) : base(info, ctxt)
{
InventoryType = InventoryType.Settings;
}
}

/// <inheritdoc />
/// <summary>
/// A folder contains <seealso cref="T:OpenMetaverse.InventoryItem" />s and has certain attributes specific
Expand Down
1 change: 1 addition & 0 deletions LibreMetaverse/InventoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,7 @@ public static InventoryItem CreateInventoryItem(InventoryType type, UUID id)
case InventoryType.Animation: return new InventoryAnimation(id);
case InventoryType.Gesture: return new InventoryGesture(id);
case InventoryType.Settings: return new InventorySettings(id);
case InventoryType.Material: return new InventoryMaterial(id);
default: return new InventoryItem(type, id);
}
}
Expand Down

0 comments on commit 2615706

Please sign in to comment.