Author Topic: a friendly reminder to HiTech  (Read 7299 times)

Offline caldera

  • Platinum Member
  • ******
  • Posts: 6437
a friendly reminder to HiTech
« on: January 24, 2016, 10:45:50 AM »
Some time ago, you stated that in the future, you "would change the way bomber drone positioning is handled"  - IIRC.

Just wanted to remind you to please work that into AH3 before beta is finished, thanks.   :cheers:
"Then out spake brave Horatius, the Captain of the gate:
 To every man upon this earth, death cometh soon or late.
 And how can man die better, than facing fearful odds.
 For the ashes of his fathers and the temples of his Gods."

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12398
      • http://www.hitechcreations.com
Re: a friendly reminder to HiTech
« Reply #1 on: January 24, 2016, 12:28:29 PM »
Thanks for the reminder, Your welcome to remind me again in about a month. Will get to it after all is stable.

HiTech

Offline caldera

  • Platinum Member
  • ******
  • Posts: 6437
Re: a friendly reminder to HiTech
« Reply #2 on: January 24, 2016, 02:22:33 PM »



Thank You!!!
"Then out spake brave Horatius, the Captain of the gate:
 To every man upon this earth, death cometh soon or late.
 And how can man die better, than facing fearful odds.
 For the ashes of his fathers and the temples of his Gods."

Offline GrandpaChaps

  • Copper Member
  • **
  • Posts: 226
Re: a friendly reminder to HiTech
« Reply #3 on: January 24, 2016, 04:46:30 PM »
Thanks for the reminder, Your welcome to remind me again in about a month. Will get to it after all is stable.

HiTech

context, remind us again what the reminder and reference is??
Uncle Fred

Offline Zacherof

  • Gold Member
  • *****
  • Posts: 3993
Re: a friendly reminder to HiTech
« Reply #4 on: January 24, 2016, 06:49:20 PM »



Thank You!!!
How can I turn that gif into my avatar
In game name Xacherof
USN Sea Bee
**ELITE**
I am a meat popsicle

Offline caldera

  • Platinum Member
  • ******
  • Posts: 6437
Re: a friendly reminder to HiTech
« Reply #5 on: February 28, 2016, 11:09:02 AM »
Thanks for the reminder, Your welcome to remind me again in about a month. Will get to it after all is stable.

HiTech

It's been a month now.  Just checking in to remind you about the reminder.  :)
"Then out spake brave Horatius, the Captain of the gate:
 To every man upon this earth, death cometh soon or late.
 And how can man die better, than facing fearful odds.
 For the ashes of his fathers and the temples of his Gods."

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12398
      • http://www.hitechcreations.com
Re: a friendly reminder to HiTech
« Reply #6 on: February 28, 2016, 11:18:49 AM »
It's been a month now.  Just checking in to remind you about the reminder.  :)

Thanks this will be a good week to do it, only thing on my list to do is bug fixes.

HiTech

Offline caldera

  • Platinum Member
  • ******
  • Posts: 6437
Re: a friendly reminder to HiTech
« Reply #7 on: February 28, 2016, 11:34:14 AM »
Thank you sir!   :salute





I did at first buy you some very expensive scotch, but was worried that it might be damaged in transit.

That left me no choice but to consume it for safe keeping.   :cheers:
"Then out spake brave Horatius, the Captain of the gate:
 To every man upon this earth, death cometh soon or late.
 And how can man die better, than facing fearful odds.
 For the ashes of his fathers and the temples of his Gods."

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12398
      • http://www.hitechcreations.com
Re: a friendly reminder to HiTech
« Reply #8 on: February 28, 2016, 03:21:26 PM »
That left me no choice but to consume it for safe keeping.   :cheers:

Thank you very much for the thoughtfulness in keeping my scotch safe.

If ever I can return the favor , don't hesitate to ask.

HiTech :)

Offline Vulcan

  • Plutonium Member
  • *******
  • Posts: 9891
Re: a friendly reminder to HiTech
« Reply #9 on: February 28, 2016, 03:43:57 PM »
only thing on my list to do is bug fixes.

HiTech

and Oculus Rift support... right?

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12398
      • http://www.hitechcreations.com
Re: a friendly reminder to HiTech
« Reply #10 on: February 28, 2016, 07:34:25 PM »
and Oculus Rift support... right?

Actually I put about 10 hours in today at home writing the generic 2 eyes piece of the code.(this will is set up to be used with any type 3d like glasses)

Just rapped it up now after one strange minor thing has me by the short hairs.
If anyone is interested

This is my work starting from scratch today. Only had a vague idea of the design when I started.

Plus all the integration that has it all working except for a very strange zbuffer issue.

