private static Primitive.ParticleSystem FromPrimObjectParticles(PrimObject.ParticlesBlock objParticles) { Primitive.ParticleSystem particles = new Primitive.ParticleSystem(); if (objParticles == null) { return(particles); } particles.PartAcceleration = objParticles.Acceleration; particles.AngularVelocity = objParticles.AngularVelocity; particles.BurstPartCount = (byte)objParticles.BurstParticleCount; particles.BurstRadius = objParticles.BurstRadius; particles.BurstRate = objParticles.BurstRate; particles.BurstSpeedMax = objParticles.BurstSpeedMax; particles.BurstSpeedMin = objParticles.BurstSpeedMin; particles.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)objParticles.DataFlags; particles.PartFlags = (uint)objParticles.Flags; particles.InnerAngle = objParticles.InnerAngle; particles.MaxAge = objParticles.MaxAge; particles.OuterAngle = objParticles.OuterAngle; particles.PartEndColor = objParticles.ParticleEndColor; particles.PartEndScaleX = objParticles.ParticleEndScale.X; particles.PartEndScaleY = objParticles.ParticleEndScale.Y; particles.PartMaxAge = objParticles.ParticleMaxAge; particles.PartStartColor = objParticles.ParticleStartColor; particles.PartStartScaleX = objParticles.ParticleStartScale.X; particles.PartStartScaleY = objParticles.ParticleStartScale.Y; particles.Pattern = (Primitive.ParticleSystem.SourcePattern)objParticles.Pattern; particles.StartAge = objParticles.StartAge; particles.Target = objParticles.TargetID; particles.Texture = objParticles.TextureID; return(particles); }
public void SetAura(SceneObjectPart From, Vector3 color, float radius, float burstRadius, float age, float burstRate, Primitive.ParticleSystem.SourcePattern patternFlags) { Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive | // Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam | // Primitive.ParticleSystem.ParticleDataFlags.TargetPos; prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR prules.PartStartColor.G = color.Y; prules.PartStartColor.B = color.Z; prules.PartStartColor.A = 0.5f; //PSYS_PART_START_ALPHA, transparency prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR prules.PartEndColor.G = color.Y; prules.PartEndColor.B = color.Z; prules.PartEndColor.A = 0.5f; //PSYS_PART_END_ALPHA, transparency /*prules.PartStartScaleX = 0.5f; //PSYS_PART_START_SCALE * prules.PartStartScaleY = 0.5f; * prules.PartEndScaleX = 0.5f; //PSYS_PART_END_SCALE * prules.PartEndScaleY = 0.5f; */ prules.PartStartScaleX = radius; //PSYS_PART_START_SCALE prules.PartStartScaleY = radius; prules.PartEndScaleX = radius; //PSYS_PART_END_SCALE prules.PartEndScaleY = radius; prules.PartMaxAge = age; //PSYS_PART_MAX_AGE prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL prules.PartAcceleration.Y = 0.0f; prules.PartAcceleration.Z = 0.0f; prules.Pattern = patternFlags; //PSYS_SRC_PATTERN //prules.Texture = UUID.Zero;//= UUID //PSYS_SRC_TEXTURE, default used if blank prules.BurstRate = burstRate; //PSYS_SRC_BURST_RATE prules.BurstPartCount = 2; //PSYS_SRC_BURST_PART_COUNT //prules.BurstRadius = radius; //PSYS_SRC_BURST_RADIUS prules.BurstRadius = burstRadius; //PSYS_SRC_BURST_RADIUS prules.BurstSpeedMin = 0.001f; //PSYS_SRC_BURST_SPEED_MIN prules.BurstSpeedMax = 0.001f; //PSYS_SRC_BURST_SPEED_MAX prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE //prules.Target = To; //PSYS_SRC_TARGET_KEY prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA prules.AngularVelocity.Y = 0.0f; prules.AngularVelocity.Z = 0.0f; prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END prules.CRC = 1; //activates the particle system?? From.AddNewParticleSystem(prules); }
private static string DecodeObjectParticleSystem(string fieldName, object fieldData) { StringBuilder result = new StringBuilder(); Primitive.ParticleSystem ParticleSys; if (fieldData is Primitive.ParticleSystem) ParticleSys = (Primitive.ParticleSystem)fieldData; else ParticleSys = new Primitive.ParticleSystem((byte[])fieldData, 0); result.AppendFormat("{0,30}", "<ParticleSystem>" + Environment.NewLine); GenericTypeDecoder(ParticleSys, ref result); result.AppendFormat("{0,30}", "</ParticleSystem>"); return result.ToString(); }
private static string DecodeObjectCompressedData(string fieldName, object fieldData) { StringBuilder result = new StringBuilder(); byte[] block = (byte[])fieldData; int i = 0; // UUID result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ID", new UUID(block, 0), "UUID"); i += 16; // Local ID uint LocalID = (uint)(block[i++] + (block[i++] << 8) + (block[i++] << 16) + (block[i++] << 24)); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "LocalID", LocalID, "Uint32"); // PCode PCode pcode = (PCode)block[i++]; result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine, "PCode", (int)pcode, "(" + pcode + ")", "PCode"); // State AttachmentPoint point = (AttachmentPoint)block[i++]; result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine, "State", (byte)point, "(" + point + ")", "AttachmentPoint"); // TODO: CRC i += 4; // Material result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine, "Material", block[i], "(" + (Material)block[i++] + ")", "Material"); // Click action result.AppendFormat("{0,30}: {1,-3} {2,-36} [{3}]" + Environment.NewLine, "ClickAction", block[i], "(" + (ClickAction)block[i++] + ")", "ClickAction"); // Scale result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "Scale", new Vector3(block, i), "Vector3"); i += 12; // Position result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "Position", new Vector3(block, i), "Vector3"); i += 12; // Rotation result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "Rotation", new Vector3(block, i), "Vector3"); i += 12; // Compressed flags CompressedFlags flags = (CompressedFlags)Utils.BytesToUInt(block, i); result.AppendFormat("{0,30}: {1,-10} {2,-29} [{3}]" + Environment.NewLine, "CompressedFlags", Utils.BytesToUInt(block, i), "(" + (CompressedFlags)Utils.BytesToUInt(block, i) + ")", "UInt"); i += 4; // Owners ID result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "OwnerID", new UUID(block, i), "UUID"); i += 16; // Angular velocity if ((flags & CompressedFlags.HasAngularVelocity) != 0) { result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "AngularVelocity", new Vector3(block, i), "Vector3"); i += 12; } // Parent ID if ((flags & CompressedFlags.HasParent) != 0) { result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ParentID", (uint)(block[i++] + (block[i++] << 8) + (block[i++] << 16) + (block[i++] << 24)), "UInt"); } // Tree data if ((flags & CompressedFlags.Tree) != 0) { result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine, "TreeSpecies", block[i++], "(" + (Tree)block[i] + ")", "Tree"); } // Scratch pad else if ((flags & CompressedFlags.ScratchPad) != 0) { int size = block[i++]; byte[] scratch = new byte[size]; Buffer.BlockCopy(block, i, scratch, 0, size); result.AppendFormat("{0,30}: {1,-40} [ScratchPad[]]" + Environment.NewLine, "ScratchPad", Utils.BytesToHexString(scratch, String.Format("{0,30}", "Data"))); i += size; } // Floating text if ((flags & CompressedFlags.HasText) != 0) { string text = String.Empty; while (block[i] != 0) { text += (char)block[i]; i++; } i++; // Floating text result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "Text", text, "string"); // Text color result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "TextColor", new Color4(block, i, false), "Color4"); i += 4; } // Media URL if ((flags & CompressedFlags.MediaURL) != 0) { string text = String.Empty; while (block[i] != 0) { text += (char)block[i]; i++; } i++; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "MediaURL", text, "string"); } // Particle system if ((flags & CompressedFlags.HasParticles) != 0) { Primitive.ParticleSystem p = new Primitive.ParticleSystem(block, i); result.AppendLine(DecodeObjectParticleSystem("ParticleSystem", p)); i += 86; } // Extra parameters TODO: Primitive prim = new Primitive(); i += prim.SetExtraParamsFromBytes(block, i); //Sound data if ((flags & CompressedFlags.HasSound) != 0) { result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "SoundID", new UUID(block, i), "UUID"); i += 16; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "SoundGain", Utils.BytesToFloat(block, i), "Float"); i += 4; result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine, "SoundFlags", block[i++], "(" + (SoundFlags)block[i] + ")", "SoundFlags"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "SoundRadius", Utils.BytesToFloat(block, i), "Float"); i += 4; } // Name values if ((flags & CompressedFlags.HasNameValues) != 0) { string text = String.Empty; while (block[i] != 0) { text += (char)block[i]; i++; } i++; // Parse the name values if (text.Length > 0) { string[] lines = text.Split('\n'); NameValue[] nameValues = new NameValue[lines.Length]; for (int j = 0; j < lines.Length; j++) { if (!String.IsNullOrEmpty(lines[j])) { NameValue nv = new NameValue(lines[j]); nameValues[j] = nv; } } DecodeNameValue("NameValues", nameValues); } } result.AppendFormat("{0,30}: {1,-2} {2,-37} [{3}]" + Environment.NewLine, "PathCurve", block[i], "(" + (PathCurve)block[i++] + ")", "PathCurve"); ushort pathBegin = Utils.BytesToUInt16(block, i); i += 2; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathBegin", Primitive.UnpackBeginCut(pathBegin), "float"); ushort pathEnd = Utils.BytesToUInt16(block, i); i += 2; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathEnd", Primitive.UnpackEndCut(pathEnd), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathScaleX", Primitive.UnpackPathScale(block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathScaleY", Primitive.UnpackPathScale(block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathShearX", Primitive.UnpackPathShear((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathShearY", Primitive.UnpackPathShear((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathTwist", Primitive.UnpackPathTwist((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathTwistBegin", Primitive.UnpackPathTwist((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathRadiusOffset", Primitive.UnpackPathTwist((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathTaperX", Primitive.UnpackPathTaper((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathTaperY", Primitive.UnpackPathTaper((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathRevolutions", Primitive.UnpackPathRevolutions(block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "PathSkew", Primitive.UnpackPathTwist((sbyte)block[i++]), "float"); result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ProfileCurve", block[i++], "float"); ushort profileBegin = Utils.BytesToUInt16(block, i); i += 2; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ProfileBegin", Primitive.UnpackBeginCut(profileBegin), "float"); ushort profileEnd = Utils.BytesToUInt16(block, i); i += 2; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ProfileEnd", Primitive.UnpackEndCut(profileEnd), "float"); ushort profileHollow = Utils.BytesToUInt16(block, i); i += 2; result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine, "ProfileHollow", Primitive.UnpackProfileHollow(profileHollow), "float"); int textureEntryLength = (int)Utils.BytesToUInt(block, i); i += 4; //prim.Textures = new Primitive.TextureEntry(block, i, textureEntryLength); String s = DecodeTextureEntry("TextureEntry", new Primitive.TextureEntry(block, i, textureEntryLength)); result.AppendLine(s); i += textureEntryLength; // Texture animation if ((flags & CompressedFlags.TextureAnimation) != 0) { i += 4; string a = DecodeObjectTextureAnim("TextureAnimation", new Primitive.TextureAnimation(block, i)); result.AppendLine(a); } return result.ToString(); }
/// <summary> /// Gather all the asset uuids associated with a given object. /// </summary> /// <remarks> /// This includes both those directly associated with /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained /// within this object). /// </remarks> /// <param name="sceneObject">The scene object for which to gather assets</param> public void AddForInspection(SceneObjectGroup sceneObject) { // m_log.DebugFormat( // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); SceneObjectPart[] parts = sceneObject.Parts; for (int i = 0; i < parts.Length; i++) { SceneObjectPart part = parts[i]; // m_log.DebugFormat( // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); try { Primitive.TextureEntry textureEntry = part.Shape.Textures; if (textureEntry != null) { // Get the prim's default texture. This will be used for faces which don't have their own texture if (textureEntry.DefaultTexture != null) { RecordTextureEntryAssetUuids(textureEntry.DefaultTexture); } if (textureEntry.FaceTextures != null) { // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture) foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) { if (texture != null) { RecordTextureEntryAssetUuids(texture); } } } } // If the prim is a sculpt then preserve this information too if (part.Shape.SculptTexture != UUID.Zero) { GatheredUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture; } if (part.Shape.ProjectionTextureUUID != UUID.Zero) { GatheredUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture; } if (part.CollisionSound != UUID.Zero) { GatheredUuids[part.CollisionSound] = (sbyte)AssetType.Sound; } if (part.ParticleSystem.Length > 0) { try { Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); if (ps.Texture != UUID.Zero) { GatheredUuids[ps.Texture] = (sbyte)AssetType.Texture; } } catch (Exception) { m_log.WarnFormat( "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.", part.Name, part.UUID, sceneObject.Name, sceneObject.UUID); } } TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); // Now analyze this prim's inventory items to preserve all the uuids that they reference foreach (TaskInventoryItem tii in taskDictionary.Values) { // m_log.DebugFormat( // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}", // tii.Name, tii.Type, part.Name, part.UUID); if (!GatheredUuids.ContainsKey(tii.AssetID)) { AddForInspection(tii.AssetID, (sbyte)tii.Type); } } // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and // inventory transfer. There needs to be a way for a module to register a method without assuming a // Scene.EventManager is present. // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs RecordMaterialsUuids(part); } catch (Exception e) { m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e); m_log.DebugFormat( "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)", part.Shape.TextureEntry.Length); } } }