112 lines
2.9 KiB
C++
112 lines
2.9 KiB
C++
|
|
#include "TRACK.h"
|
|
#include "MEDIA.h"
|
|
#include "SCENE.h"
|
|
|
|
|
|
class DIFF_Grabber:public INPUT_IO
|
|
{
|
|
public:
|
|
u32 DIFFSource1;
|
|
u32 DIFFSource2;
|
|
u8 SignalAmplify[256];
|
|
WORLD *pScene;
|
|
int INIT (class WORLD*){return 0;};
|
|
int FRAME (void);
|
|
int END (void){return 0;};
|
|
IOTYPE GetType() {return IOtype_DIFF;};
|
|
|
|
};
|
|
|
|
int DIFF_Grabber::FRAME()
|
|
{
|
|
#ifndef SKIMMED_NET
|
|
OneBuf Output;
|
|
#endif
|
|
u32 OK_Continue;
|
|
u32 LastTileNumb;
|
|
u32 X,Y,*Ptr;
|
|
|
|
if (!pScene->ID_MEDIA[DIFFSource1]) return 0;
|
|
START_RASTER(Diff);
|
|
if (Image.SetSize( pScene->ID_MEDIA[DIFFSource1]->Image.SX,
|
|
pScene->ID_MEDIA[DIFFSource1]->Image.SY))
|
|
{
|
|
if (ulAssociatedTextureIndex != -1)
|
|
pScene->DI->DestroyTexture(ulAssociatedTextureIndex);
|
|
ulAssociatedTextureIndex = pScene->DI->CreateTexture(&Image,ulColorMode);
|
|
}
|
|
|
|
/* DIFF */
|
|
|
|
pScene->DI->BeginTextureTarget(ulAssociatedTextureIndex);
|
|
|
|
RS DefaultRS;
|
|
GLOB_SetDefaultRS(&DefaultRS);
|
|
DefaultRS.BACKFACE = 0;
|
|
DefaultRS.NOZTEST = 1;
|
|
DefaultRS.NOZWRITE = 1;
|
|
|
|
pScene->DI->Matrix(NULL);
|
|
pScene->DI->Ortho();
|
|
pScene->DI->SetRS(&DefaultRS,-1/*pScene->ID_MEDIA[DIFFSource1]->ulAssociatedTextureIndex*/);
|
|
float Coef = (float)Image.SY/(float)Image.SX;
|
|
pScene->DI->DrawQuad(0x80808080,-1.0f, 1.0f*Coef ,2.0f, -2.0f*Coef ,0.0f,0.0f,1.0f,1.0f);
|
|
DefaultRS.BlendingMode = 6;
|
|
pScene->DI->SetRS(&DefaultRS,pScene->ID_MEDIA[DIFFSource1]->ulAssociatedTextureIndex);
|
|
pScene->DI->DrawQuad(0xffffffff,-1.0f, 1.0f*Coef ,2.0f, -2.0f*Coef ,0.0f,0.0f,1.0f,1.0f);
|
|
DefaultRS.BlendingMode = 2;
|
|
pScene->DI->SetRS(&DefaultRS,pScene->ID_MEDIA[DIFFSource2]->ulAssociatedTextureIndex);
|
|
pScene->DI->DrawQuad(0x80808080,-1.0f, 1.0f*Coef ,2.0f, -2.0f*Coef ,0.0f,0.0f,1.0f,1.0f);
|
|
/* Amplify */
|
|
pScene->DI->EndTextureTarget(ulAssociatedTextureIndex,1);
|
|
/*
|
|
extern void RETINEX(MAP *CurrentMap);
|
|
RETINEX(&Image);//*/
|
|
u8 *pImage,*pImageE;
|
|
pImage = (u8*)Image.GetBase();
|
|
pImageE = pImage + Image.SX * Image.SY * 4;
|
|
while (pImage < pImageE)
|
|
{
|
|
*pImage = SignalAmplify[*pImage];
|
|
pImage++;
|
|
}//*/
|
|
pScene->DI->UpdateTexture_BM_2_HW(ulAssociatedTextureIndex);
|
|
|
|
STOP_RASTER(Diff);
|
|
return 1;
|
|
}
|
|
|
|
void DIFF_SETPARAMS(INPUT_IO *pDIFF,u32 DIFFSource1,u32 DIFFSource2)
|
|
{
|
|
((DIFF_Grabber *)pDIFF)->DIFFSource1 = DIFFSource1;
|
|
((DIFF_Grabber *)pDIFF)->DIFFSource2 = DIFFSource2;
|
|
}
|
|
|
|
|
|
INPUT_IO *DIFF_CREATE(class WORLD*pScene,char *Filename)
|
|
{
|
|
u32 SX,SY,Col;
|
|
INPUT_IO *Ret;
|
|
Ret = (INPUT_IO *)new(DIFF_Grabber);
|
|
SX = SY = 256;
|
|
((DIFF_Grabber*)Ret)->DIFFSource1 = 0;
|
|
((DIFF_Grabber*)Ret)->DIFFSource2 = 0;
|
|
((DIFF_Grabber*)Ret)->pScene = pScene;
|
|
strcpy((char*)Ret->MediaName,Filename);
|
|
Ret->Image.SetSize(SX, SY);
|
|
Ret->dTotalTime = 0;
|
|
Ret->dAvgFramePerSecond = 30.0;
|
|
for (u32 Counter = 0; Counter < 256 ; Counter++)
|
|
{
|
|
s32 Value;
|
|
Value = (128 - (s32)Counter)<<2;
|
|
Value += 128;
|
|
if (Value < 0) Value = 0;
|
|
if (Value > 255) Value = 255;
|
|
((DIFF_Grabber*)Ret)->SignalAmplify[Counter] = (u8)Value;
|
|
}
|
|
return (INPUT_IO *)Ret;
|
|
};
|
|
|
|
|