I did take a brake to make fry scallops for my family.



#include "system/syscfg.h"

#include <math.h>

#include "eyes/eyestype.h"
#include "cmr/cmrtype.h"
#include "rend/rendtype.h"
#include "ma/matype.h"
#include "gr3d/gr3drect.h"
#include "shdr/shdrtype.h"
#include "shdr/shdrpost.h"

typedef struct tag_EYE_DATA
{

   int CurrentEyeCnt;
   eyesEYE Eyes[eyesEI_MAX];
   int EyeBeingRenderd;
   float FOVScale;
   int UseOneRenderTarget;
   int InterlaceFrames;

}  _EYE_DATA;

static _EYE_DATA _eyesData;

void eyesInit(int EyeCnt,int InterlaceFrames)
{
   eyesKill();
   _eyesData.CurrentEyeCnt = EyeCnt;
   _eyesData.InterlaceFrames = InterlaceFrames;
   if (EyeCnt == 1)
   {
      return;
   }
}

void eyesKill(void)
{
   if (_eyesData.CurrentEyeCnt != 0)
   {
      rendtargReleaseRenderTarget(&_eyesData.Eyes[eyesEI_LEFT].RenderTarget);
      if (!_eyesData.InterlaceFrames)
      {
         rendtargReleaseRenderTarget(&_eyesData.Eyes[eyesEI_RIGHT].RenderTarget);
      }
      memset(&_eyesData, 0, sizeof(_EYE_DATA));
   }
}




int eyesInitEye(int EyeIndex,
                  const mafPOINT * CameraOffset,
                  const eyesFIELD_OF_VIEW * Fov,
                  const grRECT * EyeRect,
                  int TargetWidth,
                  int TargetHeight,
                  int ImageFormat,
                  int DepthFormat,
                  int PopulateRenderTarget)
{

   eyesEYE * Eye;

   if (EyeIndex == eyesEI_LEFT && !PopulateRenderTarget)
   {
      return -1;
   }

   Eye = &_eyesData.Eyes[EyeIndex];

   Eye->Fov = *Fov;
   Eye->PortRect = *EyeRect;
   Eye->Offset = *CameraOffset;
   if (PopulateRenderTarget)
   {
      rendtargPopulateRenderTarget(&Eye->RenderTarget, TargetWidth, TargetHeight, ImageFormat, DepthFormat);
      Eye->RenderTarget.PortRect = Eye->PortRect;
      _eyesData.UseOneRenderTarget = 0;
   }
   else
   {
      _eyesData.UseOneRenderTarget = 1;
   }
   return 0;
}

void eyesCalcEyeCamera(int EyeIndex, cmrCAMERA * EyeCamera,const  cmrCAMERA * PrimaryCamera)
{
   eyesEYE * Eye;
eyesFIELD_OF_VIEW ScaledFov;
maf4X4_MATRIX ProjMatrix;
float Width;
float Height;
madPOINT AtPnt;
madPOINT ViewPnt;

   Eye = &_eyesData.Eyes[EyeIndex];
   _eyesData.FOVScale = eyesCalcEyeFovScale(EyeIndex, PrimaryCamera->HorizontalFOV);


   ScaledFov.LeftTan = _eyesData.Eyes[EyeIndex].Fov.LeftTan * _eyesData.FOVScale;
   ScaledFov.RightTan = _eyesData.Eyes[EyeIndex].Fov.RightTan * _eyesData.FOVScale;
   ScaledFov.UpTan = _eyesData.Eyes[EyeIndex].Fov.UpTan * _eyesData.FOVScale;
   ScaledFov.DownTan = _eyesData.Eyes[EyeIndex].Fov.DownTan * _eyesData.FOVScale;

   eyesFillProjectionMatrix(&ScaledFov, &ProjMatrix, PrimaryCamera->NearPlane, PrimaryCamera->FarPlane);





   Width = (float)(_eyesData.Eyes[EyeIndex].PortRect.Right - _eyesData.Eyes[EyeIndex].PortRect.Left);
   Height = (float)(_eyesData.Eyes[EyeIndex].PortRect.Bottom - _eyesData.Eyes[EyeIndex].PortRect.Top);
   cmrSetProjectionMatrix(EyeCamera,&ProjMatrix,PrimaryCamera->NearPlane, PrimaryCamera->FarPlane,(float)Width / Height,0);
   EyeCamera->HorizontalFOV = (float)atan((ScaledFov.LeftTan + ScaledFov.RightTan) * 0.5f) * 2.0f;

   maADD_POINTS(ViewPnt, PrimaryCamera->ViewPnt, Eye->Offset);
   maADD_POINTS(AtPnt, ViewPnt, PrimaryCamera->Fwd);
   cmrLookAt(EyeCamera, &ViewPnt, &AtPnt, &PrimaryCamera->Up);

}

