Annotation of /linden_release/linden/indra/llmessage/partsyspacket.h
Parent Directory
|
Revision Log
Revision 100 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file partsyspacket.h | ||
| 3 : | * @brief Object for packing particle system initialization parameters | ||
| 4 : | * before sending them over the network | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2000&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | mjm | 100 | * Copyright (c) 2000-2009, Linden Research, Inc. |
| 9 : | mjm | 57 | * |
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #ifndef LL_PARTSYSPACKET_H | ||
| 34 : | #define LL_PARTSYSPACKET_H | ||
| 35 : | |||
| 36 : | #include "lluuid.h" | ||
| 37 : | |||
| 38 : | // Particle system stuff | ||
| 39 : | |||
| 40 : | const U64 PART_SYS_MAX_TIME_IN_USEC = 1000000; // 1 second, die not quite near instantaneously | ||
| 41 : | |||
| 42 : | |||
| 43 : | // this struct is for particle system initialization parameters | ||
| 44 : | // I'm breaking some rules here, but I need a storage structure to hold initialization data | ||
| 45 : | // for these things. Sorry guys, they're not simple enough (yet) to avoid this cleanly | ||
| 46 : | struct LLPartInitData { | ||
| 47 : | // please do not add functions to this class -- data only! | ||
| 48 : | //F32 k[18]; // first 9 --> x,y,z last 9 --> scale, alpha, rot | ||
| 49 : | //F32 kill_p[6]; // last one is for particles that die when they reach a spherical bounding radius | ||
| 50 : | //F32 kill_plane[3]; | ||
| 51 : | //F32 bounce_p[5]; | ||
| 52 : | F32 bounce_b; // recently changed | ||
| 53 : | // no need to store orientation and position here, as they're sent over seperately | ||
| 54 : | //F32 pos_ranges[6]; | ||
| 55 : | //F32 vel_ranges[6]; | ||
| 56 : | F32 scale_range[4]; | ||
| 57 : | F32 alpha_range[4]; | ||
| 58 : | F32 vel_offset[3]; //new - more understandable! | ||
| 59 : | |||
| 60 : | F32 mDistBeginFadeout; // for fadeout LOD optimization | ||
| 61 : | F32 mDistEndFadeout; | ||
| 62 : | |||
| 63 : | LLUUID mImageUuid; | ||
| 64 : | //U8 n; // number of particles | ||
| 65 : | U8 mFlags[8]; // for miscellaneous data --> its interpretation can change at my whim! | ||
| 66 : | U8 createMe; // do I need to be created? or has the work allready been done? | ||
| 67 : | //ActionFlag is now mFlags[PART_SYS_ACTION_BYTE] | ||
| 68 : | //Spawn point is initially object creation center | ||
| 69 : | |||
| 70 : | F32 diffEqAlpha[3]; | ||
| 71 : | F32 diffEqScale[3]; | ||
| 72 : | |||
| 73 : | U8 maxParticles; | ||
| 74 : | //How many particles exist at any time within the system? | ||
| 75 : | U8 initialParticles; | ||
| 76 : | //How many particles exist when the system is created? | ||
| 77 : | F32 killPlaneZ; | ||
| 78 : | //For simplicity assume the XY plane, so this sets an altitude at which to die | ||
| 79 : | F32 killPlaneNormal[3]; | ||
| 80 : | //Normal if not planar XY | ||
| 81 : | F32 bouncePlaneZ; | ||
| 82 : | //For simplicity assume the XY plane, so this sets an altitude at which to bounce | ||
| 83 : | F32 bouncePlaneNormal[3]; | ||
| 84 : | //Normal if not planar XY | ||
| 85 : | F32 spawnRange; | ||
| 86 : | //Range of emission points about the mSpawnPoint | ||
| 87 : | F32 spawnFrequency; | ||
| 88 : | //Required if the system is to spawn new particles. | ||
| 89 : | //This variable determines the time after a particle dies when it is respawned. | ||
| 90 : | F32 spawnFreqencyRange; | ||
| 91 : | //Determines the random range of time until a new particle is spawned. | ||
| 92 : | F32 spawnDirection[3]; | ||
| 93 : | //Direction vector giving the mean direction in which particles are spawned | ||
| 94 : | F32 spawnDirectionRange; | ||
| 95 : | //Direction limiting the angular range of emissions about the mean direction. 1.0f means everywhere, 0.0f means uni-directional | ||
| 96 : | F32 spawnVelocity; | ||
| 97 : | //The mean speed at which particles are emitted | ||
| 98 : | F32 spawnVelocityRange; | ||
| 99 : | //The range of speeds about the mean at which particles are emitted. | ||
| 100 : | F32 speedLimit; | ||
| 101 : | //Used to constrain particle maximum velocity | ||
| 102 : | F32 windWeight; | ||
| 103 : | //How much of an effect does wind have | ||
| 104 : | F32 currentGravity[3]; | ||
| 105 : | //Gravity direction used in update calculations | ||
| 106 : | F32 gravityWeight; | ||
| 107 : | //How much of an effect does gravity have | ||
| 108 : | F32 globalLifetime; | ||
| 109 : | //If particles re-spawn, a system can exist forever. | ||
| 110 : | //If (ActionFlags & PART_SYS_GLOBAL_DIE) is TRUE this variable is used to determine how long the system lasts. | ||
| 111 : | F32 individualLifetime; | ||
| 112 : | //How long does each particle last if nothing else happens to it | ||
| 113 : | F32 individualLifetimeRange; | ||
| 114 : | //Range of variation in individual lifetimes | ||
| 115 : | F32 alphaDecay; | ||
| 116 : | //By what factor does alpha decrease as the lifetime of a particle is approached. | ||
| 117 : | F32 scaleDecay; | ||
| 118 : | //By what factor does scale decrease as the lifetime of a particle is approached. | ||
| 119 : | F32 distanceDeath; | ||
| 120 : | //With the increased functionality, particle systems can expand to indefinite size | ||
| 121 : | //(e.g. wind can chaotically move particles into a wide spread). | ||
| 122 : | //To avoid particles exceeding normal object size constraints, | ||
| 123 : | //set the PART_SYS_DISTANCE_DEATH flag, and set a distance value here, representing a radius around the spawn point. | ||
| 124 : | F32 dampMotionFactor; | ||
| 125 : | //How much to damp motion | ||
| 126 : | F32 windDiffusionFactor[3]; | ||
| 127 : | //Change the size and alpha of particles as wind speed increases (scale gets bigger, alpha smaller) | ||
| 128 : | }; | ||
| 129 : | |||
| 130 : | // constants for setting flag values | ||
| 131 : | // BYTES are in range 0-8, bits are in range 2^0 - 2^8 and can only be powers of two | ||
| 132 : | const int PART_SYS_NO_Z_BUFFER_BYTE = 0; // option to turn off z-buffer when rendering | ||
| 133 : | const int PART_SYS_NO_Z_BUFFER_BIT = 2; // particle systems -- | ||
| 134 : | // I advise against using this, as it looks bad in every case I've tried | ||
| 135 : | |||
| 136 : | const int PART_SYS_SLOW_ANIM_BYTE = 0; // slow animation down by a factor of 10 | ||
| 137 : | const int PART_SYS_SLOW_ANIM_BIT = 1; // useful for tweaking anims during debugging | ||
| 138 : | |||
| 139 : | const int PART_SYS_FOLLOW_VEL_BYTE = 0; // indicates whether to orient sprites towards | ||
| 140 : | const int PART_SYS_FOLLOW_VEL_BIT = 4; // their velocity vector -- default is FALSE | ||
| 141 : | |||
| 142 : | const int PART_SYS_IS_LIGHT_BYTE = 0; // indicates whether a particular particle system | ||
| 143 : | const int PART_SYS_IS_LIGHT_BIT = 8; // is also a light object -- for andrew | ||
| 144 : | // should deprecate this once there is a general method for setting light properties of objects | ||
| 145 : | |||
| 146 : | const int PART_SYS_SPAWN_COPY_BYTE = 0; // indicates whether to spawn baby particle systems on | ||
| 147 : | const int PART_SYS_SPAWN_COPY_BIT = 0x10; // particle death -- intended for smoke trails | ||
| 148 : | |||
| 149 : | const int PART_SYS_COPY_VEL_BYTE = 0; // indicates whether baby particle systems inherit parents vel | ||
| 150 : | const int PART_SYS_COPY_VEL_BIT = 0x20; // (by default they don't) | ||
| 151 : | |||
| 152 : | const int PART_SYS_INVISIBLE_BYTE = 0; // optional -- turn off display, just simulate | ||
| 153 : | const int PART_SYS_INVISIBLE_BIT = 0x40; // useful for smoke trails | ||
| 154 : | |||
| 155 : | const int PART_SYS_ADAPT_TO_FRAMERATE_BYTE = 0; // drop sprites from render call proportionally | ||
| 156 : | const int PART_SYS_ADAPT_TO_FRAMERATE_BIT = 0x80; // to how far we are below 60 fps | ||
| 157 : | |||
| 158 : | |||
| 159 : | // 26 September 2001 - not even big enough to hold all changes, so should enlarge anyway | ||
| 160 : | //const U16 MAX_PART_SYS_PACKET_SIZE = 180; | ||
| 161 : | const U16 MAX_PART_SYS_PACKET_SIZE = 256; | ||
| 162 : | |||
| 163 : | //const U8 PART_SYS_K_MASK = 0x01; | ||
| 164 : | const U8 PART_SYS_KILL_P_MASK = 0x02; | ||
| 165 : | const U8 PART_SYS_BOUNCE_P_MASK = 0x04; | ||
| 166 : | const U8 PART_SYS_BOUNCE_B_MASK = 0x08; | ||
| 167 : | //const U8 PART_SYS_POS_RANGES_MASK = 0x10; | ||
| 168 : | //const U8 PART_SYS_VEL_RANGES_MASK = 0x20; | ||
| 169 : | const U8 PART_SYS_VEL_OFFSET_MASK = 0x10; //re-use one of the original slots now commented out | ||
| 170 : | const U8 PART_SYS_ALPHA_SCALE_DIFF_MASK = 0x20; //re-use one of the original slots now commented out | ||
| 171 : | const U8 PART_SYS_SCALE_RANGE_MASK = 0x40; | ||
| 172 : | const U8 PART_SYS_M_IMAGE_UUID_MASK = 0x80; | ||
| 173 : | const U8 PART_SYS_BYTE_3_ALPHA_MASK = 0x01; // wrapped around, didn't we? | ||
| 174 : | |||
| 175 : | const U8 PART_SYS_BYTE_SPAWN_MASK = 0x01; | ||
| 176 : | const U8 PART_SYS_BYTE_ENVIRONMENT_MASK = 0x02; | ||
| 177 : | const U8 PART_SYS_BYTE_LIFESPAN_MASK = 0x04; | ||
| 178 : | const U8 PART_SYS_BYTE_DECAY_DAMP_MASK = 0x08; | ||
| 179 : | const U8 PART_SYS_BYTE_WIND_DIFF_MASK = 0x10; | ||
| 180 : | |||
| 181 : | |||
| 182 : | // 26 September 2001 - new constants for mActionFlags | ||
| 183 : | const int PART_SYS_ACTION_BYTE = 1; | ||
| 184 : | const U8 PART_SYS_SPAWN = 0x01; | ||
| 185 : | const U8 PART_SYS_BOUNCE = 0x02; | ||
| 186 : | const U8 PART_SYS_AFFECTED_BY_WIND = 0x04; | ||
| 187 : | const U8 PART_SYS_AFFECTED_BY_GRAVITY = 0x08; | ||
| 188 : | const U8 PART_SYS_EVALUATE_WIND_PER_PARTICLE = 0x10; | ||
| 189 : | const U8 PART_SYS_DAMP_MOTION = 0x20; | ||
| 190 : | const U8 PART_SYS_WIND_DIFFUSION = 0x40; | ||
| 191 : | |||
| 192 : | // 26 September 2001 - new constants for mKillFlags | ||
| 193 : | const int PART_SYS_KILL_BYTE = 2; | ||
| 194 : | const U8 PART_SYS_KILL_PLANE = 0x01; | ||
| 195 : | const U8 PART_SYS_GLOBAL_DIE = 0x02; | ||
| 196 : | const U8 PART_SYS_DISTANCE_DEATH = 0x04; | ||
| 197 : | const U8 PART_SYS_TIME_DEATH = 0x08; | ||
| 198 : | |||
| 199 : | |||
| 200 : | // global, because the sim-side also calls it in the LLPartInitDataFactory | ||
| 201 : | |||
| 202 : | |||
| 203 : | void gSetInitDataDefaults(LLPartInitData *setMe); | ||
| 204 : | |||
| 205 : | class LLPartSysCompressedPacket | ||
| 206 : | { | ||
| 207 : | public: | ||
| 208 : | LLPartSysCompressedPacket(); | ||
| 209 : | ~LLPartSysCompressedPacket(); | ||
| 210 : | BOOL fromLLPartInitData(LLPartInitData *in, U32 &bytesUsed); | ||
| 211 : | BOOL toLLPartInitData(LLPartInitData *out, U32 *bytesUsed); | ||
| 212 : | BOOL fromUnsignedBytes(U8 *in, U32 bytesUsed); | ||
| 213 : | BOOL toUnsignedBytes(U8 *out); | ||
| 214 : | U32 bufferSize(); | ||
| 215 : | U8 *getBytePtr(); | ||
| 216 : | |||
| 217 : | protected: | ||
| 218 : | U8 mData[MAX_PART_SYS_PACKET_SIZE]; | ||
| 219 : | U32 mNumBytes; | ||
| 220 : | LLPartInitData mDefaults; // this is intended to hold default LLPartInitData values | ||
| 221 : | // please do not modify it | ||
| 222 : | LLPartInitData mWorkingCopy; // uncompressed data I'm working with | ||
| 223 : | |||
| 224 : | protected: | ||
| 225 : | // private functions (used only to break up code) | ||
| 226 : | void writeFlagByte(LLPartInitData *in); | ||
| 227 : | //U32 writeK(LLPartInitData *in, U32 startByte); | ||
| 228 : | U32 writeKill_p(LLPartInitData *in, U32 startByte); | ||
| 229 : | U32 writeBounce_p(LLPartInitData *in, U32 startByte); | ||
| 230 : | U32 writeBounce_b(LLPartInitData *in, U32 startByte); | ||
| 231 : | //U32 writePos_ranges(LLPartInitData *in, U32 startByte); | ||
| 232 : | //U32 writeVel_ranges(LLPartInitData *in, U32 startByte); | ||
| 233 : | U32 writeAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte); | ||
| 234 : | U32 writeScale_range(LLPartInitData *in, U32 startByte); | ||
| 235 : | U32 writeAlpha_range(LLPartInitData *in, U32 startByte); | ||
| 236 : | U32 writeUUID(LLPartInitData *in, U32 startByte); | ||
| 237 : | |||
| 238 : | U32 writeVelocityOffset(LLPartInitData *in, U32 startByte); | ||
| 239 : | U32 writeSpawn(LLPartInitData *in, U32 startByte); //all spawn data | ||
| 240 : | U32 writeEnvironment(LLPartInitData *in, U32 startByte); //wind and gravity | ||
| 241 : | U32 writeLifespan(LLPartInitData *in, U32 startByte); //lifespan data - individual and global | ||
| 242 : | U32 writeDecayDamp(LLPartInitData *in, U32 startByte); //alpha and scale, and motion damp | ||
| 243 : | U32 writeWindDiffusionFactor(LLPartInitData *in, U32 startByte); | ||
| 244 : | |||
| 245 : | |||
| 246 : | //U32 readK(LLPartInitData *in, U32 startByte); | ||
| 247 : | U32 readKill_p(LLPartInitData *in, U32 startByte); | ||
| 248 : | U32 readBounce_p(LLPartInitData *in, U32 startByte); | ||
| 249 : | U32 readBounce_b(LLPartInitData *in, U32 startByte); | ||
| 250 : | //U32 readPos_ranges(LLPartInitData *in, U32 startByte); | ||
| 251 : | //U32 readVel_ranges(LLPartInitData *in, U32 startByte); | ||
| 252 : | U32 readAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte); | ||
| 253 : | U32 readScale_range(LLPartInitData *in, U32 startByte); | ||
| 254 : | U32 readAlpha_range(LLPartInitData *in, U32 startByte); | ||
| 255 : | U32 readUUID(LLPartInitData *in, U32 startByte); | ||
| 256 : | |||
| 257 : | U32 readVelocityOffset(LLPartInitData *in, U32 startByte); | ||
| 258 : | U32 readSpawn(LLPartInitData *in, U32 startByte); //all spawn data | ||
| 259 : | U32 readEnvironment(LLPartInitData *in, U32 startByte); //wind and gravity | ||
| 260 : | U32 readLifespan(LLPartInitData *in, U32 startByte); //lifespan data - individual and global | ||
| 261 : | U32 readDecayDamp(LLPartInitData *in, U32 startByte); //alpha and scale, and motion damp | ||
| 262 : | U32 readWindDiffusionFactor(LLPartInitData *in, U32 startByte); | ||
| 263 : | }; | ||
| 264 : | |||
| 265 : | #endif | ||
| 266 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

