diff options
Diffstat (limited to '')
-rw-r--r-- | ExportBot/Commands/ExportParticlesCommand.cs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/ExportBot/Commands/ExportParticlesCommand.cs b/ExportBot/Commands/ExportParticlesCommand.cs new file mode 100644 index 0000000..4b2c322 --- /dev/null +++ b/ExportBot/Commands/ExportParticlesCommand.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | |||
7 | namespace libsecondlife.TestClient | ||
8 | { | ||
9 | public class ExportParticlesCommand : Command | ||
10 | { | ||
11 | public ExportParticlesCommand(TestClient testClient) | ||
12 | { | ||
13 | Name = "exportparticles"; | ||
14 | Description = "Reverse engineers a prim with a particle system to an LSL script. Usage: exportscript [prim-uuid]"; | ||
15 | } | ||
16 | |||
17 | public override string Execute(string[] args, LLUUID fromAgentID) | ||
18 | { | ||
19 | if (args.Length != 1) | ||
20 | return "Usage: exportparticles [prim-uuid]"; | ||
21 | |||
22 | LLUUID id; | ||
23 | if (!LLUUID.TryParse(args[0], out id)) | ||
24 | return "Usage: exportparticles [prim-uuid]"; | ||
25 | |||
26 | lock (Client.SimPrims) | ||
27 | { | ||
28 | if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim)) | ||
29 | { | ||
30 | foreach (Primitive prim in Client.SimPrims[Client.Network.CurrentSim].Values) | ||
31 | { | ||
32 | if (prim.ID == id) | ||
33 | { | ||
34 | if (prim.ParticleSys.CRC != 0) | ||
35 | { | ||
36 | StringBuilder lsl = new StringBuilder(); | ||
37 | |||
38 | lsl.Append("default" + Environment.NewLine); | ||
39 | lsl.Append("{" + Environment.NewLine); | ||
40 | lsl.Append(" state_entry()" + Environment.NewLine); | ||
41 | lsl.Append(" {" + Environment.NewLine); | ||
42 | lsl.Append(" llParticleSystem([" + Environment.NewLine); | ||
43 | |||
44 | lsl.Append(" PSYS_PART_FLAGS, 0"); | ||
45 | |||
46 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpColor) != 0) | ||
47 | lsl.Append(" | PSYS_PART_INTERP_COLOR_MASK"); | ||
48 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpScale) != 0) | ||
49 | lsl.Append(" | PSYS_PART_INTERP_SCALE_MASK"); | ||
50 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Bounce) != 0) | ||
51 | lsl.Append(" | PSYS_PART_BOUNCE_MASK"); | ||
52 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Wind) != 0) | ||
53 | lsl.Append(" | PSYS_PART_WIND_MASK"); | ||
54 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowSrc) != 0) | ||
55 | lsl.Append(" | PSYS_PART_FOLLOW_SRC_MASK"); | ||
56 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowVelocity) != 0) | ||
57 | lsl.Append(" | PSYS_PART_FOLLOW_VELOCITY_MASK"); | ||
58 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetPos) != 0) | ||
59 | lsl.Append(" | PSYS_PART_TARGET_POS_MASK"); | ||
60 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetLinear) != 0) | ||
61 | lsl.Append(" | PSYS_PART_TARGET_LINEAR_MASK"); | ||
62 | if ((prim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Emissive) != 0) | ||
63 | lsl.Append(" | PSYS_PART_EMISSIVE_MASK"); | ||
64 | |||
65 | lsl.Append(","); lsl.Append(Environment.NewLine); | ||
66 | lsl.Append(" PSYS_SRC_PATTERN, 0"); | ||
67 | |||
68 | if ((prim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Drop) != 0) | ||
69 | lsl.Append(" | PSYS_SRC_PATTERN_DROP"); | ||
70 | if ((prim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Explode) != 0) | ||
71 | lsl.Append(" | PSYS_SRC_PATTERN_EXPLODE"); | ||
72 | if ((prim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Angle) != 0) | ||
73 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE"); | ||
74 | if ((prim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleCone) != 0) | ||
75 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE"); | ||
76 | if ((prim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleConeEmpty) != 0) | ||
77 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY"); | ||
78 | |||
79 | lsl.Append("," + Environment.NewLine); | ||
80 | |||
81 | lsl.Append(" PSYS_PART_START_ALPHA, " + String.Format("{0:0.00000}", prim.ParticleSys.PartStartColor.A) + "," + Environment.NewLine); | ||
82 | lsl.Append(" PSYS_PART_END_ALPHA, " + String.Format("{0:0.00000}", prim.ParticleSys.PartEndColor.A) + "," + Environment.NewLine); | ||
83 | lsl.Append(" PSYS_PART_START_COLOR, " + prim.ParticleSys.PartStartColor.ToStringRGB() + "," + Environment.NewLine); | ||
84 | lsl.Append(" PSYS_PART_END_COLOR, " + prim.ParticleSys.PartEndColor.ToStringRGB() + "," + Environment.NewLine); | ||
85 | lsl.Append(" PSYS_PART_START_SCALE, <" + String.Format("{0:0.00000}", prim.ParticleSys.PartStartScaleX) + ", " + String.Format("{0:0.00000}", prim.ParticleSys.PartStartScaleY) + ", 0>, " + Environment.NewLine); | ||
86 | lsl.Append(" PSYS_PART_END_SCALE, <" + String.Format("{0:0.00000}", prim.ParticleSys.PartEndScaleX) + ", " + String.Format("{0:0.00000}", prim.ParticleSys.PartEndScaleY) + ", 0>, " + Environment.NewLine); | ||
87 | lsl.Append(" PSYS_PART_MAX_AGE, " + String.Format("{0:0.00000}", prim.ParticleSys.PartMaxAge) + "," + Environment.NewLine); | ||
88 | lsl.Append(" PSYS_SRC_MAX_AGE, " + String.Format("{0:0.00000}", prim.ParticleSys.MaxAge) + "," + Environment.NewLine); | ||
89 | lsl.Append(" PSYS_SRC_ACCEL, " + prim.ParticleSys.PartAcceleration.ToString() + "," + Environment.NewLine); | ||
90 | lsl.Append(" PSYS_SRC_BURST_PART_COUNT, " + String.Format("{0:0}", prim.ParticleSys.BurstPartCount) + "," + Environment.NewLine); | ||
91 | lsl.Append(" PSYS_SRC_BURST_RADIUS, " + String.Format("{0:0.00000}", prim.ParticleSys.BurstRadius) + "," + Environment.NewLine); | ||
92 | lsl.Append(" PSYS_SRC_BURST_RATE, " + String.Format("{0:0.00000}", prim.ParticleSys.BurstRate) + "," + Environment.NewLine); | ||
93 | lsl.Append(" PSYS_SRC_BURST_SPEED_MIN, " + String.Format("{0:0.00000}", prim.ParticleSys.BurstSpeedMin) + "," + Environment.NewLine); | ||
94 | lsl.Append(" PSYS_SRC_BURST_SPEED_MAX, " + String.Format("{0:0.00000}", prim.ParticleSys.BurstSpeedMax) + "," + Environment.NewLine); | ||
95 | lsl.Append(" PSYS_SRC_INNERANGLE, " + String.Format("{0:0.00000}", prim.ParticleSys.InnerAngle) + "," + Environment.NewLine); | ||
96 | lsl.Append(" PSYS_SRC_OUTERANGLE, " + String.Format("{0:0.00000}", prim.ParticleSys.OuterAngle) + "," + Environment.NewLine); | ||
97 | lsl.Append(" PSYS_SRC_OMEGA, " + prim.ParticleSys.AngularVelocity.ToString() + "," + Environment.NewLine); | ||
98 | lsl.Append(" PSYS_SRC_TEXTURE, (key)\"" + prim.ParticleSys.Texture.ToStringHyphenated() + "\"," + Environment.NewLine); | ||
99 | lsl.Append(" PSYS_SRC_TARGET_KEY, (key)\"" + prim.ParticleSys.Target.ToStringHyphenated() + "\"" + Environment.NewLine); | ||
100 | |||
101 | lsl.Append(" ]);" + Environment.NewLine); | ||
102 | lsl.Append(" }" + Environment.NewLine); | ||
103 | lsl.Append("}" + Environment.NewLine); | ||
104 | |||
105 | return lsl.ToString(); | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | return "Prim " + prim.LocalID + " does not have a particle system"; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | return "Couldn't find prim " + id.ToStringHyphenated(); | ||
117 | } | ||
118 | } | ||
119 | } | ||