C# Class OpenMetaverse.Helpers

Static helper functions and global variables
Show file Open project: 3di/3di-viewer-rei-libs Class Usage Examples

Public Methods

Method Description
FloatToTerseString ( float val ) : string

Converts a floating point number to a terse string format used for transmitting numbers in wearable asset files

GetResourceStream ( string resourceName ) : System.IO.Stream

Attempts to load a file embedded in the assembly

GetResourceStream ( string resourceName, string searchPath ) : System.IO.Stream

Attempts to load a file either embedded in the assembly or found in a given search path

GlobalPosToRegionHandle ( float globalX, float globalY, float &localX, float &localY ) : ulong

Given an X/Y location in absolute (grid-relative) terms, a region handle is returned along with the local X/Y location in that region

InventoryCRC ( int creationDate, byte saleType, sbyte invType, sbyte type, UUID assetID, UUID groupID, int salePrice, UUID ownerID, UUID creatorID, UUID itemID, UUID folderID, uint everyoneMask, uint flags, uint nextOwnerMask, uint groupMask, uint ownerMask ) : uint

Calculates the CRC (cyclic redundancy check) needed to upload inventory.

OSDToPrimList ( StructuredData osd ) : List

Deserializes OSD in to a list of primitives

PrimListToOSD ( List prims ) : StructuredData.OSD

Converts a list of primitives to an object that can be serialized with the LLSD system

SplitBlocks ( OpenMetaverse.Packets.PacketBlock blocks, int packetOverhead ) : List
StateToAttachmentPoint ( uint state ) : AttachmentPoint
TEGlowByte ( float glow ) : byte
TEGlowFloat ( byte bytes, int pos ) : float
TEOffsetFloat ( byte bytes, int pos ) : float

TEOffsetShort ( float offset ) : short

TERotationFloat ( byte bytes, int pos ) : float

TERotationShort ( float rotation ) : short

ZeroDecode ( byte src, int srclen, byte dest ) : int

Decode a zerocoded byte array, used to decompress packets marked with the zerocoded flag

Any time a zero is encountered, the next byte is a count of how many zeroes to expand. One zero is encoded with 0x00 0x01, two zeroes is 0x00 0x02, three zeroes is 0x00 0x03, etc. The first four bytes are copied directly to the output buffer.

ZeroEncode ( byte src, int srclen, byte dest ) : int

Encode a byte array with zerocoding. Used to compress packets marked with the zerocoded flag. Any zeroes in the array are compressed down to a single zero byte followed by a count of how many zeroes to expand out. A single zero becomes 0x00 0x01, two zeroes becomes 0x00 0x02, three zeroes becomes 0x00 0x03, etc. The first four bytes are copied directly to the output buffer.

Private Methods

Method Description
FieldToString ( StringBuilder output, byte bytes, string fieldName ) : void

Convert a variable length field (byte array) to a string, with a field name prepended to each line of the output

If the byte array has unprintable characters in it, a hex dump will be written instead

Method Details

FloatToTerseString() public static method

Converts a floating point number to a terse string format used for transmitting numbers in wearable asset files
public static FloatToTerseString ( float val ) : string
val float Floating point number to convert to a string
return string

GetResourceStream() public static method

Attempts to load a file embedded in the assembly
public static GetResourceStream ( string resourceName ) : System.IO.Stream
resourceName string The filename of the resource to load
return System.IO.Stream

GetResourceStream() public static method

Attempts to load a file either embedded in the assembly or found in a given search path
public static GetResourceStream ( string resourceName, string searchPath ) : System.IO.Stream
resourceName string The filename of the resource to load
searchPath string An optional path that will be searched if /// the asset is not found embedded in the assembly
return System.IO.Stream

GlobalPosToRegionHandle() public static method

