00001
00055 #define _EXPORT_CCL_
00056
00057 #include "CigiSpecEffDefV1.h"
00058 #include "CigiSwapping.h"
00059 #include "CigiExceptions.h"
00060
00061 #include <memory.h>
00062
00063
00064 #ifdef CIGI_LITTLE_ENDIAN
00065 #define CIGI_SCOPY2 CigiSwap2
00066 #define CIGI_SCOPY4 CigiSwap4
00067 #define CIGI_SCOPY8 CigiSwap8
00068 #else
00069 #define CIGI_SCOPY2 CigiCopy2
00070 #define CIGI_SCOPY4 CigiCopy4
00071 #define CIGI_SCOPY8 CigiCopy8
00072 #endif
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 CigiSpecEffDefV1::CigiSpecEffDefV1()
00086 {
00087
00088 PacketID = CIGI_SPEC_EFF_DEF_PACKET_ID_V1;
00089 PacketSize = CIGI_SPEC_EFF_DEF_PACKET_SIZE_V1;
00090 Version = 1;
00091 MinorVersion = 0;
00092
00093 EntityID = 0;
00094 SeqDir = Forward;
00095 ColorEn = false;
00096 Red = 0;
00097 Green = 0;
00098 Blue = 0;
00099 XScale = 0.0;
00100 YScale = 0.0;
00101 ZScale = 0.0;
00102 TimeScale = 0.0;
00103 EffectCnt = 0;
00104 Separation = 0.0;
00105 BurstRate = 0.0;
00106 Duration = 0.0;
00107
00108 }
00109
00110
00111
00112
00113 CigiSpecEffDefV1::~CigiSpecEffDefV1()
00114 {
00115
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125 int CigiSpecEffDefV1::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00126 {
00127 double DBuf[6];
00128
00129 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00130
00131 PackPointer CDta;
00132
00133 CigiBaseSpecEffDef * Data = ( CigiBaseSpecEffDef *)Base;
00134
00135 CDta.d = DBuf;
00136
00137 *CDta.c++ = PacketID;
00138 *CDta.c++ = PacketSize;
00139
00140 CIGI_SCOPY2(CDta.s++, &Data->EntityID);
00141
00142 Cigi_uint8 HDta = (Data->SeqDir << 7) & 0x80;
00143 HDta |= (Data->ColorEn) ? 0x40 : 0;
00144 *CDta.c++ = HDta;
00145
00146 *CDta.c++ = Data->Red;
00147 *CDta.c++ = Data->Green;
00148 *CDta.c++ = Data->Blue;
00149
00150 float tfScl = (float)Data->XScale / 0.015625f;
00151 Cigi_int16 tsScl = (Cigi_int16)tfScl;
00152 CIGI_SCOPY2(CDta.h++, &tsScl);
00153
00154 tfScl = Data->YScale / 0.015625f;
00155 tsScl = (Cigi_int16)tfScl;
00156 CIGI_SCOPY2(CDta.h++, &tsScl);
00157
00158 tfScl = Data->ZScale / 0.015625f;
00159 tsScl = (Cigi_int16)tfScl;
00160 CIGI_SCOPY2(CDta.h++, &tsScl);
00161
00162 tfScl = Data->TimeScale / 0.015625f;
00163 tsScl = (Cigi_int16)tfScl;
00164 CIGI_SCOPY2(CDta.h++, &tsScl);
00165
00166 *CDta.s++ = 0;
00167
00168 CIGI_SCOPY2(CDta.s++, &Data->EffectCnt);
00169
00170 CIGI_SCOPY4(CDta.f++, &Data->Separation);
00171 CIGI_SCOPY4(CDta.f++, &Data->BurstRate);
00172 CIGI_SCOPY4(CDta.f++, &Data->Duration);
00173
00174
00175 memcpy(Buff,tBuf,CIGI_SPEC_EFF_DEF_PACKET_SIZE_V1);
00176
00177 return(PacketSize);
00178
00179 }
00180
00181
00182
00183
00184 int CigiSpecEffDefV1::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00185 {
00186 double DBuf[6];
00187
00188 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00189
00190 PackPointer CDta;
00191
00192 memcpy(tBuf,Buff,CIGI_SPEC_EFF_DEF_PACKET_SIZE_V1);
00193
00194 CDta.d = DBuf;
00195
00196 CDta.c += 2;
00197
00198 CIGI_SCOPY2(&EntityID, CDta.h++);
00199
00200 Cigi_uint8 HDta = *CDta.c++;
00201 SeqDir = (SeqDirGrp)((HDta >> 7) & 0x01);
00202 ColorEn = ((HDta & 0x40) != 0);
00203
00204 Red = *CDta.c++;
00205 Green = *CDta.c++;
00206 Blue = *CDta.c++;
00207
00208 Cigi_int16 tsScl;
00209
00210 CIGI_SCOPY2(&tsScl, CDta.h++);
00211 float tfScl = (float)tsScl;
00212 XScale = tfScl * 0.015625f;
00213
00214 CIGI_SCOPY2(&tsScl, CDta.h++);
00215 tfScl = (float)tsScl;
00216 YScale = tfScl * 0.015625f;
00217
00218 CIGI_SCOPY2(&tsScl, CDta.h++);
00219 tfScl = (float)tsScl;
00220 ZScale = tfScl * 0.015625f;
00221
00222 CIGI_SCOPY2(&tsScl, CDta.h++);
00223 tfScl = (float)tsScl;
00224 TimeScale = tfScl * 0.015625f;
00225
00226
00227 CDta.h++;
00228
00229 CIGI_SCOPY2(&EffectCnt, CDta.h++);
00230
00231 CIGI_SCOPY4(&Separation, CDta.f++);
00232 CIGI_SCOPY4(&BurstRate, CDta.f++);
00233 CIGI_SCOPY4(&Duration, CDta.f++);
00234
00235 return(PacketSize);
00236
00237 }
00238
00239
00240
00241
00242
00243
00244
00245