void    eyesBindEye(int EyeIndex,const cmrCAMERA * PrimaryCamera)
{
   eyesCalcEyeCamera(EyeIndex, &_eyesData.Eyes[EyeIndex].Camera, PrimaryCamera);
   cmrActivateCamera(&_eyesData.Eyes[EyeIndex].Camera);
   rendtargBindRenderTarget(&_eyesData.Eyes[EyeIndex].RenderTarget);
   rendportSetPort(&_eyesData.Eyes[EyeIndex].PortRect,0.0f,1.0f);
}

const cmrCAMERA * eyesGetCurrentCamera(void)
{
   return &_eyesData.Eyes[_eyesData.EyeBeingRenderd].Camera;
}

int eyesBeginRender(const cmrCAMERA * PrimaryCamera)
{
int EyeIndex;
   if (_eyesData.CurrentEyeCnt == 0)
   {
      return -1;
   }
   if (_eyesData.CurrentEyeCnt == 1)
   {
      _eyesData.Eyes[eyesEI_LEFT].Camera = *PrimaryCamera;
      return 1;
   }

   if (_eyesData.InterlaceFrames)
   {
      _eyesData.EyeBeingRenderd = !_eyesData.EyeBeingRenderd;
      
   }
   else
   {
      _eyesData.EyeBeingRenderd = eyesEI_LEFT;
   }

   EyeIndex = _eyesData.EyeBeingRenderd;
   eyesBindEye(EyeIndex,PrimaryCamera);
   rendportClearPort();

   if (_eyesData.InterlaceFrames)
   {
      return 1;
   }
   else
   {
      return 2;
   }
}

int eyesBeginNextEye(const cmrCAMERA * PrimaryCamera)
{
   int EyeIndex;
   if (_eyesData.InterlaceFrames)
   {
      return -1;
   }
   if (_eyesData.CurrentEyeCnt < 2)
   {
      return -1;
   }

   EyeIndex = _eyesData.EyeBeingRenderd;
   rendtargUnBindRenderTarget(&_eyesData.Eyes[EyeIndex].RenderTarget);

   _eyesData.EyeBeingRenderd = eyesEI_RIGHT;
   EyeIndex = _eyesData.EyeBeingRenderd;

   /* We need to copy every frame incase the target Changed */
   if (_eyesData.UseOneRenderTarget)
   {
      _eyesData.Eyes[eyesEI_RIGHT].RenderTarget = _eyesData.Eyes[eyesEI_LEFT].RenderTarget;
      _eyesData.Eyes[eyesEI_RIGHT].RenderTarget.PortRect = _eyesData.Eyes[eyesEI_RIGHT].PortRect;
   }

   eyesBindEye(EyeIndex, PrimaryCamera);
   
   return 0;
}

void eyesEndRender(void)
{
int EyeIndex;
   if (_eyesData.CurrentEyeCnt < 2)
   {
      return ;
   }

   EyeIndex = _eyesData.EyeBeingRenderd;
   rendtargUnBindRenderTarget(&_eyesData.Eyes[EyeIndex].RenderTarget);
}


void eyesFillProjectionMatrix(const eyesFIELD_OF_VIEW * EyeFov, maf4X4_MATRIX * Matrix, float Near, float Far)
{
   mafPOINT_W ScaleAndOffset;
   //float ProjMult;
   float Q;

   eyesCreateNDCScaleAndOffsetFr omFov(EyeFov, &ScaleAndOffset);

   Q = Far / (Far - Near);

   Matrix->Cell[0][0] = ScaleAndOffset.x;
   Matrix->Cell[0][1] = 0.0f;
   Matrix->Cell[0][2] = 0.0f;
   Matrix->Cell[0][3] = 0.0f;

   Matrix->Cell[1][0] = 0.0f;
   Matrix->Cell[1][1] = ScaleAndOffset.y;
   Matrix->Cell[1][2] = 0.0f;
   Matrix->Cell[1][3] = 0.0f;

   Matrix->Cell[2][0] = ScaleAndOffset.z;
   Matrix->Cell[2][1] = ScaleAndOffset.w;
   Matrix->Cell[2][2] = Q;
   Matrix->Cell[2][3] = 1.0f;

   Matrix->Cell[3][0] = 0.0f;
   Matrix->Cell[3][1] = 0.0f;
   Matrix->Cell[3][2] = -Near * Q;
   Matrix->Cell[3][3] = 0.0f;
}

