xp12camera

Owner: IIIlllIIIllI URL: git@github.com:nyangkosense/xp12camera.git

remove border

Commit 2831fa15e69d1429d992e3fe38a06b60fee4ad32 by SM <seb.michalk@gmail.com> on 2025-06-25 19:38:11 +0200
diff --git a/FLIR_Camera.cpp b/FLIR_Camera.cpp
index 8d28809..fb2266d 100644
--- a/FLIR_Camera.cpp
+++ b/FLIR_Camera.cpp
@@ -13,6 +13,7 @@
 
  #include <string.h>
  #include <stdio.h>
+ #include <stdlib.h>
  #include <math.h>
  #ifndef M_PI
  #define M_PI 3.14159265358979323846
@@ -456,46 +457,24 @@ static void DrawRealisticThermalOverlay(void)
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     
-    // Camera effect - dark vignette border for camera look
-    glColor4f(0.0f, 0.0f, 0.0f, 0.7f);
-    float borderSize = 60.0f;
-    glBegin(GL_QUADS);
-    // Top border
-    glVertex2f(0, 0);
-    glVertex2f(screenWidth, 0);
-    glVertex2f(screenWidth, borderSize);
-    glVertex2f(0, borderSize);
-    // Bottom border
-    glVertex2f(0, screenHeight - borderSize);
-    glVertex2f(screenWidth, screenHeight - borderSize);
-    glVertex2f(screenWidth, screenHeight);
-    glVertex2f(0, screenHeight);
-    // Left border
-    glVertex2f(0, 0);
-    glVertex2f(borderSize, 0);
-    glVertex2f(borderSize, screenHeight);
-    glVertex2f(0, screenHeight);
-    // Right border
-    glVertex2f(screenWidth - borderSize, 0);
-    glVertex2f(screenWidth, 0);
-    glVertex2f(screenWidth, screenHeight);
-    glVertex2f(screenWidth - borderSize, screenHeight);
-    glEnd();
-    
-    // Draw thermal border effect if thermal mode is active
+    // Noise filter effect for thermal camera realism
     if (gThermalMode > 0) {
-        glColor4f(0.0f, 1.0f, 0.0f, 0.2f); // Subtle green tint
-        glBegin(GL_QUADS);
-        // Top border
-        glVertex2f(borderSize, borderSize);
-        glVertex2f(screenWidth - borderSize, borderSize);
-        glVertex2f(screenWidth - borderSize, borderSize + 10);
-        glVertex2f(borderSize, borderSize + 10);
-        // Bottom border
-        glVertex2f(borderSize, screenHeight - borderSize - 10);
-        glVertex2f(screenWidth - borderSize, screenHeight - borderSize - 10);
-        glVertex2f(screenWidth - borderSize, screenHeight - borderSize);
-        glVertex2f(borderSize, screenHeight - borderSize);
+        glColor4f(0.8f, 0.8f, 0.8f, 0.1f);
+        glBegin(GL_POINTS);
+        for (int i = 0; i < 500; i++) {
+            float x = (rand() % screenWidth);
+            float y = (rand() % screenHeight);
+            glVertex2f(x, y);
+        }
+        glEnd();
+        
+        // Subtle scan lines
+        glColor4f(0.7f, 0.7f, 0.7f, 0.05f);
+        glBegin(GL_LINES);
+        for (int y = 0; y < screenHeight; y += 4) {
+            glVertex2f(0, y);
+            glVertex2f(screenWidth, y);
+        }
         glEnd();
     }
     
@@ -505,9 +484,9 @@ static void DrawRealisticThermalOverlay(void)
     
     // Set color based on lock status
     if (IsLockOnActive()) {
-        glColor4f(1.0f, 0.0f, 0.0f, 0.8f); // Red when locked
+        glColor4f(1.0f, 0.0f, 0.0f, 0.9f); // Red when locked
     } else {
-        glColor4f(0.0f, 1.0f, 0.0f, 0.8f); // Green when scanning
+        glColor4f(0.0f, 1.0f, 0.0f, 0.9f); // Green when scanning
     }
     
     glLineWidth(2.0f);
@@ -554,23 +533,8 @@ static void DrawRealisticThermalOverlay(void)
     
     glEnd();
     
