corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.IO; |
||
4 | using System.Text; |
||
5 | using OpenMetaverse; |
||
6 | |||
7 | namespace OpenMetaverse.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 | Category = CommandCategory.Objects; |
||
16 | } |
||
17 | |||
18 | public override string Execute(string[] args, UUID fromAgentID) |
||
19 | { |
||
20 | if (args.Length != 1) |
||
21 | return "Usage: exportparticles [prim-uuid]"; |
||
22 | |||
23 | UUID id; |
||
24 | if (!UUID.TryParse(args[0], out id)) |
||
25 | return "Usage: exportparticles [prim-uuid]"; |
||
26 | |||
27 | lock (Client.Network.Simulators) |
||
28 | { |
||
29 | for (int i = 0; i < Client.Network.Simulators.Count; i++) |
||
30 | { |
||
31 | Primitive exportPrim = Client.Network.Simulators[i].ObjectsPrimitives.Find( |
||
32 | delegate(Primitive prim) |
||
33 | { |
||
34 | return prim.ID == id; |
||
35 | } |
||
36 | ); |
||
37 | |||
38 | if (exportPrim != null) |
||
39 | { |
||
40 | if (exportPrim.ParticleSys.CRC != 0) |
||
41 | { |
||
42 | StringBuilder lsl = new StringBuilder(); |
||
43 | |||
44 | #region Particle System to LSL |
||
45 | |||
46 | lsl.Append("default" + Environment.NewLine); |
||
47 | lsl.Append("{" + Environment.NewLine); |
||
48 | lsl.Append(" state_entry()" + Environment.NewLine); |
||
49 | lsl.Append(" {" + Environment.NewLine); |
||
50 | lsl.Append(" llParticleSystem([" + Environment.NewLine); |
||
51 | |||
52 | lsl.Append(" PSYS_PART_FLAGS, 0"); |
||
53 | |||
54 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpColor) != 0) |
||
55 | lsl.Append(" | PSYS_PART_INTERP_COLOR_MASK"); |
||
56 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpScale) != 0) |
||
57 | lsl.Append(" | PSYS_PART_INTERP_SCALE_MASK"); |
||
58 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Bounce) != 0) |
||
59 | lsl.Append(" | PSYS_PART_BOUNCE_MASK"); |
||
60 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Wind) != 0) |
||
61 | lsl.Append(" | PSYS_PART_WIND_MASK"); |
||
62 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowSrc) != 0) |
||
63 | lsl.Append(" | PSYS_PART_FOLLOW_SRC_MASK"); |
||
64 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowVelocity) != 0) |
||
65 | lsl.Append(" | PSYS_PART_FOLLOW_VELOCITY_MASK"); |
||
66 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetPos) != 0) |
||
67 | lsl.Append(" | PSYS_PART_TARGET_POS_MASK"); |
||
68 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetLinear) != 0) |
||
69 | lsl.Append(" | PSYS_PART_TARGET_LINEAR_MASK"); |
||
70 | if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Emissive) != 0) |
||
71 | lsl.Append(" | PSYS_PART_EMISSIVE_MASK"); |
||
72 | |||
73 | lsl.Append(","); lsl.Append(Environment.NewLine); |
||
74 | lsl.Append(" PSYS_SRC_PATTERN, 0"); |
||
75 | |||
76 | if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Drop) != 0) |
||
77 | lsl.Append(" | PSYS_SRC_PATTERN_DROP"); |
||
78 | if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Explode) != 0) |
||
79 | lsl.Append(" | PSYS_SRC_PATTERN_EXPLODE"); |
||
80 | if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Angle) != 0) |
||
81 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE"); |
||
82 | if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleCone) != 0) |
||
83 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE"); |
||
84 | if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleConeEmpty) != 0) |
||
85 | lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY"); |
||
86 | |||
87 | lsl.Append("," + Environment.NewLine); |
||
88 | |||
89 | lsl.Append(" PSYS_PART_START_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartColor.A) + "," + Environment.NewLine); |
||
90 | lsl.Append(" PSYS_PART_END_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndColor.A) + "," + Environment.NewLine); |
||
91 | lsl.Append(" PSYS_PART_START_COLOR, " + exportPrim.ParticleSys.PartStartColor.ToRGBString() + "," + Environment.NewLine); |
||
92 | lsl.Append(" PSYS_PART_END_COLOR, " + exportPrim.ParticleSys.PartEndColor.ToRGBString() + "," + Environment.NewLine); |
||
93 | lsl.Append(" PSYS_PART_START_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleY) + ", 0>, " + Environment.NewLine); |
||
94 | lsl.Append(" PSYS_PART_END_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleY) + ", 0>, " + Environment.NewLine); |
||
95 | lsl.Append(" PSYS_PART_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartMaxAge) + "," + Environment.NewLine); |
||
96 | lsl.Append(" PSYS_SRC_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.MaxAge) + "," + Environment.NewLine); |
||
97 | lsl.Append(" PSYS_SRC_ACCEL, " + exportPrim.ParticleSys.PartAcceleration.ToString() + "," + Environment.NewLine); |
||
98 | lsl.Append(" PSYS_SRC_BURST_PART_COUNT, " + String.Format("{0:0}", exportPrim.ParticleSys.BurstPartCount) + "," + Environment.NewLine); |
||
99 | lsl.Append(" PSYS_SRC_BURST_RADIUS, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRadius) + "," + Environment.NewLine); |
||
100 | lsl.Append(" PSYS_SRC_BURST_RATE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRate) + "," + Environment.NewLine); |
||
101 | lsl.Append(" PSYS_SRC_BURST_SPEED_MIN, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMin) + "," + Environment.NewLine); |
||
102 | lsl.Append(" PSYS_SRC_BURST_SPEED_MAX, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMax) + "," + Environment.NewLine); |
||
103 | lsl.Append(" PSYS_SRC_INNERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.InnerAngle) + "," + Environment.NewLine); |
||
104 | lsl.Append(" PSYS_SRC_OUTERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.OuterAngle) + "," + Environment.NewLine); |
||
105 | lsl.Append(" PSYS_SRC_OMEGA, " + exportPrim.ParticleSys.AngularVelocity.ToString() + "," + Environment.NewLine); |
||
106 | lsl.Append(" PSYS_SRC_TEXTURE, (key)\"" + exportPrim.ParticleSys.Texture.ToString() + "\"," + Environment.NewLine); |
||
107 | lsl.Append(" PSYS_SRC_TARGET_KEY, (key)\"" + exportPrim.ParticleSys.Target.ToString() + "\"" + Environment.NewLine); |
||
108 | |||
109 | lsl.Append(" ]);" + Environment.NewLine); |
||
110 | lsl.Append(" }" + Environment.NewLine); |
||
111 | lsl.Append("}" + Environment.NewLine); |
||
112 | |||
113 | #endregion Particle System to LSL |
||
114 | |||
115 | return lsl.ToString(); |
||
116 | } |
||
117 | else |
||
118 | { |
||
119 | return "Prim " + exportPrim.LocalID + " does not have a particle system"; |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | } |
||
124 | |||
125 | return "Couldn't find prim " + id.ToString(); |
||
126 | } |
||
127 | } |
||
128 | } |