void eyesCalcSimpleFov(eyesFIELD_OF_VIEW * Fov, float HorizontalFOV, float WidthOverHeightAspect)
{
   float VertFOV;

   Fov->LeftTan = (float)tan(HorizontalFOV * 0.5);
   Fov->RightTan = (float)tan(HorizontalFOV * 0.5);
   VertFOV = cmrCalcVerticalFOV(HorizontalFOV, WidthOverHeightAspect);
   Fov->UpTan = (float)tan(VertFOV * 0.5);
   Fov->DownTan = Fov->UpTan;

}

void eyesCreateNDCScaleAndOffsetFr omFov(const eyesFIELD_OF_VIEW * EyeFov, mafPOINT_W * Rtn)
{
   float projXScale = 2.0f / (EyeFov->LeftTan + EyeFov->RightTan);
   float projXOffset = (EyeFov->LeftTan - EyeFov->RightTan) * projXScale * 0.5f;

   float projYScale = 2.0f / (EyeFov->UpTan + EyeFov->DownTan);
   float projYOffset = (EyeFov->UpTan - EyeFov->DownTan) * projYScale * 0.5f;

   Rtn->x = projXScale;
   Rtn->y = projYScale;
   Rtn->z = projXOffset;
   Rtn->w = projYOffset;
   // Hey - why is that Y.Offset negated?
   // It's because a projection matrix transforms from world coords with Y=up,
   // whereas this is from NDC which is Y=down.

}

float eyesCalcEyeFovScale(int EyeIndex, float HorizontalFOV)
{
eyesEYE * Eye;
float BaseTan;
float NewTan;

   Eye = &_eyesData.Eyes[EyeIndex];
   BaseTan = Eye->Fov.LeftTan + Eye->Fov.RightTan;
   NewTan = (float)tan(HorizontalFOV * 0.5) * 2.0f;

   return BaseTan / NewTan;

}

void eyesRenderToScreen(void)
{
grRECT Rect;

   if (_eyesData.CurrentEyeCnt < 2)
      return;

   rendstateSetZBufferEnable(0);
   shdrpostBindTech(shdrpostPTI_COPY);
   shdrBindTextures(_eyesData.Eyes[eyesEI_LEFT].RenderTarget.ImageTexId, -1, NULL);
   gr3drectRenderScreenQuadRect(&_eyesData.Eyes[eyesEI_LEFT].PortRect,0.0f);


   shdrBindTextures(_eyesData.Eyes[eyesEI_RIGHT].RenderTarget.ImageTexId, -1, NULL);
   Rect = _eyesData.Eyes[eyesEI_LEFT].PortRect;
   Rect.Left = Rect.Right;
   Rect.Right *= 2;
   gr3drectRenderScreenQuadRect(&Rect,0.0f);

   shdrpostUnBindTech(shdrpostPTI_COPY);
   shdrBindTextures(-1, -1, NULL);
}






HiTech

Offline Vulcan

  • Plutonium Member
  • *******
  • Posts: 9891
Re: a friendly reminder to HiTech
« Reply #11 on: February 29, 2016, 02:15:14 AM »
<--- dry humping HTs leg.

 :x

Offline FTJR

  • Silver Member
  • ****
  • Posts: 1996
Re: a friendly reminder to HiTech
« Reply #12 on: February 29, 2016, 02:40:08 AM »
<--- dry humping HTs leg.

 :x

I think he'd prefer the scotch.
Bring the Beaufighter to Aces High
Raw Prawns      

B.O.S.S. "Beaufighter Operator Support Services" 
Storms and Aeroplanes dont mix

Offline puller

  • Gold Member
  • *****
  • Posts: 2210
Re: a friendly reminder to HiTech
« Reply #13 on: February 29, 2016, 09:03:39 AM »
Sorry to jump in here...and I know nothing of computer coding....

But I can not even begin to understand how all those different lines of text and characters make my cartoon airplane fly...

Is that was tells the 3d models what to do???  As a matter of fact...now I really don't know how this game even works now  :uhoh

When I pull the trigger are each of those tracer rounds that see some line of code that is interacting with other lines of code...

I'll stop now....  :salute Hitech   for all the hours of fun you provide for us...
"The road to Hell is paved with good intentions."
CO   Anti-Horde

Offline Ramesis

  • Silver Member
  • ****
  • Posts: 1300
Re: a friendly reminder to HiTech
« Reply #14 on: February 29, 2016, 01:57:02 PM »
Jeez HiTech... where is the assbly code!
Thats the only code I understand  :bhead
"Would you tell me, please,
 which way I ought to go from here?
 That depends a good deal on where
 you want to get to. Said the cat."
    Charles Lutwidge Dodgson a.k.a. Lewis Carroll