aboutsummaryrefslogtreecommitdiff
path: root/Src/Winamp/plush/CAM.C
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/plush/CAM.C
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Winamp/plush/CAM.C')
-rw-r--r--Src/Winamp/plush/CAM.C52
1 files changed, 52 insertions, 0 deletions
diff --git a/Src/Winamp/plush/CAM.C b/Src/Winamp/plush/CAM.C
new file mode 100644
index 00000000..3d122a13
--- /dev/null
+++ b/Src/Winamp/plush/CAM.C
@@ -0,0 +1,52 @@
+/******************************************************************************
+Plush Version 1.2
+cam.c
+Camera Control
+Copyright (c) 1996-2000, Justin Frankel
+******************************************************************************/
+
+#include "plush.h"
+
+void plCamDelete(pl_Cam *c) {
+ if (c) free(c);
+}
+
+void plCamSetTarget(pl_Cam *c, pl_Float x, pl_Float y, pl_Float z) {
+ double dx, dy, dz;
+ dx = x - c->X;
+ dy = y - c->Y;
+ dz = z - c->Z;
+ c->Roll = 0;
+ if (dz > 0.0001f) {
+ c->Pan = (pl_Float) (-atan(dx/dz)*(180.0/PL_PI));
+ dz /= cos(c->Pan*(PL_PI/180.0));
+ c->Pitch = (pl_Float) (atan(dy/dz)*(180.0/PL_PI));
+ } else if (dz < -0.0001f) {
+ c->Pan = (pl_Float) (180.0-atan(dx/dz)*(180.0/PL_PI));
+ dz /= cos((c->Pan-180.0f)*(PL_PI/180.0));
+ c->Pitch = (pl_Float) (-atan(dy/dz)*(180.0/PL_PI));
+ } else {
+ c->Pan = 0.0f;
+ c->Pitch = -90.0f;
+ }
+}
+
+pl_Cam *plCamCreate(pl_uInt sw, pl_uInt sh, pl_Float ar, pl_Float fov,
+ pl_uChar *fb, pl_ZBuffer *zb) {
+ pl_Cam *c;
+ c = malloc(sizeof(pl_Cam));
+ if (!c) return 0;
+ memset(c,0,sizeof(pl_Cam));
+ c->Fov = fov;
+ c->AspectRatio = ar;
+ c->ClipRight = c->ScreenWidth = sw;
+ c->ClipBottom = c->ScreenHeight = sh;
+ c->CenterX = sw>>1;
+ c->CenterY = sh>>1;
+ c->ClipBack = 8.0e30f;
+ c->frameBuffer = fb;
+ c->zBuffer = zb;
+ c->Sort = 1;
+ if (zb) c->Sort = 0;
+ return (c);
+}