Given an X/Y location in absolute (grid-relative) terms, a region handle is returned along with the local X/Y location in that region
public static GlobalPosToRegionHandle ( float globalX, float globalY, float &localX, float &localY ) : ulong
globalX float The absolute X location, a number such as /// 255360.35
globalY float The absolute Y location, a number such as /// 255360.35
localX float The sim-local X position of the global X /// position, a value from 0.0 to 256.0
localY float The sim-local Y position of the global Y /// position, a value from 0.0 to 256.0
return ulong

InventoryCRC() public static method

Calculates the CRC (cyclic redundancy check) needed to upload inventory.
public static InventoryCRC ( int creationDate, byte saleType, sbyte invType, sbyte type, UUID assetID, UUID groupID, int salePrice, UUID ownerID, UUID creatorID, UUID itemID, UUID folderID, uint everyoneMask, uint flags, uint nextOwnerMask, uint groupMask, uint ownerMask ) : uint
creationDate int Creation date
saleType byte Sale type
invType sbyte Inventory type
type sbyte Type
assetID UUID Asset ID
groupID UUID Group ID
salePrice int Sale price
ownerID UUID Owner ID
creatorID UUID Creator ID
itemID UUID Item ID
folderID UUID Folder ID
everyoneMask uint Everyone mask (permissions)
flags uint Flags
nextOwnerMask uint Next owner mask (permissions)
groupMask uint Group mask (permissions)
ownerMask uint Owner mask (permisions)
return uint

OSDToPrimList() public static method

Deserializes OSD in to a list of primitives
public static OSDToPrimList ( StructuredData osd ) : List
osd StructuredData Structure holding the serialized primitive list, /// must be of the SDMap type
return List

PrimListToOSD() public static method

Converts a list of primitives to an object that can be serialized with the LLSD system
public static PrimListToOSD ( List prims ) : StructuredData.OSD
prims List Primitives to convert to a serializable object
return StructuredData.OSD

SplitBlocks() public static method

public static SplitBlocks ( OpenMetaverse.Packets.PacketBlock blocks, int packetOverhead ) : List
blocks OpenMetaverse.Packets.PacketBlock
packetOverhead int
return List

StateToAttachmentPoint() public static method

public static StateToAttachmentPoint ( uint state ) : AttachmentPoint
state uint
return AttachmentPoint

TEGlowByte() public static method

public static TEGlowByte ( float glow ) : byte
glow float
return byte

TEGlowFloat() public static method

public static TEGlowFloat ( byte bytes, int pos ) : float
bytes byte
pos int
return float

TEOffsetFloat() public static method

public static TEOffsetFloat ( byte bytes, int pos ) : float
bytes byte
pos int
return float

TEOffsetShort() public static method

public static TEOffsetShort ( float offset ) : short
offset float
return short

TERotationFloat() public static method

public static TERotationFloat ( byte bytes, int pos ) : float
bytes byte
pos int
return float

TERotationShort() public static method

public static TERotationShort ( float rotation ) : short
rotation float
return short

ZeroDecode() public static method

Decode a zerocoded byte array, used to decompress packets marked with the zerocoded flag
Any time a zero is encountered, the next byte is a count of how many zeroes to expand. One zero is encoded with 0x00 0x01, two zeroes is 0x00 0x02, three zeroes is 0x00 0x03, etc. The first four bytes are copied directly to the output buffer.
public static ZeroDecode ( byte src, int srclen, byte dest ) : int
src byte The byte array to decode
srclen int The length of the byte array to decode. This /// would be the length of the packet up to (but not including) any /// appended ACKs
dest byte The output byte array to decode to
return int

ZeroEncode() public static method

Encode a byte array with zerocoding. Used to compress packets marked with the zerocoded flag. Any zeroes in the array are compressed down to a single zero byte followed by a count of how many zeroes to expand out. A single zero becomes 0x00 0x01, two zeroes becomes 0x00 0x02, three zeroes becomes 0x00 0x03, etc. The first four bytes are copied directly to the output buffer.
public static ZeroEncode ( byte src, int srclen, byte dest ) : int
src byte The byte array to encode
srclen int The length of the byte array to encode
dest byte The output byte array to encode to
return int