00001
00052 #define _EXPORT_CCL_
00053
00054 #include "CigiViewDefV3.h"
00055 #include "CigiSwapping.h"
00056 #include "CigiExceptions.h"
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 CigiViewDefV3::CigiViewDefV3()
00068 {
00069
00070 PacketID = CIGI_VIEW_DEF_PACKET_ID_V3;
00071 PacketSize = CIGI_VIEW_DEF_PACKET_SIZE_V3;
00072 Version = 3;
00073 MinorVersion = 0;
00074
00075 ViewID = 0;
00076 GroupID = 0;
00077 FOVNearEn = false;
00078 FOVFarEn = false;
00079 FOVLeftEn = false;
00080 FOVRightEn = false;
00081 FOVTopEn = false;
00082 FOVBottomEn = false;
00083 MirrorMode = MirrorNone;
00084 PixelReplicateMode = ReplicateNone;
00085 ProjectionType = Perspective;
00086 Reorder = false;
00087 ViewType = 0;
00088 TrackerAssigned = false;
00089 FOVNear = 0.0;
00090 FOVFar = 0.0;
00091 FOVLeft = 0.0;
00092 FOVRight = 0.0;
00093 FOVTop = 0.0;
00094 FOVBottom = 0.0;
00095
00096 }
00097
00098
00099
00100
00101 CigiViewDefV3::~CigiViewDefV3()
00102 {
00103
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113 int CigiViewDefV3::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00114 {
00115 PackPointer CDta;
00116
00117 CigiBaseViewDef * Data = ( CigiBaseViewDef *)Base;
00118
00119 CDta.c = Buff;
00120
00121 *CDta.c++ = PacketID;
00122 *CDta.c++ = PacketSize;
00123
00124 *CDta.s++ = Data->ViewID;
00125 *CDta.c++ = Data->GroupID;
00126
00127 Cigi_uint8 HDta = (Cigi_uint8)((Data->MirrorMode << 6) & 0xc0);
00128
00129 if(Data->FOVBottomEn)
00130 HDta |= 0x20;
00131
00132 if(Data->FOVTopEn)
00133 HDta |= 0x10;
00134
00135 if(Data->FOVRightEn)
00136 HDta |= 0x08;
00137
00138 if(Data->FOVLeftEn)
00139 HDta |= 0x04;
00140
00141 if(Data->FOVFarEn)
00142 HDta |= 0x02;
00143
00144 if(Data->FOVNearEn)
00145 HDta |= 0x01;
00146
00147 *CDta.c++ = HDta;
00148
00149 HDta = (Cigi_uint8)((Data->ViewType << 5) & 0xe0);
00150
00151 if(Data->Reorder)
00152 HDta |= 0x10;
00153
00154 if(Data->ProjectionType == Orthographic)
00155 HDta |= 0x08;
00156
00157 HDta |= (Cigi_uint8)(Data->PixelReplicateMode & 0x07);
00158
00159 *CDta.c++ = HDta;
00160 *CDta.c++ = 0;
00161
00162 *CDta.f++ = Data->FOVNear;
00163 *CDta.f++ = Data->FOVFar;
00164 *CDta.f++ = Data->FOVLeft;
00165 *CDta.f++ = Data->FOVRight;
00166 *CDta.f++ = Data->FOVTop;
00167 *CDta.f++ = Data->FOVBottom;
00168
00169 return(CIGI_VIEW_DEF_PACKET_SIZE_V3);
00170
00171 }
00172
00173
00174
00175
00176 int CigiViewDefV3::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00177 {
00178 PackPointer CDta;
00179
00180 CDta.c = Buff;
00181
00182 CDta.c += 2;
00183
00184
00185 if(!Swap)
00186 ViewID = *CDta.s++;
00187 else
00188 CigiSwap2(&ViewID, CDta.s++);
00189
00190 GroupID = *CDta.c++;
00191
00192 Cigi_uint8 HDta = *CDta.c++;
00193
00194 MirrorMode = (MirrorModeGrp)((HDta >> 6) & 0x03);
00195 FOVBottomEn = ((HDta & 0x20) != 0);
00196 FOVTopEn = ((HDta & 0x10) != 0);
00197 FOVRightEn = ((HDta & 0x08) != 0);
00198 FOVLeftEn = ((HDta & 0x04) != 0);
00199 FOVFarEn = ((HDta & 0x02) != 0);
00200 FOVNearEn = ((HDta & 0x01) != 0);
00201
00202 HDta = *CDta.c++;
00203
00204 ViewType = (HDta >> 5) & 0x07;
00205 Reorder = ((HDta & 0x10) != 0);
00206 ProjectionType = (ProjectionTypeGrp)((HDta >> 3) & 0x01);
00207 PixelReplicateMode = (PixelReplicateModeGrp)(HDta & 0x07);
00208
00209 CDta.c++;
00210
00211 if(!Swap)
00212 {
00213 FOVNear = *CDta.f++;
00214 FOVFar = *CDta.f++;
00215 FOVLeft = *CDta.f++;
00216 FOVRight = *CDta.f++;
00217 FOVTop = *CDta.f++;
00218 FOVBottom = *CDta.f++;
00219 }
00220 else
00221 {
00222 CigiSwap4(&FOVNear, CDta.f++);
00223 CigiSwap4(&FOVFar, CDta.f++);
00224 CigiSwap4(&FOVLeft, CDta.f++);
00225 CigiSwap4(&FOVRight, CDta.f++);
00226 CigiSwap4(&FOVTop, CDta.f++);
00227 CigiSwap4(&FOVBottom, CDta.f++);
00228 }
00229
00230 return(CIGI_VIEW_DEF_PACKET_SIZE_V3);
00231
00232
00233 }
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 int CigiViewDefV3::SetProjectionType(const ProjectionTypeGrp ProjectionTypeIn, bool bndchk)
00246 {
00247
00248 #ifndef CIGI_NO_BND_CHK
00249 if(bndchk && ((ProjectionType < 0)||(ProjectionType > 1)))
00250 {
00251 #ifndef CIGI_NO_EXCEPT
00252 throw CigiValueOutOfRangeException("ProjectionType",(ProjectionTypeGrp)ProjectionTypeIn,0,1);
00253 #endif
00254 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00255 }
00256 #endif
00257
00258 ProjectionType = ProjectionTypeIn;
00259 return(CIGI_SUCCESS);
00260
00261 }
00262
00263