public AddNewParticleSystem ( |
||
pSystem | ||
return | void |
private void SetParticleSystem(SceneObjectPart part, LSL_List rules, string originFunc) { if (rules.Length == 0) { part.RemoveParticleSystem(); part.ParentGroup.HasGroupChanged = true; } else { Primitive.ParticleSystem prules = getNewParticleSystemWithSLDefaultValues(); LSL_Vector tempv = new LSL_Vector(); float tempf = 0; int tmpi = 0; for (int i = 0; i < rules.Length; i += 2) { int psystype; try { psystype = rules.GetLSLIntegerItem(i); } catch (InvalidCastException) { Error(originFunc, string.Format("Error running particle system params index #{0}: particle system parameter type must be integer", i)); return; } switch (psystype) { case (int)ScriptBaseClass.PSYS_PART_FLAGS: try { prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)(uint)rules.GetLSLIntegerItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_FLAGS: arg #{0} - parameter 1 must be integer", i + 1)); return; } break; case (int)ScriptBaseClass.PSYS_PART_START_COLOR: try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_START_COLOR: arg #{0} - parameter 1 must be vector", i + 1)); return; } 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: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_START_ALPHA: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.PartStartColor.A = tempf; break; case (int)ScriptBaseClass.PSYS_PART_END_COLOR: try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_END_COLOR: arg #{0} - parameter 1 must be vector", i + 1)); return; } 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: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_END_ALPHA: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.PartEndColor.A = tempf; break; case (int)ScriptBaseClass.PSYS_PART_START_SCALE: try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_START_SCALE: arg #{0} - parameter 1 must be vector", i + 1)); return; } prules.PartStartScaleX = validParticleScale((float)tempv.x); prules.PartStartScaleY = validParticleScale((float)tempv.y); break; case (int)ScriptBaseClass.PSYS_PART_END_SCALE: try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_END_SCALE: arg #{0} - parameter 1 must be vector", i + 1)); return; } prules.PartEndScaleX = validParticleScale((float)tempv.x); prules.PartEndScaleY = validParticleScale((float)tempv.y); break; case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_MAX_AGE: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.PartMaxAge = tempf; break; case (int)ScriptBaseClass.PSYS_SRC_ACCEL: try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_ACCEL: arg #{0} - parameter 1 must be vector", i + 1)); return; } 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: try { tmpi = (int)rules.GetLSLIntegerItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_PATTERN: arg #{0} - parameter 1 must be integer", i + 1)); return; } prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; break; // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The // client tells the difference between the two by looking at the 0x02 bit in // the PartFlags variable. case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_INNERANGLE: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.InnerAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. break; case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_OUTERANGLE: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.OuterAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. break; case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_SOURCE: try { tmpi = (int)rules.GetLSLIntegerItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_BLEND_FUNC_SOURCE: arg #{0} - parameter 1 must be integer", i + 1)); return; } prules.BlendFuncSource = (byte)tmpi; break; case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_DEST: try { tmpi = (int)rules.GetLSLIntegerItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_BLEND_FUNC_DEST: arg #{0} - parameter 1 must be integer", i + 1)); return; } prules.BlendFuncDest = (byte)tmpi; break; case (int)ScriptBaseClass.PSYS_PART_START_GLOW: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_START_GLOW: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.PartStartGlow = (float)tempf; break; case (int)ScriptBaseClass.PSYS_PART_END_GLOW: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_PART_END_GLOW: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.PartEndGlow = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: try { prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1)); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_TEXTURE: arg #{0} - parameter 1 must be string or key", i + 1)); return; } break; case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_BURST_RATE: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.BurstRate = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: try { prules.BurstPartCount = (byte)(int)rules.GetLSLIntegerItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_BURST_PART_COUNT: arg #{0} - parameter 1 must be integer", i + 1)); return; } break; case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_BURST_RADIUS: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.BurstRadius = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_BURST_SPEED_MIN: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.BurstSpeedMin = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_BURST_SPEED_MAX: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.BurstSpeedMax = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_MAX_AGE: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.MaxAge = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: UUID key = UUID.Zero; if (UUID.TryParse(rules.Data[i + 1].ToString(), out key)) { prules.Target = key; } else { prules.Target = part.UUID; } break; case (int)ScriptBaseClass.PSYS_SRC_OMEGA: // AL: This is an assumption, since it is the only thing that would match. try { tempv = rules.GetVector3Item(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_OMEGA: arg #{0} - parameter 1 must be vector", i + 1)); return; } prules.AngularVelocity.X = (float)tempv.x; prules.AngularVelocity.Y = (float)tempv.y; prules.AngularVelocity.Z = (float)tempv.z; break; case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch(InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_ANGLE_BEGIN: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.InnerAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. break; case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: try { tempf = (float)rules.GetLSLFloatItem(i + 1); } catch (InvalidCastException) { Error(originFunc, string.Format("Error running rule PSYS_SRC_ANGLE_END: arg #{0} - parameter 1 must be float", i + 1)); return; } prules.OuterAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. break; } } prules.CRC = 1; part.AddNewParticleSystem(prules); part.ParentGroup.HasGroupChanged = true; } part.SendFullUpdateToAllClients(); }
private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { if (rules.Length == 0) { part.RemoveParticleSystem(); part.ParentGroup.HasGroupChanged = true; } else { Primitive.ParticleSystem prules = getNewParticleSystemWithSLDefaultValues(); LSL_Vector tempv = new LSL_Vector(); float tempf = 0; for (int i = 0; i < rules.Length; i += 2) { switch (rules.GetLSLIntegerItem(i)) { case (int)ScriptBaseClass.PSYS_PART_FLAGS: prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)(uint)rules.GetLSLIntegerItem(i + 1); break; case (int)ScriptBaseClass.PSYS_PART_START_COLOR: tempv = rules.GetVector3Item(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 = (float)rules.GetLSLFloatItem(i + 1); prules.PartStartColor.A = tempf; break; case (int)ScriptBaseClass.PSYS_PART_END_COLOR: tempv = rules.GetVector3Item(i + 1); 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 = (float)rules.GetLSLFloatItem(i + 1); prules.PartEndColor.A = tempf; break; case (int)ScriptBaseClass.PSYS_PART_START_SCALE: tempv = rules.GetVector3Item(i + 1); prules.PartStartScaleX = (float)tempv.x; prules.PartStartScaleY = (float)tempv.y; break; case (int)ScriptBaseClass.PSYS_PART_END_SCALE: tempv = rules.GetVector3Item(i + 1); prules.PartEndScaleX = (float)tempv.x; prules.PartEndScaleY = (float)tempv.y; break; case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.PartMaxAge = tempf; break; case (int)ScriptBaseClass.PSYS_SRC_ACCEL: tempv = rules.GetVector3Item(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)rules.GetLSLIntegerItem(i + 1); prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; break; // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The // client tells the difference between the two by looking at the 0x02 bit in // the PartFlags variable. case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.InnerAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. break; case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.OuterAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. break; case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); break; case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstRate = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: prules.BurstPartCount = (byte)(int)rules.GetLSLIntegerItem(i + 1); break; case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstRadius = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstSpeedMin = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstSpeedMax = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.MaxAge = (float)tempf; break; case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: UUID key = UUID.Zero; if (UUID.TryParse(rules.Data[i + 1].ToString(), out key)) { prules.Target = key; } else { prules.Target = part.UUID; } break; case (int)ScriptBaseClass.PSYS_SRC_OMEGA: // AL: This is an assumption, since it is the only thing that would match. tempv = rules.GetVector3Item(i + 1); prules.AngularVelocity.X = (float)tempv.x; prules.AngularVelocity.Y = (float)tempv.y; prules.AngularVelocity.Z = (float)tempv.z; break; case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.InnerAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. break; case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.OuterAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. break; } } prules.CRC = 1; part.AddNewParticleSystem(prules); part.ParentGroup.HasGroupChanged = true; } part.SendFullUpdateToAllClients(); }
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); }