public static TextureEntry FromLLSD(LLSD llsd) { LLSDArray array = (LLSDArray)llsd; LLSDMap faceLLSD; if (array.Count > 0) { int faceNumber; faceLLSD = (LLSDMap)array[0]; TextureEntryFace defaultFace = TextureEntryFace.FromLLSD(faceLLSD, null, out faceNumber); TextureEntry te = new TextureEntry(defaultFace); for (int i = 1; i < array.Count; i++) { TextureEntryFace tex = TextureEntryFace.FromLLSD(array[i], defaultFace, out faceNumber); if (faceNumber >= 0 && faceNumber < te.FaceTextures.Length) { te.FaceTextures[faceNumber] = tex; } } return(te); } else { throw new ArgumentException("LLSD contains no elements"); } }
/// <summary> /// /// </summary> /// <param name="texture"></param> public PrimObject(SecondLife client, LLUUID texture) { Client = client; PCode = PCode.Prim; Textures = new TextureEntry(); Textures.DefaultTexture.TextureID = texture; }
public static TextureEntry FromLLSD(LLSD llsd) { LLSDArray array = (LLSDArray)llsd; LLSDMap faceLLSD; if (array.Count > 0) { int faceNumber; faceLLSD = (LLSDMap)array[0]; TextureEntryFace defaultFace = TextureEntryFace.FromLLSD(faceLLSD, null, out faceNumber); TextureEntry te = new TextureEntry(defaultFace); for (int i = 1; i < array.Count; i++) { TextureEntryFace tex = TextureEntryFace.FromLLSD(array[i], defaultFace, out faceNumber); if (faceNumber >= 0 && faceNumber < te.FaceTextures.Length) te.FaceTextures[faceNumber] = tex; } return te; } else { throw new ArgumentException("LLSD contains no elements"); } }
/// <summary> /// /// </summary> public PrimObject(SecondLife client) { Client = client; PCode = PCode.Prim; Textures = new TextureEntry(); }
/// <summary> /// /// </summary> /// <param name="simulator"></param> /// <param name="localID"></param> /// <param name="textures"></param> /// <param name="mediaUrl"></param> public void SetTextures(Simulator simulator, uint localID, TextureEntry textures, string mediaUrl) { ObjectImagePacket image = new ObjectImagePacket(); image.AgentData.AgentID = Client.Network.AgentID; image.AgentData.SessionID = Client.Network.SessionID; image.ObjectData = new ObjectImagePacket.ObjectDataBlock[1]; image.ObjectData[0] = new ObjectImagePacket.ObjectDataBlock(); image.ObjectData[0].ObjectLocalID = localID; image.ObjectData[0].TextureEntry = textures.ToBytes(); image.ObjectData[0].MediaURL = Helpers.StringToField(mediaUrl); Client.Network.SendPacket(image, simulator); }
/// <summary> /// /// </summary> /// <param name="simulator"></param> /// <param name="localID"></param> /// <param name="textures"></param> public void SetTextures(Simulator simulator, uint localID, TextureEntry textures) { SetTextures(simulator, localID, textures, String.Empty); }
public static Primitive FromLLSD(LLSD llsd) { Primitive prim = new Primitive(); LLObject.ObjectData data = new ObjectData(); LLSDMap map = (LLSDMap)llsd; LLSDMap volume = (LLSDMap)map["volume"]; LLSDMap path = (LLSDMap)volume["path"]; LLSDMap profile = (LLSDMap)volume["profile"]; #region Path/Profile data.PathBegin = (float)path["begin"].AsReal(); data.PathCurve = (PathCurve)path["curve"].AsInteger(); data.PathEnd = (float)path["end"].AsReal(); data.PathRadiusOffset = (float)path["radius_offset"].AsReal(); data.PathRevolutions = (float)path["revolutions"].AsReal(); data.PathScaleX = (float)path["scale_x"].AsReal(); data.PathScaleY = (float)path["scale_y"].AsReal(); data.PathShearX = (float)path["shear_x"].AsReal(); data.PathShearY = (float)path["shear_y"].AsReal(); data.PathSkew = (float)path["skew"].AsReal(); data.PathTaperX = (float)path["taper_x"].AsReal(); data.PathTaperY = (float)path["taper_y"].AsReal(); data.PathTwist = (float)path["twist"].AsReal(); data.PathTwistBegin = (float)path["twist_begin"].AsReal(); data.ProfileBegin = (float)profile["begin"].AsReal(); data.ProfileCurve = (ProfileCurve)profile["curve"].AsInteger(); data.ProfileHole = (HoleType)profile["hole"].AsInteger(); data.ProfileEnd = (float)profile["end"].AsReal(); data.ProfileHollow = (float)profile["hollow"].AsReal(); #endregion Path/Profile prim.Data = data; if (map["phantom"].AsBoolean()) { prim.Flags |= ObjectFlags.Phantom; } if (map["physical"].AsBoolean()) { prim.Flags |= ObjectFlags.Physics; } if (map["shadows"].AsBoolean()) { prim.Flags |= ObjectFlags.CastShadows; } prim.ParentID = (uint)map["parentid"].AsInteger(); prim.Position.FromLLSD(map["position"]); prim.Rotation.FromLLSD(map["rotation"]); prim.Scale.FromLLSD(map["scale"]); prim.Data.Material = (MaterialType)map["material"].AsInteger(); prim.Flexible = FlexibleData.FromLLSD(map["flex"]); prim.Light = LightData.FromLLSD(map["light"]); prim.Sculpt = SculptData.FromLLSD(map["sculpt"]); prim.Textures = TextureEntry.FromLLSD(map["textures"]); if (!string.IsNullOrEmpty(map["name"].AsString())) { prim.Properties.Name = map["name"].AsString(); } if (!string.IsNullOrEmpty(map["description"].AsString())) { prim.Properties.Description = map["description"].AsString(); } return(prim); }
public void GetAvatarAppearanceInfoFromWearableAssets() { AgentWearablesUpdatePacket.WearableDataBlock[] wdbs = GetWearables(); foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in wdbs) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AManager.GetInventoryAsset(wearableAsset); if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } try { foreach (KeyValuePair<uint, LLUUID> texture in wearableAsset.Textures) { AgentTextureEntry.CreateFace(texture.Key).TextureID = texture.Value; } foreach (KeyValuePair<uint, float> kvp in wearableAsset.Parameters) { AgentAppearanceParams[kvp.Key] = kvp.Value; } } catch (Exception e) { Client.Log("ItemID: " + wdb.ItemID + Environment.NewLine + "WearableType: " + wdb.WearableType + Environment.NewLine + "Retrieving as type: " + wearableAsset.Type + Environment.NewLine + e.ToString() + Environment.NewLine + wearableAsset.AssetDataToString(), Helpers.LogLevel.Error); } } // Correct the order of the textures foreach (uint faceid in AgentTextureEntry.FaceTextures.Keys) { switch (faceid) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 12: case 13: case 14: case 15: case 16: case 17: case 18: break; default: Client.Log("Unknown order for FaceID: " + faceid + Environment.NewLine + "Your wearables define a face that we don't know the order of. Please " + "capture a AgentSetAppearance packet for your current outfit and submit to " + "[email protected], thanks!", Helpers.LogLevel.Info); break; } } //Re-order texture faces to match Linden Labs internal data structure. TextureEntry te2 = new TextureEntry(AgentTextureEntry.DefaultTexture.TextureID); te2.CreateFace(18).TextureID = AgentTextureEntry.GetFace(18).TextureID; te2.CreateFace(17).TextureID = AgentTextureEntry.GetFace(17).TextureID; te2.CreateFace(16).TextureID = AgentTextureEntry.GetFace(16).TextureID; te2.CreateFace(15).TextureID = AgentTextureEntry.GetFace(15).TextureID; te2.CreateFace(14).TextureID = AgentTextureEntry.GetFace(14).TextureID; te2.CreateFace(13).TextureID = AgentTextureEntry.GetFace(13).TextureID; te2.CreateFace(12).TextureID = AgentTextureEntry.GetFace(12).TextureID; // I wonder if shoes are somewhere in here? te2.CreateFace(7).TextureID = AgentTextureEntry.GetFace(7).TextureID; te2.CreateFace(6).TextureID = AgentTextureEntry.GetFace(6).TextureID; te2.CreateFace(5).TextureID = AgentTextureEntry.GetFace(5).TextureID; te2.CreateFace(4).TextureID = AgentTextureEntry.GetFace(4).TextureID; te2.CreateFace(3).TextureID = AgentTextureEntry.GetFace(3).TextureID; te2.CreateFace(2).TextureID = AgentTextureEntry.GetFace(2).TextureID; te2.CreateFace(1).TextureID = AgentTextureEntry.GetFace(1).TextureID; te2.CreateFace(0).TextureID = AgentTextureEntry.GetFace(0).TextureID; AgentTextureEntry = te2; }