-    
-    // Corner indicators
-    glBegin(GL_LINES);
-    // Top corners
-    glVertex2f(borderSize + 20, borderSize + 20);
-    glVertex2f(borderSize + 40, borderSize + 20);
-    glVertex2f(borderSize + 20, borderSize + 20);
-    glVertex2f(borderSize + 20, borderSize + 40);
-    
-    glVertex2f(screenWidth - borderSize - 20, borderSize + 20);
-    glVertex2f(screenWidth - borderSize - 40, borderSize + 20);
-    glVertex2f(screenWidth - borderSize - 20, borderSize + 20);
-    glVertex2f(screenWidth - borderSize - 20, borderSize + 40);
-    glEnd();
-    
     // Center dot
-    glPointSize(4.0f);
+    glPointSize(3.0f);
     glBegin(GL_POINTS);
     glVertex2f(centerX, centerY);
     glEnd();
diff --git a/FLIR_Camera.o b/FLIR_Camera.o
index 60dc31d..6c33f07 100644
Binary files a/FLIR_Camera.o and b/FLIR_Camera.o differ
diff --git a/FLIR_HUD.lua b/FLIR_HUD.lua
index 45e06c8..2efa88c 100644
--- a/FLIR_HUD.lua
+++ b/FLIR_HUD.lua
@@ -16,8 +16,8 @@ local ground_speed_ref = dataref_table("sim/flightmodel/position/groundspeed")
 local heading_ref = dataref_table("sim/flightmodel/position/psi")
 
 function draw_flir_hud()
-    -- Only draw HUD when FLIR camera is actually active
-    if view_type_ref[0] == 1026 and manipulator_ref[0] == 1 then  -- External view AND camera active
+    -- Only draw HUD when in external view (camera view)
+    if view_type_ref[0] == 1026 then  -- External view
         -- Get basic aircraft data safely using pre-declared datarefs
         local zulu_time = zulu_time_ref[0]
         local latitude = latitude_ref[0]
diff --git a/FLIR_LockOn.cpp b/FLIR_LockOn.cpp
index b8d2c90..fb6e301 100644
--- a/FLIR_LockOn.cpp
+++ b/FLIR_LockOn.cpp
@@ -87,7 +87,7 @@ void UpdateCameraToLockPoint(float* outPan, float* outTilt)
         return;
     }
     
-    // Get current aircraft position
+    // Get current aircraft position and orientation
     float planeX = XPLMGetDataf(gPlaneX);
     float planeY = XPLMGetDataf(gPlaneY);
     float planeZ = XPLMGetDataf(gPlaneZ);
@@ -109,21 +109,33 @@ void UpdateCameraToLockPoint(float* outPan, float* outTilt)
         return;
     }
     
-    // Calculate required camera angles
+    // Calculate absolute heading to target (in world coordinates)
     float targetHeading = atan2(dx, dz) * 180.0f / M_PI;
+    
+    // Calculate tilt angle to target
     float targetTilt = atan2(dy, horizontalDist) * 180.0f / M_PI;
     
-    // Convert to camera-relative angles
+    // Convert absolute world heading to relative camera pan
+    // This is the key fix - we need to account for aircraft heading changes
     *outPan = targetHeading - planeHeading;
     *outTilt = targetTilt;
     
-    // Normalize pan angle to -180 to +180
+    // Normalize pan angle to -180 to +180 degrees
     while (*outPan > 180.0f) *outPan -= 360.0f;
     while (*outPan < -180.0f) *outPan += 360.0f;
     
-    // Clamp tilt to reasonable limits
-    if (*outTilt > 90.0f) *outTilt = 90.0f;
+    // Clamp tilt to reasonable camera limits
+    if (*outTilt > 45.0f) *outTilt = 45.0f;
     if (*outTilt < -90.0f) *outTilt = -90.0f;
+    
+    // Update stored angles for reference
+    gLockOnPan = *outPan;
+    gLockOnTilt = *outTilt;
+    
+    char debugMsg[256];
+    sprintf(debugMsg, "FLIR Lock-On: Target at %.1f°, Pan=%.1f°, Tilt=%.1f°, Dist=%.1fm\n", 
+            targetHeading, *outPan, *outTilt, totalDist);
+    // Uncomment for debugging: XPLMDebugString(debugMsg);
 }
 
 void DisableLockOn()
diff --git a/FLIR_LockOn.o b/FLIR_LockOn.o
index 34c3a2b..4e16b9a 100644
Binary files a/FLIR_LockOn.o and b/FLIR_LockOn.o differ
diff --git a/build/FLIR_Camera/win_x64/FLIR_Camera.xpl b/build/FLIR_Camera/win_x64/FLIR_Camera.xpl
index 596e120..654763d 100755
Binary files a/build/FLIR_Camera/win_x64/FLIR_Camera.xpl and b/build/FLIR_Camera/win_x64/FLIR_Camera.xpl differ