129 lines
No EOL
3.4 KiB
C++
129 lines
No EOL
3.4 KiB
C++
// The following ifdef block is the standard way of creating macros which make exporting
|
|
// from a DLL simpler. All files within this DLL are compiled with the SHOTTRACKER_EXPORTS
|
|
// symbol defined on the command line. this symbol should not be defined on any project
|
|
// that uses this DLL. This way any other project whose source files include this file see
|
|
// SHOTTRACKER_API functions as being imported from a DLL, whereas this DLL sees symbols
|
|
// defined with this macro as being exported.
|
|
#ifndef ___SHOTTRACKER_H___
|
|
#define ___SHOTTRACKER_H___
|
|
|
|
#include "CCMath.h"
|
|
#include "CCMap.h"
|
|
|
|
//#define SHOTTRACKER_DLL_MODE
|
|
|
|
#ifdef SHOTTRACKER_DLL_MODE
|
|
#ifdef SHOTTRACKER_EXPORTS
|
|
#define SHOTTRACKER_API __declspec(dllexport)
|
|
#else
|
|
#define SHOTTRACKER_API __declspec(dllimport)
|
|
#endif
|
|
#else
|
|
#define SHOTTRACKER_API
|
|
#endif
|
|
|
|
|
|
#define MAX_DETECTED_SHOT 200
|
|
#define CURRENT_TAG_VERION 29
|
|
|
|
#define SMALL_RADIUS 0.20f
|
|
#define CMIN (SMALL_RADIUS + ((1.0f - SMALL_RADIUS) * 0.35f) )
|
|
#define CMAX (SMALL_RADIUS + ((1.0f - SMALL_RADIUS) * 0.65f) )
|
|
#define CODERADIUSCOEF (0.5f * (CMIN + CMAX))
|
|
|
|
/* Shot Code */
|
|
#define RAW_CODEBITNUM 4
|
|
#define ANCHOR_WSIZE (4)
|
|
#define ANCHOR_BSIZE (2)
|
|
#define ANCHOR_SIZE (ANCHOR_BSIZE * 2 + ANCHOR_WSIZE)
|
|
#define RAW_CODELENGHT (RAW_CODEBITNUM * 2 + (RAW_CODEBITNUM) + ANCHOR_SIZE)
|
|
#define RAW_CODESAMPLEL_Po2 (3)
|
|
#define RAW_CODESAMPLEL (RAW_CODELENGHT<<RAW_CODESAMPLEL_Po2)
|
|
#define RAW_WhiteLenght (ANCHOR_WSIZE<<RAW_CODESAMPLEL_Po2)
|
|
#define RAW_WhiteLenghtPlus (((ANCHOR_WSIZE)<<RAW_CODESAMPLEL_Po2) /*+ (1<<(RAW_CODESAMPLEL_Po2-1))*/)
|
|
|
|
typedef struct
|
|
{
|
|
Vector Coord;
|
|
Vector Coord2D;
|
|
float Radius;
|
|
Vector BigAxis;
|
|
Vector PerspectiveDir;
|
|
float Mu1,Mu2;
|
|
Vector VMu1,VMu2;
|
|
MATRIX Matrix;
|
|
MATRIX MatrixSmoothed;
|
|
Vector PerspectiveDirSmoothed;
|
|
float CODE[RAW_CODESAMPLEL];
|
|
u32 CodeNumber;
|
|
u32 TrackedTime;
|
|
u32 Validated;
|
|
|
|
float ContourError;
|
|
} GravC;
|
|
|
|
#define FAST_COS_DISCREET 1024
|
|
#define SmallRaidusFactor SMALL_RADIUS
|
|
|
|
class SHOTTRACKER_API SHOTS_CLASS
|
|
{
|
|
public :
|
|
SHOTS_CLASS();
|
|
|
|
public :
|
|
static float FASTCOS[FAST_COS_DISCREET+1];
|
|
static float FASTSIN[FAST_COS_DISCREET+1];
|
|
static u32 IsCosInit;
|
|
static void InitcosTable();
|
|
static u32 DrawShots;
|
|
static void Init();
|
|
static float FACTOR_ForceVDir;
|
|
|
|
public :
|
|
float SHOTS_FOCALE;
|
|
GravC DetectedGrav[MAX_DETECTED_SHOT];
|
|
GravC TrackedGrav[1<<RAW_CODEBITNUM];
|
|
u32 TrackedCodeHistory[1<<RAW_CODEBITNUM];
|
|
u32 TrackedCodeRequested[1<<((RAW_CODEBITNUM-5) + 1)];
|
|
u32 DetectedGravNum;
|
|
u32 TrackedGravNum;
|
|
s8 *MapCal;
|
|
u32 MapSize;
|
|
u32 THIS_IS_USED;
|
|
|
|
u32 GetCode(float *pCODE);
|
|
u32 GetCodeOrigin(float *pCode);
|
|
void Get3DCode(MAP8 *Map,MATRIX *M,float Radius,float *pCode);
|
|
|
|
void SHOT_DrawDebug(GravC *pShot,MAP *pSrc,u32 DrawCodeBMP , u32 DrawCodeTEXT , u32 Color);
|
|
/* SHOTDetect.cpp */
|
|
u32 SHOTS_DETECT(MAP *pSrc,/*OUT*/GravC *OutpL,u8 *pTempBuffer);
|
|
/* SHOTTrack.cpp */
|
|
u32 SHOTS_TRACK(MAP8 *pSrc,MAP8 *pSrcO2,MAP8 *pSrcO4,/*IN - OUT*/GravC *OutpL,MAP *pSrcR=0);
|
|
void SHOT_ComputeSmooth(GravC *OutpL);
|
|
u32 SHOT_ComputeMatrix(GravC *pShot,MAP8 *pSrc, u32 ComputeCode = 1);
|
|
|
|
void MainCall(MAP *pSrc);
|
|
};
|
|
|
|
/* MAIN CALL Example ---------------------------
|
|
float SHOTS_FOCALE = 1.7f;
|
|
SHOTS_CLASS *MS = 0;
|
|
|
|
void FindHotSpot(MAP *pSrc,float Focale)
|
|
{
|
|
if (!MS) return;
|
|
if (!MS->THIS_IS_USED)
|
|
{
|
|
if (MS->MapCal) free(MS->MapCal);
|
|
free(MS);
|
|
MS = NULL;
|
|
return;
|
|
}
|
|
MS->SHOTS_FOCALE = Focale;
|
|
MS->THIS_IS_USED--;
|
|
MS->MainCall(pSrc);
|
|
}
|
|
// ----------------------------------------------*/
|
|
|
|
#endif |