aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorCharles Krinke2008-08-08 15:16:30 +0000
committerCharles Krinke2008-08-08 15:16:30 +0000
commit10822a139f3fc976940bce0c39eea7e98af3a5da (patch)
tree18e6a30ba757b6788446f8ead717d454c8780917 /OpenSim/Region/ScriptEngine/Shared/Api
parentPatch #9161 (diff)
downloadopensim-SC_OLD-10822a139f3fc976940bce0c39eea7e98af3a5da.zip
opensim-SC_OLD-10822a139f3fc976940bce0c39eea7e98af3a5da.tar.gz
opensim-SC_OLD-10822a139f3fc976940bce0c39eea7e98af3a5da.tar.bz2
opensim-SC_OLD-10822a139f3fc976940bce0c39eea7e98af3a5da.tar.xz
Mantis#1521. Thank you kindly, Lmmz for a patch that:
Improves the implementation of the particle system.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs254
1 files changed, 139 insertions, 115 deletions
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
4322 return returnval; 4322 return returnval;
4323 } 4323 }
4324 4324
4325 4325 private Primitive.ParticleSystem getNewParticleSystemWithSLDefaultValues()
4326 {
4327 Primitive.ParticleSystem ps = new Primitive.ParticleSystem();
4328
4329 // TODO find out about the other defaults and add them here
4330 ps.PartStartColor = new LLColor(1.0f, 1.0f, 1.0f, 1.0f);
4331 ps.PartEndColor = new LLColor(1.0f, 1.0f, 1.0f, 1.0f);
4332 ps.PartStartScaleX = 1.0f;
4333 ps.PartStartScaleY = 1.0f;
4334 ps.PartEndScaleX = 1.0f;
4335 ps.PartEndScaleY = 1.0f;
4336 ps.BurstSpeedMin = 1.0f;
4337 ps.BurstSpeedMax = 1.0f;
4338 ps.BurstRate = 0.1f;
4339 ps.PartMaxAge = 10.0f;
4340 return ps;
4341 }
4342
4326 public void llParticleSystem(LSL_Types.list rules) 4343 public void llParticleSystem(LSL_Types.list rules)
4327 { 4344 {
4328 m_host.AddScriptLPS(1); 4345 m_host.AddScriptLPS(1);
4329 Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); 4346 if(rules.Length == 0)
4330 LSL_Types.Vector3 tempv = new LSL_Types.Vector3(); 4347 {
4348 m_host.RemoveParticleSystem();
4349 }
4350 else
4351 {
4352 Primitive.ParticleSystem prules = getNewParticleSystemWithSLDefaultValues();
4353 LSL_Types.Vector3 tempv = new LSL_Types.Vector3();
4331 4354
4332 float tempf = 0; 4355 float tempf = 0;
4333 4356
4334 for (int i = 0; i < rules.Length; i += 2) 4357 for (int i = 0; i < rules.Length; i += 2)
4335 {
4336 switch ((int)rules.Data[i])
4337 { 4358 {
4338 case (int)ScriptBaseClass.PSYS_PART_FLAGS: 4359 switch ((int)rules.Data[i])
4339 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); 4360 {
4340 break; 4361 case (int)ScriptBaseClass.PSYS_PART_FLAGS:
4362 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString()));
4363 break;
4341 4364
4342 case (int)ScriptBaseClass.PSYS_PART_START_COLOR: 4365 case (int)ScriptBaseClass.PSYS_PART_START_COLOR:
4343 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4366 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4344 prules.PartStartColor.R = (float)tempv.x; 4367 prules.PartStartColor.R = (float)tempv.x;
4345 prules.PartStartColor.G = (float)tempv.y; 4368 prules.PartStartColor.G = (float)tempv.y;
4346 prules.PartStartColor.B = (float)tempv.z; 4369 prules.PartStartColor.B = (float)tempv.z;
4347 break; 4370 break;
4348 4371
4349 case (int)ScriptBaseClass.PSYS_PART_START_ALPHA: 4372 case (int)ScriptBaseClass.PSYS_PART_START_ALPHA:
4350 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4373 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4351 prules.PartStartColor.A = (float)tempf; 4374 prules.PartStartColor.A = (float)tempf;
4352 break; 4375 break;
4353 4376
4354 case (int)ScriptBaseClass.PSYS_PART_END_COLOR: 4377 case (int)ScriptBaseClass.PSYS_PART_END_COLOR:
4355 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4378 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4356 //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1); 4379 //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1);
4357 4380
4358 prules.PartEndColor.R = (float)tempv.x; 4381 prules.PartEndColor.R = (float)tempv.x;
4359 prules.PartEndColor.G = (float)tempv.y; 4382 prules.PartEndColor.G = (float)tempv.y;
4360 prules.PartEndColor.B = (float)tempv.z; 4383 prules.PartEndColor.B = (float)tempv.z;
4361 break; 4384 break;
4362 4385
4363 case (int)ScriptBaseClass.PSYS_PART_END_ALPHA: 4386 case (int)ScriptBaseClass.PSYS_PART_END_ALPHA:
4364 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4387 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4365 prules.PartEndColor.A = (float)tempf; 4388 prules.PartEndColor.A = (float)tempf;
4366 break; 4389 break;
4367 4390
4368 case (int)ScriptBaseClass.PSYS_PART_START_SCALE: 4391 case (int)ScriptBaseClass.PSYS_PART_START_SCALE:
4369 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4392 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4370 prules.PartStartScaleX = (float)tempv.x; 4393 prules.PartStartScaleX = (float)tempv.x;
4371 prules.PartStartScaleY = (float)tempv.y; 4394 prules.PartStartScaleY = (float)tempv.y;
4372 break; 4395 break;
4373 4396
4374 case (int)ScriptBaseClass.PSYS_PART_END_SCALE: 4397 case (int)ScriptBaseClass.PSYS_PART_END_SCALE:
4375 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4398 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4376 prules.PartEndScaleX = (float)tempv.x; 4399 prules.PartEndScaleX = (float)tempv.x;
4377 prules.PartEndScaleY = (float)tempv.y; 4400 prules.PartEndScaleY = (float)tempv.y;
4378 break; 4401 break;
4379 4402
4380 case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: 4403 case (int)ScriptBaseClass.PSYS_PART_MAX_AGE:
4381 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4404 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4382 prules.PartMaxAge = (float)tempf; 4405 prules.PartMaxAge = (float)tempf;
4383 break; 4406 break;
4384 4407
4385 case (int)ScriptBaseClass.PSYS_SRC_ACCEL: 4408 case (int)ScriptBaseClass.PSYS_SRC_ACCEL:
4386 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4409 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4387 prules.PartAcceleration.X = (float)tempv.x; 4410 prules.PartAcceleration.X = (float)tempv.x;
4388 prules.PartAcceleration.Y = (float)tempv.y; 4411 prules.PartAcceleration.Y = (float)tempv.y;
4389 prules.PartAcceleration.Z = (float)tempv.z; 4412 prules.PartAcceleration.Z = (float)tempv.z;
4390 break; 4413 break;
4391 4414
4392 case (int)ScriptBaseClass.PSYS_SRC_PATTERN: 4415 case (int)ScriptBaseClass.PSYS_SRC_PATTERN:
4393 int tmpi = int.Parse(rules.Data[i + 1].ToString()); 4416 int tmpi = int.Parse(rules.Data[i + 1].ToString());
4394 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; 4417 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
4395 break; 4418 break;
4396 4419
4397 // Xantor 20080503 4420 // Xantor 20080503
4398 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture 4421 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture
4399 // "" = default texture. 4422 // "" = default texture.
4400 // 20080530 Updated to remove code duplication 4423 // 20080530 Updated to remove code duplication
4401 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: 4424 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
4402 prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); 4425 prules.Texture = KeyOrName(rules.Data[i + 1].ToString());
4403 break; 4426 break;
4404 4427
4405 case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: 4428 case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE:
4406 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4429 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4407 prules.BurstRate = (float)tempf; 4430 prules.BurstRate = (float)tempf;
4408 break; 4431 break;
4409 4432
4410 case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: 4433 case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT:
4411 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); 4434 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString());
4412 break; 4435 break;
4413 4436
4414 case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: 4437 case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS:
4415 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4438 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4416 prules.BurstRadius = (float)tempf; 4439 prules.BurstRadius = (float)tempf;
4417 break; 4440 break;
4418 4441
4419 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: 4442 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN:
4420 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4443 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4421 prules.BurstSpeedMin = (float)tempf; 4444 prules.BurstSpeedMin = (float)tempf;
4422 break; 4445 break;
4423 4446
4424 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: 4447 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX:
4425 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4448 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4426 prules.BurstSpeedMax = (float)tempf; 4449 prules.BurstSpeedMax = (float)tempf;
4427 break; 4450 break;
4428 4451
4429 case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: 4452 case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE:
4430 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4453 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4431 prules.MaxAge = (float)tempf; 4454 prules.MaxAge = (float)tempf;
4432 break; 4455 break;
4433 4456
4434 case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY: 4457 case (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY:
4435 LLUUID key = LLUUID.Zero; 4458 LLUUID key = LLUUID.Zero;
4436 if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key)) 4459 if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key))
4437 { 4460 {
4438 prules.Target = key; 4461 prules.Target = key;
4439 } 4462 }
4440 else 4463 else
4441 { 4464 {
4442 prules.Target = m_host.UUID; 4465 prules.Target = m_host.UUID;
4443 } 4466 }
4444 break; 4467 break;
4445 4468
4446 case (int)ScriptBaseClass.PSYS_SRC_OMEGA: 4469 case (int)ScriptBaseClass.PSYS_SRC_OMEGA:
4447 // AL: This is an assumption, since it is the only thing that would match. 4470 // AL: This is an assumption, since it is the only thing that would match.
4448 tempv = (LSL_Types.Vector3)rules.Data[i + 1]; 4471 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4449 prules.AngularVelocity.X = (float)tempv.x; 4472 prules.AngularVelocity.X = (float)tempv.x;
4450 prules.AngularVelocity.Y = (float)tempv.y; 4473 prules.AngularVelocity.Y = (float)tempv.y;
4451 prules.AngularVelocity.Z = (float)tempv.z; 4474 prules.AngularVelocity.Z = (float)tempv.z;
4452 //cast?? prules.MaxAge = (float)rules[i + 1]; 4475 //cast?? prules.MaxAge = (float)rules[i + 1];
4453 break; 4476 break;
4454 4477
4455 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: 4478 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN:
4456 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 4479 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4457 prules.InnerAngle = (float)tempf; 4480 prules.InnerAngle = (float)tempf;
4458 break; 4481 break;
4482
4483 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END:
4484 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4485 prules.OuterAngle = (float)tempf;
4486 break;
4487 }
4459 4488
4460 case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END:
4461 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4462 prules.OuterAngle = (float)tempf;
4463 break;
4464 } 4489 }
4490 prules.CRC = 1;
4465 4491
4492 m_host.AddNewParticleSystem(prules);
4466 } 4493 }
4467 prules.CRC = 1;
4468
4469 m_host.AddNewParticleSystem(prules);
4470 m_host.SendFullUpdateToAllClients(); 4494 m_host.SendFullUpdateToAllClients();
4471 } 4495 }
4472 4496