#include "BaseType.h"#include "Vec3d.h"#include "XForm3d.h"#include "GETypes.h"Go to the source code of this file.
Typedefs | |
| typedef geCamera | geCamera |
Functions | |
| GENESISAPI geCamera *GENESISCC | geCamera_Create (geFloat Fov, const geRect *Rect) |
| GENESISAPI void GENESISCC | geCamera_Destroy (geCamera **pCamera) |
| GENESISAPI void GENESISCC | geCamera_SetZScale (geCamera *Camera, geFloat ZScale) |
| GENESISAPI geFloat GENESISCC | geCamera_GetZScale (const geCamera *Camera) |
| GENESISAPI void GENESISCC | geCamera_SetFarClipPlane (geCamera *Camera, geBoolean Enable, geFloat ZFar) |
| GENESISAPI void GENESISCC | geCamera_GetFarClipPlane (const geCamera *Camera, geBoolean *Enable, geFloat *ZFar) |
| GENESISAPI void GENESISCC | geCamera_GetClippingRect (const geCamera *Camera, geRect *Rect) |
| void GENESISCC | geCamera_GetWidthHeight (const geCamera *Camera, geFloat *Width, geFloat *Height) |
| geFloat GENESISCC | geCamera_GetScale (const geCamera *Camera) |
| GENESISAPI void GENESISCC | geCamera_SetAttributes (geCamera *Camera, geFloat Fov, const geRect *Rect) |
| void | geCamera_FillDriverInfo (geCamera *Camera) |
| GENESISAPI void GENESISCC | geCamera_ScreenPointToWorld (const geCamera *Camera, int32 ScreenX, int32 ScreenY, geVec3d *Vector) |
| GENESISAPI void GENESISCC | geCamera_Project (const geCamera *Camera, const geVec3d *PointInCameraSpace, geVec3d *ProjectedPoint) |
| GENESISAPI void GENESISCC | geCamera_ProjectZ (const geCamera *Camera, const geVec3d *PointInCameraSpace, geVec3d *ProjectedPoint) |
| void GENESISCC | geCamera_ProjectAndClamp (const geCamera *Camera, const geVec3d *PointInCameraSpace, geVec3d *ProjectedPoint) |
| void GENESISCC | geCamera_GetViewAngleXSinCos (const geCamera *Camera, geFloat *SinAngle, geFloat *CosAngle) |
| void GENESISCC | geCamera_GetViewAngleYSinCos (const geCamera *Camera, geFloat *SinAngle, geFloat *CosAngle) |
| GENESISAPI void GENESISCC | geCamera_Transform (const geCamera *Camera, const geVec3d *WorldSpacePoint, geVec3d *CameraSpacePoint) |
| GENESISAPI void GENESISCC | geCamera_TransformArray (const geCamera *Camera, const geVec3d *WorldSpacePointPtr, geVec3d *CameraSpacePointPtr, int count) |
| GENESISAPI void GENESISCC | geCamera_TransformAndProjectArray (const geCamera *Camera, const geVec3d *WorldSpacePointPtr, geVec3d *ProjectedSpacePointPtr, int count) |
| GENESISAPI void GENESISCC | geCamera_TransformAndProjectLArray (const geCamera *Camera, const GE_LVertex *WorldSpacePointPtr, GE_TLVertex *ProjectedSpacePointPtr, int count) |
| GENESISAPI void GENESISCC | geCamera_TransformAndProject (const geCamera *Camera, const geVec3d *Point, geVec3d *ProjectedPoint) |
| GENESISAPI void GENESISCC | geCamera_TransformAndProjectL (const geCamera *Camera, const GE_LVertex *Point, GE_TLVertex *ProjectedPoint) |
| GENESISAPI geBoolean GENESISCC | geCamera_SetWorldSpaceXForm (geCamera *Camera, const geXForm3d *XForm) |
| GENESISAPI geBoolean GENESISCC | geCamera_SetWorldSpaceVisXForm (geCamera *Camera, const geXForm3d *XForm) |
| GENESISAPI const geXForm3d *GENESISCC | geCamera_GetWorldSpaceXForm (const geCamera *Camera) |
| GENESISAPI const geXForm3d *GENESISCC | geCamera_GetCameraSpaceXForm (const geCamera *Camera) |
| GENESISAPI const geXForm3d *GENESISCC | geCamera_GetCameraSpaceVisXForm (const geCamera *Camera) |
| GENESISAPI const geXForm3d *GENESISCC | geCamera_GetWorldSpaceVisXForm (const geCamera *Camera) |
| GENESISAPI const geVec3d *GENESISCC | geCamera_GetPov (const geCamera *Camera) |
| const geVec3d *GENESISCC | geCamera_GetVisPov (const geCamera *Camera) |
| GENESISAPI geBoolean GENESISCC | geCamera_ConvertWorldSpaceToCameraSpace (const geXForm3d *WXForm, geXForm3d *CXForm) |
|
|
|
|
||||||||||||
|
Definition at line 709 of file Camera.c.
00710 {
00711 // The rotation portion is just the transpose of the model xform
00712 CXForm->AX = WXForm->AX;
00713 CXForm->AY = WXForm->BX;
00714 CXForm->AZ = WXForm->CX;
00715
00716 CXForm->BX = WXForm->AY;
00717 CXForm->BY = WXForm->BY;
00718 CXForm->BZ = WXForm->CY;
00719
00720 CXForm->CX = WXForm->AZ;
00721 CXForm->CY = WXForm->BZ;
00722 CXForm->CZ = WXForm->CZ;
00723
00724 CXForm->Translation = WXForm->Translation;
00725
00726 geVec3d_Inverse(&CXForm->Translation);
00727
00728 // Rotate the translation in the new camera matrix
00729 geXForm3d_Rotate(CXForm, &CXForm->Translation, &CXForm->Translation);
00730
00731 return GE_TRUE;
00732 }
|
|
||||||||||||
|
Definition at line 79 of file Camera.c.
00080 {
00081 geCamera *Camera;
00082
00083 assert( Rect != NULL );
00084
00085 Camera = GE_RAM_ALLOCATE_STRUCT(geCamera);
00086 if (Camera == NULL)
00087 {
00088 geErrorLog_Add(-1, NULL); //FIXME
00089 return NULL;
00090 }
00091
00092 memset(Camera, 0, sizeof(geCamera));
00093
00094 Camera->ZScale = 0.5f;
00095
00096 #if 0
00097 Camera->ZFar = 1000.0f;
00098 Camera->ZFarEnable = GE_TRUE;
00099 #endif
00100
00101 geCamera_SetAttributes(Camera,Fov,Rect);
00102 return Camera;
00103 }
|
|
|
Definition at line 108 of file Camera.c.
00109 {
00110 assert( pCamera != NULL );
00111 assert( *pCamera != NULL );
00112 geRam_Free(*pCamera);
00113 *pCamera = NULL;
00114 }
|
|
|
Definition at line 259 of file Camera.c.
00260 {
00261 // this is for the software driver to cache out some stuff
00262
00263 #pragma message ("Camera.c : remove _FillDriverInfo, and thereby GlobalInfo!" )
00264 extern GInfo GlobalInfo;
00265 assert(Camera);
00266
00267 GlobalInfo.XScale =-Camera->Scale;
00268 GlobalInfo.YScale =-Camera->Scale;
00269 GlobalInfo.XScaleInv =1.0f / GlobalInfo.XScale;
00270 GlobalInfo.YScaleInv =1.0f / GlobalInfo.YScale;
00271 GlobalInfo.XCenter =Camera->XCenter;
00272 GlobalInfo.YCenter =Camera->YCenter;
00273
00274 // Temp hack
00275 GlobalInfo.CXForm =Camera->XForm;
00276 GlobalInfo.Pov =Camera->Pov;
00277 GlobalInfo.ZScale =Camera->ZScale;
00278
00279 geXForm3d_Rotate(&Camera->XForm, &GlobalInfo.Pov, &GlobalInfo.CPov);
00280 }
|
|
|
Definition at line 660 of file Camera.c. References GENESISAPI, GENESISCC, NULL, geCamera::UseVisPov, geCamera::VisXForm, and geCamera::XForm.
|
|
|
Definition at line 651 of file Camera.c.
00652 {
00653 assert(Camera != NULL);
00654 return &(Camera->XForm);
00655 }
|
|
||||||||||||
|
Definition at line 159 of file Camera.c.
|
|
||||||||||||||||
|
Definition at line 148 of file Camera.c.
00149 {
00150 assert(Camera);
00151
00152 *Enable = Camera->ZFarEnable;
00153 *ZFar = Camera->ZFar;
00154 }
|
|
|
Definition at line 686 of file Camera.c.
00687 {
00688 assert( Camera != NULL );
00689 return &(Camera->Pov);
00690 }
|
|
|
Definition at line 185 of file Camera.c. References geFloat, GENESISCC, NULL, and geCamera::Scale. Referenced by RenderTexturedPoint().
00186 {
00187 assert( Camera != NULL );
00188
00189 return Camera->Scale;
00190 }
|
|
||||||||||||||||
|
Definition at line 441 of file Camera.c. References geCamera::CosViewAngleX, GENESISCC, NULL, and geCamera::SinViewAngleX. Referenced by Frustum_SetFromCamera().
00442 {
00443 assert( Camera != NULL );
00444 assert( SinAngle );
00445 assert( CosAngle );
00446 *SinAngle = Camera->SinViewAngleX;
00447 *CosAngle = Camera->CosViewAngleX;
00448 }
|
|
||||||||||||||||
|
Definition at line 453 of file Camera.c. References geCamera::CosViewAngleY, GENESISCC, NULL, and geCamera::SinViewAngleY. Referenced by Frustum_SetFromCamera().
00454 {
00455 assert( Camera != NULL );
00456 assert( SinAngle );
00457 assert( CosAngle );
00458 *SinAngle = Camera->SinViewAngleY;
00459 *CosAngle = Camera->CosViewAngleY;
00460 }
|
|
|
Definition at line 695 of file Camera.c. References GENESISCC, NULL, geCamera::Pov, geCamera::UseVisPov, and geCamera::VisPov. Referenced by Vis_VisWorld().
|
|
||||||||||||||||
|
Definition at line 172 of file Camera.c. References GENESISCC, geCamera::Height, NULL, and geCamera::Width. Referenced by geEngine_RenderWorld().
|
|
|
Definition at line 673 of file Camera.c.
00674 {
00675 assert(Camera != NULL);
00676
00677 if (Camera->UseVisPov)
00678 return &(Camera->TransposeVisXForm);
00679 else
00680 return &(Camera->TransposeXForm);
00681 }
|
|
|
Definition at line 642 of file Camera.c.
00643 {
00644 assert(Camera );
00645 return &(Camera->TransposeXForm);
00646 }
|
|
|
Definition at line 128 of file Camera.c.
00129 {
00130 assert(Camera);
00131 return Camera->ZScale;
00132 }
|
|
||||||||||||||||
|
Definition at line 322 of file Camera.c.
00328 {
00329 geFloat ScaleOverZ;
00330 geFloat Z;
00331 assert( Camera != NULL );
00332 assert( PointInCameraSpace != NULL );
00333 assert( ProjectedPoint != NULL );
00334
00335 Z = -PointInCameraSpace->Z;
00336
00337 if (Z < CAMERA_MINIMUM_PROJECTION_DISTANCE)
00338 {
00339 Z = CAMERA_MINIMUM_PROJECTION_DISTANCE;
00340 }
00341
00342 ScaleOverZ = Camera->Scale / Z;
00343
00344 ProjectedPoint->Z = Z*Camera->ZScale;
00345
00346 ProjectedPoint->X = ( PointInCameraSpace->X * ScaleOverZ ) + Camera->XCenter;
00347
00348 ProjectedPoint->Y = Camera->YCenter - ( PointInCameraSpace->Y * ScaleOverZ );
00349 }
|
|
||||||||||||||||
|
Definition at line 393 of file Camera.c. References geCamera::Bottom, CAMERA_MINIMUM_PROJECTION_DISTANCE, geFloat, GENESISCC, geCamera::Left, NULL, geCamera::Right, geCamera::Scale, geCamera::Top, geVec3d::X, geCamera::XCenter, geVec3d::Y, geCamera::YCenter, geVec3d::Z, Z, and geCamera::ZScale. Referenced by Frustum_Project(), Frustum_ProjectRGB(), and Frustum_ProjectRGBA().
00400 {
00401 geFloat ScaleOverZ;
00402 geFloat X,Y,Z;
00403 assert( Camera != NULL );
00404 assert( PointInCameraSpace != NULL );
00405 assert( ProjectedPoint != NULL );
00406
00407 Z = -PointInCameraSpace->Z;
00408
00409 if (Z < CAMERA_MINIMUM_PROJECTION_DISTANCE)
00410 {
00411 Z = CAMERA_MINIMUM_PROJECTION_DISTANCE;
00412 }
00413
00414 ScaleOverZ = Camera->Scale / Z;
00415
00416 ProjectedPoint->Z = Z*Camera->ZScale;
00417
00418 X = ( PointInCameraSpace->X * ScaleOverZ ) + Camera->XCenter;
00419
00420 if (X < Camera->Left)
00421 X = Camera->Left;
00422 else if (X > Camera->Right)
00423 X = Camera->Right;
00424
00425 ProjectedPoint->X = X;
00426
00427 Y = Camera->YCenter - ( PointInCameraSpace->Y * ScaleOverZ );
00428
00429 if (Y < Camera->Top)
00430 Y = Camera->Top;
00431 else if (Y > Camera->Bottom)
00432 Y = Camera->Bottom;
00433
00434 ProjectedPoint->Y = Y;
00435 }
|
|
||||||||||||||||
|
Definition at line 355 of file Camera.c. References CAMERA_MINIMUM_PROJECTION_DISTANCE, geFloat, GENESISAPI, GENESISCC, NULL, OneOverZ, geCamera::Scale, geVec3d::X, geCamera::XCenter, geVec3d::Y, geCamera::YCenter, geVec3d::Z, and Z. Referenced by geBodyInst_GetGeometry().
00362 {
00363 geFloat OneOverZ;
00364 geFloat ScaleOverZ;
00365 geFloat Z;
00366 assert( Camera != NULL );
00367 assert( PointInCameraSpace != NULL );
00368 assert( ProjectedPoint != NULL );
00369
00370 Z = -PointInCameraSpace->Z;
00371
00372 if (Z < CAMERA_MINIMUM_PROJECTION_DISTANCE)
00373 {
00374 Z = CAMERA_MINIMUM_PROJECTION_DISTANCE;
00375 }
00376
00377 OneOverZ = 1.0f / Z;
00378 ScaleOverZ = Camera->Scale * (OneOverZ);
00379
00380 ProjectedPoint->Z = OneOverZ;
00381
00382 ProjectedPoint->X = ( PointInCameraSpace->X * ScaleOverZ ) + Camera->XCenter;
00383
00384 ProjectedPoint->Y = Camera->YCenter - ( PointInCameraSpace->Y * ScaleOverZ );
00385 }
|
|
||||||||||||||||||||
|
Definition at line 285 of file Camera.c.
00291 {
00292 geVec3d In,Left,Up;
00293 geVec3d ScaledIn,ScaledLeft,ScaledUp ;
00294 geFloat XCenter ;
00295 geFloat YCenter ;
00296 geFloat Scale ;
00297 const geXForm3d *pM;
00298
00299 pM = &(Camera->TransposeXForm);
00300 XCenter = Camera->XCenter ;
00301 YCenter = Camera->YCenter ;
00302 Scale = Camera->Scale ;
00303
00304 geXForm3d_GetIn( pM, &In ) ;
00305 geXForm3d_GetLeft( pM, &Left ) ;
00306 geXForm3d_GetUp( pM, &Up ) ;
00307
00308 geVec3d_Scale(&In, Scale, &ScaledIn);
00309 geVec3d_Scale(&Left, XCenter - ((geFloat)ScreenX), &ScaledLeft );
00310 geVec3d_Scale(&Up, YCenter - ((geFloat)ScreenY), &ScaledUp );
00311
00312 geVec3d_Copy(&ScaledIn, Vector);
00313 geVec3d_Add(Vector, &ScaledLeft, Vector );
00314 geVec3d_Add(Vector, &ScaledUp, Vector );
00315 geVec3d_Normalize(Vector);
00316 }
|
|
||||||||||||||||
|
Definition at line 195 of file Camera.c.
00196 {
00197
00198 #define TOO_SMALL (0.0001f) // width and Fov must be >= TOO_SMALL
00199
00200 geFloat Width, Height;
00201 geFloat OneOverFov;
00202
00203 assert (Camera != NULL);
00204 assert (Rect != NULL);
00205 assert (! ((Fov < TOO_SMALL) && (Fov > -TOO_SMALL)));
00206
00207 Width = (geFloat)(Rect->Right - Rect->Left)+1.0f;
00208 Height = (geFloat)(Rect->Bottom - Rect->Top)+1.0f;
00209
00210 assert( Width > 0.0f );
00211 assert( Height > 0.0f );
00212
00213 Camera->Width = Width;
00214 Camera->Height = Height;
00215
00216 Camera->Fov = Fov;
00217
00218 if ((Camera->Fov < TOO_SMALL) && (Camera->Fov > -TOO_SMALL))
00219 Camera->Fov = TOO_SMALL; // Just in case
00220
00221 OneOverFov = 1.0f/Fov;
00222
00223 if (Width <=0.0f)
00224 Width = TOO_SMALL; // Just in case
00225 if (Height <=0.0f)
00226 Height = TOO_SMALL; // Just in case
00227
00228 Camera->XRatio = Width * OneOverFov;
00229 Camera->YRatio = Height * OneOverFov;
00230
00231 Camera->Scale = max(Camera->XRatio, Camera->YRatio);
00232 //Camera->YScale = Camera->XScale;
00233
00234 Camera->Left = (geFloat)Rect->Left;
00235 Camera->Right = (geFloat)Rect->Right;
00236 Camera->Top = (geFloat)Rect->Top;
00237 Camera->Bottom = (geFloat)Rect->Bottom;
00238
00239 Camera->XCenter = Camera->Left + ( Width * 0.5f ) - 0.5f;
00240 Camera->YCenter = Camera->Top + ( Height * 0.5f ) - 0.5f;
00241
00242 {
00243 geFloat Numerator = 2.0f * OneOverFov * Camera->Scale;
00244 double Angle;
00245 Angle = atan(Numerator / Camera->XRatio);
00246 Camera->CosViewAngleX = (geFloat)cos(Angle);
00247 Camera->SinViewAngleX = (geFloat)sin(Angle);
00248
00249 Angle = atan(Numerator / Camera->YRatio);
00250 Camera->CosViewAngleY = (geFloat)cos(Angle);
00251 Camera->SinViewAngleY = (geFloat)sin(Angle);
00252 }
00253 }
|
|
||||||||||||||||
|
Definition at line 137 of file Camera.c.
00138 {
00139 assert(Camera);
00140
00141 Camera->ZFarEnable = Enable;
00142 Camera->ZFar = ZFar;
00143 }
|
|
||||||||||||
|
Definition at line 618 of file Camera.c.
00619 {
00620 assert(Camera != NULL);
00621
00622 if (XForm)
00623 {
00624 Camera->TransposeVisXForm = *XForm; // Make a copy of the original XForm
00625 Camera->VisPov = XForm->Translation;
00626 geXForm3d_GetTranspose(XForm, &Camera->VisXForm);
00627
00628 Camera->UseVisPov = GE_TRUE;
00629 }
00630 else
00631 {
00632 Camera->UseVisPov = GE_FALSE;
00633 }
00634
00635 return GE_TRUE;
00636 }
|
|
||||||||||||
|
Definition at line 599 of file Camera.c.
00600 {
00601 assert(Camera != NULL);
00602 assert(XForm != NULL);
00603
00604 Camera->TransposeXForm = *XForm; // Make a copy of the model XForm
00605
00606 // Convert the model transform into a camera xform...
00607 //geCamera_ConvertModelToCamera(XForm, &Camera->XForm);
00608 geXForm3d_GetTranspose(XForm, &Camera->XForm);
00609
00610 Camera->Pov = XForm->Translation;
00611
00612 return GE_TRUE;
00613 }
|
|
||||||||||||
|
Definition at line 119 of file Camera.c.
00120 {
00121 assert(Camera);
00122 Camera->ZScale = ZScale;
00123 }
|
|
||||||||||||||||
|
Definition at line 465 of file Camera.c.
00468 {
00469 assert( Camera );
00470 assert( WorldSpacePoint );
00471 assert( CameraSpacePoint );
00472
00473 // Would be better if xform3d_transform was assembly, or a macro, or anything
00474 geXForm3d_Transform(&(Camera->XForm),WorldSpacePoint,CameraSpacePoint);
00475 }
|
|
||||||||||||||||
|
Definition at line 531 of file Camera.c.
00537 {
00538 geFloat Z;
00539
00540 assert( Camera );
00541 assert( Point );
00542 assert( ProjectedPoint );
00543
00544 geXForm3d_Transform(&(Camera->XForm),Point,ProjectedPoint);
00545
00546 Z = - ProjectedPoint->Z;
00547
00548 Z = max(Z,CAMERA_MINIMUM_PROJECTION_DISTANCE);
00549
00550 ProjectedPoint->Z = Z*Camera->ZScale;
00551
00552 Z = Camera->Scale / Z;
00553
00554 ProjectedPoint->X = ( ProjectedPoint->X * Z ) + Camera->XCenter;
00555 ProjectedPoint->Y = - ( ProjectedPoint->Y * Z ) + Camera->YCenter;
00556 }
|
|
||||||||||||||||||||
|
Definition at line 498 of file Camera.c.
00502 {
00503 assert( Camera );
00504 assert( WorldSpacePointPtr );
00505 assert( ProjectedSpacePointPtr );
00506 while(count--)
00507 {
00508 geCamera_TransformAndProject(Camera,WorldSpacePointPtr++,ProjectedSpacePointPtr++);
00509 }
00510 }
|
|
||||||||||||||||
|
Definition at line 562 of file Camera.c.
00568 {
00569 geFloat ScaleOverZ;
00570 geFloat Z;
00571
00572 assert( Camera );
00573 assert( Point );
00574 assert( ProjectedPoint );
00575
00576 geXForm3d_Transform(&(Camera->XForm),(geVec3d *)Point,(geVec3d *)ProjectedPoint);
00577
00578 Z = - ProjectedPoint->z;
00579
00580 Z = max(Z,CAMERA_MINIMUM_PROJECTION_DISTANCE);
00581
00582 ScaleOverZ = Camera->Scale / Z;
00583
00584 ProjectedPoint->z = Z*Camera->ZScale;
00585 ProjectedPoint->x = ( ProjectedPoint->x * ScaleOverZ ) + Camera->XCenter;
00586 ProjectedPoint->y = - ( ProjectedPoint->y * ScaleOverZ ) + Camera->YCenter;
00587
00588 ProjectedPoint->u = Point->u;
00589 ProjectedPoint->v = Point->v;
00590 ProjectedPoint->r = Point->r;
00591 ProjectedPoint->g = Point->g;
00592 ProjectedPoint->b = Point->b;
00593 ProjectedPoint->a = Point->a;
00594 }
|
|
||||||||||||||||||||
|
Definition at line 515 of file Camera.c.
00518 {
00519 assert( Camera );
00520 assert( WorldSpacePointPtr );
00521 assert( ProjectedSpacePointPtr );
00522 while(count--)
00523 {
00524 geCamera_TransformAndProjectL(Camera,WorldSpacePointPtr++,ProjectedSpacePointPtr++);
00525 }
00526 }
|
|
||||||||||||||||||||
|
Definition at line 481 of file Camera.c.
00484 {
00485 assert( Camera );
00486 assert( WorldSpacePointPtr );
00487 assert( CameraSpacePointPtr );
00488 // use transformarray!!
00489 while(count--)
00490 {
00491 geXForm3d_Transform(&(Camera->XForm),WorldSpacePointPtr++,CameraSpacePointPtr++);
00492 }
00493 }
|
1.3.2