/// <summary> /// Adds an image to this baking texture and potentially processes it, or /// stores it for processing later /// </summary> /// <param name="index">The baking texture index of the image to be added</param> /// <param name="texture">JPEG2000 compressed image to be /// added to the baking texture</param> /// <param name="needsDecode">True if <code>Decode()</code> needs to be /// called for the texture, otherwise false</param> /// <returns>True if this texture is completely baked and JPEG2000 data /// is available, otherwise false</returns> public bool AddTexture(AppearanceManager.TextureIndex index, AssetTexture texture, bool needsDecode) { lock (_textures) { if (needsDecode) { try { texture.Decode(); } catch (Exception e) { Logger.Log(String.Format("AddTexture({0}, {1})", index, texture.AssetID), Helpers.LogLevel.Error, e); return(false); } } _textures.Add(index, texture); Logger.DebugLog(String.Format("Added texture {0} (ID: {1}) to bake {2}", index, texture.AssetID, _bakeType), _client); } if (_textures.Count >= _textureCount) { Bake(); return(true); } else { return(false); } }
public static AppearanceManager.BakeType BakeTypeFor(AppearanceManager.TextureIndex index) { switch (index) { case AppearanceManager.TextureIndex.HeadBodypaint: return(AppearanceManager.BakeType.Head); case AppearanceManager.TextureIndex.UpperBodypaint: case AppearanceManager.TextureIndex.UpperGloves: case AppearanceManager.TextureIndex.UpperUndershirt: case AppearanceManager.TextureIndex.UpperShirt: case AppearanceManager.TextureIndex.UpperJacket: return(AppearanceManager.BakeType.UpperBody); case AppearanceManager.TextureIndex.LowerBodypaint: case AppearanceManager.TextureIndex.LowerUnderpants: case AppearanceManager.TextureIndex.LowerSocks: case AppearanceManager.TextureIndex.LowerShoes: case AppearanceManager.TextureIndex.LowerPants: case AppearanceManager.TextureIndex.LowerJacket: return(AppearanceManager.BakeType.LowerBody); case AppearanceManager.TextureIndex.EyesIris: return(AppearanceManager.BakeType.Eyes); case AppearanceManager.TextureIndex.Skirt: return(AppearanceManager.BakeType.Skirt); default: return(AppearanceManager.BakeType.Unknown); } }
void AgentSetAppearanceHandler(Packet packet, Agent agent) { AgentSetAppearancePacket set = (AgentSetAppearancePacket)packet; Logger.DebugLog("Updating avatar appearance"); //TODO: Store this for cached bake responses for (int i = 0; i < set.WearableData.Length; i++) { AppearanceManager.TextureIndex index = (AppearanceManager.TextureIndex)set.WearableData[i].TextureIndex; UUID cacheID = set.WearableData[i].CacheID; Logger.DebugLog(String.Format("WearableData: {0} is now {1}", index, cacheID)); } // Create a TextureEntry Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(set.ObjectData.TextureEntry, 0, set.ObjectData.TextureEntry.Length); // Create a block of VisualParams byte[] visualParams = new byte[set.VisualParam.Length]; for (int i = 0; i < set.VisualParam.Length; i++) { visualParams[i] = set.VisualParam[i].ParamValue; } server.Scene.AvatarAppearance(this, agent, textureEntry, visualParams); }
void Objects_OnNewAvatar(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation) { if (enabled) { // Search this avatar for textures for (int i = 0; i < avatar.Textures.FaceTextures.Length; i++) { Primitive.TextureEntryFace face = avatar.Textures.FaceTextures[i]; if (face != null) { if (!alreadyRequested.ContainsKey(face.TextureID)) { alreadyRequested[face.TextureID] = face.TextureID; // Determine if this is a baked outfit texture or a normal texture ImageType type = ImageType.Normal; AppearanceManager.TextureIndex index = (AppearanceManager.TextureIndex)i; switch (index) { case AppearanceManager.TextureIndex.EyesBaked: case AppearanceManager.TextureIndex.HeadBaked: case AppearanceManager.TextureIndex.LowerBaked: case AppearanceManager.TextureIndex.SkirtBaked: case AppearanceManager.TextureIndex.UpperBaked: type = ImageType.Baked; break; } Client.Assets.RequestImage(face.TextureID, type); } } } } }
public bool MissingTexture(AppearanceManager.TextureIndex index) { Logger.DebugLog(String.Format("Missing texture {0} in bake {1}", index, _bakeType), _client); _textureCount--; if (_textures.Count >= _textureCount) { Bake(); return(true); } else { return(false); } }
public bool MissingTexture(AppearanceManager.TextureIndex index) { Client.DebugLog("Missing texture " + index.ToString() + " in bake " + BakeType.ToString()); TextureCount--; if (Textures.Count == TextureCount) { Bake(); return(true); } else { return(false); } }
private bool DrawLayer(AppearanceManager.TextureIndex textureIndex) { AssetTexture texture; bool useSourceAlpha = (textureIndex == AppearanceManager.TextureIndex.HeadBodypaint || textureIndex == AppearanceManager.TextureIndex.Skirt); if (_textures.TryGetValue(textureIndex, out texture)) { return(DrawLayer(texture.Image, useSourceAlpha)); } else { return(false); } }
/// <summary> /// Adds an image to this baking texture and potentially processes it, or /// stores it for processing later /// </summary> /// <param name="index">The baking texture index of the image to be added</param> /// <param name="jp2data">JPEG2000 compressed image to be added to the /// baking texture</param> /// <returns>True if this texture is completely baked and JPEG2000 data /// is available, otherwise false</returns> public bool AddTexture(AppearanceManager.TextureIndex index, AssetTexture texture) { lock (Textures) { texture.Decode(); Textures.Add(index, texture); Client.DebugLog("Adding texture " + index.ToString() + " to bake " + BakeType.ToString()); } if (Textures.Count == TextureCount) { Bake(); return(true); } else { return(false); } }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2) { return("Usage: avatarinfo [firstname] [lastname]"); } string targetName = String.Format("{0} {1}", args[0], args[1]); Avatar foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find( delegate(Avatar avatar) { return(avatar.Name == targetName); } ); if (foundAv != null) { StringBuilder output = new StringBuilder(); output.AppendFormat("{0} ({1})", targetName, foundAv.ID); output.AppendLine(); for (int i = 0; i < foundAv.Textures.FaceTextures.Length; i++) { if (foundAv.Textures.FaceTextures[i] != null) { Primitive.TextureEntryFace face = foundAv.Textures.FaceTextures[i]; AppearanceManager.TextureIndex type = (AppearanceManager.TextureIndex)i; output.AppendFormat("{0}: {1}", type, face.TextureID); output.AppendLine(); } } return(output.ToString()); } else { return("No nearby avatar with the name " + targetName); } }
private bool DrawLayer(AppearanceManager.TextureIndex textureIndex) { AssetTexture texture; ManagedImage source; bool sourceHasAlpha; bool sourceHasBump; bool copySourceAlphaToBakedLayer; int i = 0; try { if (!_textures.TryGetValue(textureIndex, out texture)) { return(false); } source = texture.Image; sourceHasAlpha = ((source.Channels & ManagedImage.ImageChannels.Alpha) != 0 && source.Alpha != null); sourceHasBump = ((source.Channels & ManagedImage.ImageChannels.Bump) != 0 && source.Bump != null); copySourceAlphaToBakedLayer = sourceHasAlpha && ( textureIndex == AppearanceManager.TextureIndex.HeadBodypaint || textureIndex == AppearanceManager.TextureIndex.Skirt ); if (source.Width != _bakeWidth || source.Height != _bakeHeight) { source.ResizeNearestNeighbor(_bakeWidth, _bakeHeight); } } catch { return(false); } int alpha = 255; //int alphaInv = 255 - alpha; int alphaInv = 256 - alpha; byte[] bakedRed = _bakedTexture.Image.Red; byte[] bakedGreen = _bakedTexture.Image.Green; byte[] bakedBlue = _bakedTexture.Image.Blue; byte[] bakedAlpha = _bakedTexture.Image.Alpha; byte[] bakedBump = _bakedTexture.Image.Bump; byte[] sourceRed = source.Red; byte[] sourceGreen = source.Green; byte[] sourceBlue = source.Blue; byte[] sourceAlpha = null; byte[] sourceBump = null; if (sourceHasAlpha) { sourceAlpha = source.Alpha; } if (sourceHasBump) { sourceBump = source.Bump; } for (int y = 0; y < _bakeHeight; y++) { for (int x = 0; x < _bakeWidth; x++) { if (sourceHasAlpha) { alpha = sourceAlpha[i]; //alphaInv = 255 - alpha; alphaInv = 256 - alpha; } bakedRed[i] = (byte)((bakedRed[i] * alphaInv + sourceRed[i] * alpha) >> 8); bakedGreen[i] = (byte)((bakedGreen[i] * alphaInv + sourceGreen[i] * alpha) >> 8); bakedBlue[i] = (byte)((bakedBlue[i] * alphaInv + sourceBlue[i] * alpha) >> 8); if (copySourceAlphaToBakedLayer) { bakedAlpha[i] = sourceAlpha[i]; } if (sourceHasBump) { bakedBump[i] = sourceBump[i]; } i++; } } return(true); }
public override bool Decode() { int version = -1; Permissions = new Permissions(); string data = Helpers.FieldToUTF8String(AssetData); string[] lines = data.Split('\n'); for (int stri = 0; stri < lines.Length; stri++) { if (stri == 0) { string versionstring = lines[stri]; version = Int32.Parse(versionstring.Split(' ')[2]); if (version != 22 && version != 18) { return(false); } } else if (stri == 1) { Name = lines[stri]; } else if (stri == 2) { Description = lines[stri]; } else { string line = lines[stri].Trim(); string[] fields = line.Split('\t'); if (fields.Length == 1) { fields = line.Split(' '); if (fields[0] == "parameters") { int count = Int32.Parse(fields[1]) + stri; for (; stri < count;) { stri++; line = lines[stri].Trim(); fields = line.Split(' '); int id = Int32.Parse(fields[0]); if (fields[1] == ",") { fields[1] = "0"; } else { fields[1] = fields[1].Replace(',', '.'); } float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float, Helpers.EnUsCulture.NumberFormat); Params[id] = weight; } } else if (fields[0] == "textures") { int count = Int32.Parse(fields[1]) + stri; for (; stri < count;) { stri++; line = lines[stri].Trim(); fields = line.Split(' '); AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]); LLUUID texture = new LLUUID(fields[1]); Textures[id] = texture; } } else if (fields[0] == "type") { WearableType = (WearableType)Int32.Parse(fields[1]); } } else if (fields.Length == 2) { switch (fields[0]) { case "creator_mask": // Deprecated, apply this as the base mask Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "base_mask": Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "owner_mask": Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "group_mask": Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "everyone_mask": Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "next_owner_mask": Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber); break; case "creator_id": Creator = new LLUUID(fields[1]); break; case "owner_id": Owner = new LLUUID(fields[1]); break; case "last_owner_id": LastOwner = new LLUUID(fields[1]); break; case "group_id": Group = new LLUUID(fields[1]); break; case "group_owned": GroupOwned = (Int32.Parse(fields[1]) != 0); break; case "sale_type": ForSale = InventoryManager.StringToSaleType(fields[1]); break; case "sale_price": SalePrice = Int32.Parse(fields[1]); break; case "sale_info": // Container for sale_type and sale_price, ignore break; default: return(false); } } } } return(true); }