diff options
Diffstat (limited to 'linden/indra/llmessage/llpartdata.h')
-rw-r--r-- | linden/indra/llmessage/llpartdata.h | 236 |
1 files changed, 236 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llpartdata.h b/linden/indra/llmessage/llpartdata.h new file mode 100644 index 0000000..4045ada --- /dev/null +++ b/linden/indra/llmessage/llpartdata.h | |||
@@ -0,0 +1,236 @@ | |||
1 | /** | ||
2 | * @file llpartdata.h | ||
3 | * @brief Particle system data packing | ||
4 | * | ||
5 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLPARTDATA_H | ||
29 | #define LL_LLPARTDATA_H | ||
30 | |||
31 | #include <stdio.h> | ||
32 | |||
33 | #include "lluuid.h" | ||
34 | #include "v3math.h" | ||
35 | #include "v3dmath.h" | ||
36 | #include "v2math.h" | ||
37 | #include "v4color.h" | ||
38 | |||
39 | class LLMessageSystem; | ||
40 | class LLDataPacker; | ||
41 | |||
42 | const S32 PS_CUR_VERSION = 18; | ||
43 | |||
44 | // | ||
45 | // These constants are used by the script code, not by the particle system itself | ||
46 | // | ||
47 | |||
48 | enum LLPSScriptFlags | ||
49 | { | ||
50 | // Flags for the different parameters of individual particles | ||
51 | LLPS_PART_FLAGS, | ||
52 | LLPS_PART_START_COLOR, | ||
53 | LLPS_PART_START_ALPHA, | ||
54 | LLPS_PART_END_COLOR, | ||
55 | LLPS_PART_END_ALPHA, | ||
56 | LLPS_PART_START_SCALE, | ||
57 | LLPS_PART_END_SCALE, | ||
58 | LLPS_PART_MAX_AGE, | ||
59 | |||
60 | // Flags for the different parameters of the particle source | ||
61 | LLPS_SRC_ACCEL, | ||
62 | LLPS_SRC_PATTERN, | ||
63 | LLPS_SRC_INNERANGLE, | ||
64 | LLPS_SRC_OUTERANGLE, | ||
65 | LLPS_SRC_TEXTURE, | ||
66 | LLPS_SRC_BURST_RATE, | ||
67 | LLPS_SRC_BURST_DURATION, | ||
68 | LLPS_SRC_BURST_PART_COUNT, | ||
69 | LLPS_SRC_BURST_RADIUS, | ||
70 | LLPS_SRC_BURST_SPEED_MIN, | ||
71 | LLPS_SRC_BURST_SPEED_MAX, | ||
72 | LLPS_SRC_MAX_AGE, | ||
73 | LLPS_SRC_TARGET_UUID, | ||
74 | LLPS_SRC_OMEGA, | ||
75 | LLPS_SRC_ANGLE_BEGIN, | ||
76 | LLPS_SRC_ANGLE_END | ||
77 | }; | ||
78 | |||
79 | |||
80 | class LLPartData | ||
81 | { | ||
82 | public: | ||
83 | LLPartData() : | ||
84 | mFlags(0), | ||
85 | mMaxAge(0) | ||
86 | { | ||
87 | } | ||
88 | BOOL unpack(LLDataPacker &dp); | ||
89 | BOOL pack(LLDataPacker &dp); | ||
90 | LLSD asLLSD() const; | ||
91 | operator LLSD() const {return asLLSD(); } | ||
92 | bool fromLLSD(LLSD& sd); | ||
93 | |||
94 | // Masks for the different particle flags | ||
95 | enum | ||
96 | { | ||
97 | LL_PART_INTERP_COLOR_MASK = 0x01, | ||
98 | LL_PART_INTERP_SCALE_MASK = 0x02, | ||
99 | LL_PART_BOUNCE_MASK = 0x04, | ||
100 | LL_PART_WIND_MASK = 0x08, | ||
101 | LL_PART_FOLLOW_SRC_MASK = 0x10, // Follows source, no rotation following (expensive!) | ||
102 | LL_PART_FOLLOW_VELOCITY_MASK = 0x20, // Particles orient themselves with velocity | ||
103 | LL_PART_TARGET_POS_MASK = 0x40, | ||
104 | LL_PART_TARGET_LINEAR_MASK = 0x80, // Particle uses a direct linear interpolation | ||
105 | LL_PART_EMISSIVE_MASK = 0x100, // Particle is "emissive", instead of being lit | ||
106 | LL_PART_BEAM_MASK = 0x200, // Particle is a "beam" connecting source and target | ||
107 | |||
108 | // Not implemented yet! | ||
109 | //LL_PART_RANDOM_ACCEL_MASK = 0x100, // Patricles have random accelearation | ||
110 | //LL_PART_RANDOM_VEL_MASK = 0x200, // Particles have random velocity shifts" | ||
111 | //LL_PART_TRAIL_MASK = 0x400, // Particles have historical "trails" | ||
112 | |||
113 | // Viewer side use only! | ||
114 | LL_PART_DEAD_MASK = 0x80000000, | ||
115 | }; | ||
116 | |||
117 | void setFlags(const U32 flags); | ||
118 | void setMaxAge(const F32 max_age); | ||
119 | void setStartScale(const F32 xs, F32 ys); | ||
120 | void setEndScale(const F32 xs, F32 ys); | ||
121 | void setStartColor(const LLVector3 &rgb); | ||
122 | void setEndColor(const LLVector3 &rgb); | ||
123 | void setStartAlpha(const F32 alpha); | ||
124 | void setEndAlpha(const F32 alpha); | ||
125 | |||
126 | |||
127 | friend class LLPartSysData; | ||
128 | friend class LLViewerPartSourceScript; | ||
129 | |||
130 | // These are public because I'm really lazy... | ||
131 | public: | ||
132 | U32 mFlags; // Particle state/interpolators in effect | ||
133 | F32 mMaxAge; // Maximum age of the particle | ||
134 | LLColor4 mStartColor; // Start color | ||
135 | LLColor4 mEndColor; // End color | ||
136 | LLVector2 mStartScale; // Start scale | ||
137 | LLVector2 mEndScale; // End scale | ||
138 | |||
139 | LLVector3 mPosOffset; // Offset from source if using FOLLOW_SOURCE | ||
140 | F32 mParameter; // A single floating point parameter | ||
141 | }; | ||
142 | |||
143 | |||
144 | class LLPartSysData | ||
145 | { | ||
146 | public: | ||
147 | LLPartSysData(); | ||
148 | |||
149 | BOOL unpack(LLDataPacker &dp); | ||
150 | BOOL pack(LLDataPacker &dp); | ||
151 | |||
152 | |||
153 | BOOL unpackBlock(const S32 block_num); | ||
154 | BOOL packBlock(); | ||
155 | |||
156 | static BOOL packNull(); | ||
157 | static BOOL isNullPS(const S32 block_num); // Returns FALSE if this is a "NULL" particle system (i.e. no system) | ||
158 | |||
159 | // Different masks for effects on the source | ||
160 | enum | ||
161 | { | ||
162 | LL_PART_SRC_OBJ_REL_MASK = 0x01, // Accel and velocity for particles relative object rotation | ||
163 | LL_PART_USE_NEW_ANGLE = 0x02, // Particles uses new 'correct' angle parameters. | ||
164 | }; | ||
165 | |||
166 | // The different patterns for how particles are created | ||
167 | enum | ||
168 | { | ||
169 | LL_PART_SRC_PATTERN_DROP = 0x01, | ||
170 | LL_PART_SRC_PATTERN_EXPLODE = 0x02, | ||
171 | // Not implemented fully yet | ||
172 | LL_PART_SRC_PATTERN_ANGLE = 0x04, | ||
173 | LL_PART_SRC_PATTERN_ANGLE_CONE = 0x08, | ||
174 | LL_PART_SRC_PATTERN_ANGLE_CONE_EMPTY = 0x10, | ||
175 | }; | ||
176 | |||
177 | |||
178 | void setBurstSpeedMin(const F32 spd) { mBurstSpeedMin = llclamp(spd, -100.f, 100.f); } | ||
179 | void setBurstSpeedMax(const F32 spd) { mBurstSpeedMax = llclamp(spd, -100.f, 100.f); } | ||
180 | void setBurstRadius(const F32 rad) { mBurstRadius = llclamp(rad, 0.f, 50.f); } | ||
181 | void setPartAccel(const LLVector3 &accel); | ||
182 | void setUseNewAngle() { mFlags |= LL_PART_USE_NEW_ANGLE; } | ||
183 | void unsetUseNewAngle() { mFlags &= ~LL_PART_USE_NEW_ANGLE; } | ||
184 | |||
185 | // Since the actual particle creation rate is | ||
186 | // a combination of multiple parameters, we | ||
187 | // need to clamp it using a separate method instead of an accessor. | ||
188 | void clampSourceParticleRate(); | ||
189 | public: | ||
190 | // Public because I'm lazy.... | ||
191 | |||
192 | // | ||
193 | // There are two kinds of data for the particle system | ||
194 | // 1. Parameters which specify parameters of the source (mSource*) | ||
195 | // 2. Parameters which specify parameters of the particles generated by the source (mPart*) | ||
196 | // | ||
197 | |||
198 | U32 mCRC; | ||
199 | U32 mFlags; | ||
200 | |||
201 | U8 mPattern; // Pattern for particle velocity/output | ||
202 | F32 mInnerAngle; // Inner angle for PATTERN_ANGLE | ||
203 | F32 mOuterAngle; // Outer angle for PATTERN_ANGLE | ||
204 | LLVector3 mAngularVelocity; // Angular velocity for emission axis (for PATTERN_ANGLE) | ||
205 | |||
206 | F32 mBurstRate; // How often to do a burst of particles | ||
207 | U8 mBurstPartCount; // How many particles in a burst | ||
208 | F32 mBurstRadius; | ||
209 | F32 mBurstSpeedMin; // Minimum particle velocity | ||
210 | F32 mBurstSpeedMax; // Maximum particle velocity | ||
211 | |||
212 | F32 mMaxAge; // Maximum lifetime of this particle source | ||
213 | |||
214 | LLUUID mTargetUUID; // Target UUID for the particle system | ||
215 | |||
216 | F32 mStartAge; // Age at which to start the particle system (for an update after the | ||
217 | // particle system has started) | ||
218 | |||
219 | |||
220 | // | ||
221 | // These are actually particle properties, but can be mutated by the source, | ||
222 | // so are stored here instead | ||
223 | // | ||
224 | LLVector3 mPartAccel; | ||
225 | LLUUID mPartImageID; | ||
226 | |||
227 | // | ||
228 | // The "template" partdata where we actually store the non-mutable particle parameters | ||
229 | // | ||
230 | LLPartData mPartData; | ||
231 | |||
232 | protected: | ||
233 | S32 mNumParticles; // Number of particles generated | ||
234 | }; | ||
235 | |||
236 | #endif // LL_LLPARTDATA_H | ||