From 10822a139f3fc976940bce0c39eea7e98af3a5da Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 8 Aug 2008 15:16:30 +0000 Subject: Mantis#1521. Thank you kindly, Lmmz for a patch that: Improves the implementation of the particle system. --- .../Shared/Api/Implementation/LSL_Api.cs | 254 +++++++++++---------- 1 file changed, 139 insertions(+), 115 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2a1efd4..ee10300 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4322,151 +4322,175 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return returnval; } - + private Primitive.ParticleSystem getNewParticleSystemWithSLDefaultValues() + { + Primitive.ParticleSystem ps = new Primitive.ParticleSystem(); + + // TODO find out about the other defaults and add them here + ps.PartStartColor = new LLColor(1.0f, 1.0f, 1.0f, 1.0f); + ps.PartEndColor = new LLColor(1.0f, 1.0f, 1.0f, 1.0f); + ps.PartStartScaleX = 1.0f; + ps.PartStartScaleY = 1.0f; + ps.PartEndScaleX = 1.0f; + ps.PartEndScaleY = 1.0f; + ps.BurstSpeedMin = 1.0f; + ps.BurstSpeedMax = 1.0f; + ps.BurstRate = 0.1f; + ps.PartMaxAge = 10.0f; + return ps; + } + public void llParticleSystem(LSL_Types.list rules) { m_host.AddScriptLPS(1); - Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); - LSL_Types.Vector3 tempv = new LSL_Types.Vector3(); + if(rules.Length == 0) + { + m_host.RemoveParticleSystem(); + } + else + { + Primitive.ParticleSystem prules = getNewParticleSystemWithSLDefaultValues(); + LSL_Types.Vector3 tempv = new LSL_Types.Vector3(); - float tempf = 0; + float tempf = 0; - for (int i = 0; i < rules.Length; i += 2) - { - switch ((int)rules.Data[i]) + for (int i = 0; i < rules.Length; i += 2) { - case (int)ScriptBaseClass.PSYS_PART_FLAGS: - prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); - break; + switch ((int)rules.Data[i]) + { + case (int)ScriptBaseClass.PSYS_PART_FLAGS: + prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); + break; - case (int)ScriptBaseClass.PSYS_PART_START_COLOR: - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - prules.PartStartColor.R = (float)tempv.x; - prules.PartStartColor.G = (float)tempv.y; - prules.PartStartColor.B = (float)tempv.z; - break; + case (int)ScriptBaseClass.PSYS_PART_START_COLOR: + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + prules.PartStartColor.R = (float)tempv.x; + prules.PartStartColor.G = (float)tempv.y; + prules.PartStartColor.B = (float)tempv.z; + break; - case (int)ScriptBaseClass.PSYS_PART_START_ALPHA: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.PartStartColor.A = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_PART_START_ALPHA: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.PartStartColor.A = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_PART_END_COLOR: - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1); + case (int)ScriptBaseClass.PSYS_PART_END_COLOR: + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1); - prules.PartEndColor.R = (float)tempv.x; - prules.PartEndColor.G = (float)tempv.y; - prules.PartEndColor.B = (float)tempv.z; - break; + prules.PartEndColor.R = (float)tempv.x; + prules.PartEndColor.G = (float)tempv.y; + prules.PartEndColor.B = (float)tempv.z; + break; - case (int)ScriptBaseClass.PSYS_PART_END_ALPHA: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.PartEndColor.A = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_PART_END_ALPHA: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.PartEndColor.A = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_PART_START_SCALE: - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - prules.PartStartScaleX = (float)tempv.x; - prules.PartStartScaleY = (float)tempv.y; - break; + case (int)ScriptBaseClass.PSYS_PART_START_SCALE: + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + prules.PartStartScaleX = (float)tempv.x; + prules.PartStartScaleY = (float)tempv.y; + break; - case (int)ScriptBaseClass.PSYS_PART_END_SCALE: - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - prules.PartEndScaleX = (float)tempv.x; - prules.PartEndScaleY = (float)tempv.y; - break; + case (int)ScriptBaseClass.PSYS_PART_END_SCALE: + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + prules.PartEndScaleX = (float)tempv.x; + prules.PartEndScaleY = (float)tempv.y; + break; - case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.PartMaxAge = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.PartMaxAge = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_ACCEL: - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - prules.PartAcceleration.X = (float)tempv.x; - prules.PartAcceleration.Y = (float)tempv.y; - prules.PartAcceleration.Z = (float)tempv.z; - break; + case (int)ScriptBaseClass.PSYS_SRC_ACCEL: + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + prules.PartAcceleration.X = (float)tempv.x; + prules.PartAcceleration.Y = (float)tempv.y; + prules.PartAcceleration.Z = (float)tempv.z; + break; - case (int)ScriptBaseClass.PSYS_SRC_PATTERN: - int tmpi = int.Parse(rules.Data[i + 1].ToString()); - prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; - break; + case (int)ScriptBaseClass.PSYS_SRC_PATTERN: + int tmpi = int.Parse(rules.Data[i + 1].ToString()); + prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; + break; - // Xantor 20080503 - // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture - // "" = default texture. - // 20080530 Updated to remove code duplication - case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: - prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); - break; + // Xantor 20080503 + // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture + // "" = default texture. + // 20080530 Updated to remove code duplication + case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: + prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); + break; - case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.BurstRate = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.BurstRate = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: - prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); - break; + case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: + prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); + break; - case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.BurstRadius = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.BurstRadius = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.BurstSpeedMin = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.BurstSpeedMin = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.BurstSpeedMax = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.BurstSpeedMax = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.MaxAge = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.MaxAge = (float)tempf; + break; - case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: - LLUUID key = LLUUID.Zero; - if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key)) - { - prules.Target = key; - } - else - { - prules.Target = m_host.UUID; - } - break; + case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: + LLUUID key = LLUUID.Zero; + if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key)) + { + prules.Target = key; + } + else + { + prules.Target = m_host.UUID; + } + break; - case (int)ScriptBaseClass.PSYS_SRC_OMEGA: - // AL: This is an assumption, since it is the only thing that would match. - tempv = (LSL_Types.Vector3)rules.Data[i + 1]; - prules.AngularVelocity.X = (float)tempv.x; - prules.AngularVelocity.Y = (float)tempv.y; - prules.AngularVelocity.Z = (float)tempv.z; - //cast?? prules.MaxAge = (float)rules[i + 1]; - break; + case (int)ScriptBaseClass.PSYS_SRC_OMEGA: + // AL: This is an assumption, since it is the only thing that would match. + tempv = (LSL_Types.Vector3)rules.Data[i + 1]; + prules.AngularVelocity.X = (float)tempv.x; + prules.AngularVelocity.Y = (float)tempv.y; + prules.AngularVelocity.Z = (float)tempv.z; + //cast?? prules.MaxAge = (float)rules[i + 1]; + break; - case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.InnerAngle = (float)tempf; - break; + case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.InnerAngle = (float)tempf; + break; + + case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: + tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); + prules.OuterAngle = (float)tempf; + break; + } - case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: - tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); - prules.OuterAngle = (float)tempf; - break; } + prules.CRC = 1; + m_host.AddNewParticleSystem(prules); } - prules.CRC = 1; - - m_host.AddNewParticleSystem(prules); m_host.SendFullUpdateToAllClients(); } -- cgit v1.1