#include "SCENE.h" #include "MEDIA.h" #include "CODEC.h" class ReverseRender:public INPUT_IO { public: u32 SX,SY; WORLD *pScene; u32 SourceIndex; u32 MaskmediaIndex; //ImageFinder imgFinder; int INIT (class WORLD*pscn); int FRAME (); int END (void); IOTYPE GetType() {return IOtype_REVR;}; }; int ReverseRender::END() { Image.Delete(); return 0; } int ReverseRender::INIT(class WORLD*pscn) { pScene = pscn; MaskmediaIndex = -1; return 0; }; int ReverseRender::FRAME() { START_RASTER(Revr); if ((pScene->ID_TABLE[SourceIndex]) && (!pScene->ID_TABLE[SourceIndex]->SF_U.FromScratch) && pScene->MediaToTrack != -1 && pScene->ID_MEDIA[pScene->MediaToTrack] && pScene->TrackRes) { if (Image.SetSize(SX, SY, 1)) { if (ulAssociatedTextureIndex != -1) pScene->DI->DestroyTexture(ulAssociatedTextureIndex); ulAssociatedTextureIndex = pScene->DI->CreateTexture(&Image,ulColorMode); } IsValidForMosaique = 1; RS Nullmlml; GLOB_SetDefaultRS(&Nullmlml); Nullmlml.BACKFACE = 0; Nullmlml.BACKFACE_INVERT = 0; Nullmlml.WIRED = 0; Nullmlml.NOZWRITE = 1; Nullmlml.NOZTEST = 1; Nullmlml.TEXTURED = 1; Nullmlml.HIDEALPHA = 0; Nullmlml.SECONDPASS = 0; pScene->ID_TABLE[SourceIndex]->p_UsedMesh->Optimize(); /* Set the correct focale */ if (pScene->ID_TABLE[SourceIndex]->SF_U.IsAnimatedTrack && (pScene->ID_TABLE[SourceIndex]->AnimatedMedia != -1)) pScene->SetCurrentFocale(pScene->ID_MEDIA[pScene->ID_TABLE[SourceIndex]->AnimatedMedia]->MediaFocale); else pScene->SetCurrentFocale(pScene->ID_MEDIA[pScene->MediaToTrack]->MediaFocale);//*/ pScene->DI->BeginTextureTarget(ulAssociatedTextureIndex); pScene->DI->Perspective(pScene->GetCurrentFocale()); pScene->DI->Matrix(&pScene->ID_TABLE[SourceIndex]->CurrentMatrix_U); pScene->DI->SetRS(&Nullmlml,ulAssociatedTextureIndex); if ((MaskmediaIndex != -1) && pScene->ID_MEDIA[MaskmediaIndex]) { /* Draw the mask */ Nullmlml.MappingMode = 1; Nullmlml.HIDECOLOR = 1; pScene->DI->SetRS(&Nullmlml,pScene->ID_MEDIA[MaskmediaIndex]->ulAssociatedTextureIndex); pScene->DI->ReverseRenderMesh(pScene->ID_TABLE[SourceIndex]->p_UsedMesh,pScene->ID_MEDIA[MaskmediaIndex]->ulAssociatedTextureIndex); Nullmlml.MappingMode = 0; Nullmlml.HIDECOLOR = 0; Nullmlml.HIDEALPHA = 1; Nullmlml.BlendingMode = 4; //<- previous alpha pScene->DI->SetRS(&Nullmlml,ulAssociatedTextureIndex); if (pScene->ID_TABLE[SourceIndex]->SF_U.IsAnimatedTrack && (pScene->ID_TABLE[SourceIndex]->AnimatedMedia != -1)) pScene->DI->ReverseRenderMesh(pScene->ID_TABLE[SourceIndex]->p_UsedMesh,pScene->ID_MEDIA[pScene->ID_TABLE[SourceIndex]->AnimatedMedia]->ulAssociatedTextureIndex); else pScene->DI->ReverseRenderMesh(pScene->ID_TABLE[SourceIndex]->p_UsedMesh,pScene->ID_MEDIA[pScene->MediaToTrack]->ulAssociatedTextureIndex);//*/ } else { if (pScene->ID_TABLE[SourceIndex]->SF_U.IsAnimatedTrack && (pScene->ID_TABLE[SourceIndex]->AnimatedMedia != -1)) pScene->DI->ReverseRenderMesh(pScene->ID_TABLE[SourceIndex]->p_UsedMesh,pScene->ID_MEDIA[pScene->ID_TABLE[SourceIndex]->AnimatedMedia]->ulAssociatedTextureIndex); else pScene->DI->ReverseRenderMesh(pScene->ID_TABLE[SourceIndex]->p_UsedMesh,pScene->ID_MEDIA[pScene->MediaToTrack]->ulAssociatedTextureIndex); } pScene->DI->EndTextureTarget(ulAssociatedTextureIndex,pScene->ID_TABLE[SourceIndex]->SF_U.FlyStart ? 0 : 0);//*/ } else { //pScene->ID_MEDIA[pScene->MediaToTrack]->IsValidForMosaique = 1; //pScene->DI->UpdateTexture_BM_2_HW(ulAssociatedTextureIndex); IsValidForMosaique = 1; } STOP_RASTER(Revr); return 0; } void ReverseRender_SETPARAMS(INPUT_IO *pREVR, u32 sizeX, u32 sizeY) { ((ReverseRender *)pREVR)->SX = sizeX; ((ReverseRender *)pREVR)->SY = sizeY; } void ReverseRender_SETMASK(INPUT_IO *pREVR, u32 MaskmediaIndex) { ((ReverseRender *)pREVR)->MaskmediaIndex = MaskmediaIndex; } INPUT_IO *ReverseRender_CREATE(WORLD *pScene,char *Name) { ReverseRender *Ret; Ret = new(ReverseRender); Ret->INIT(pScene); //Ret->SX = 128; //Ret->SY = 128; Ret->SX = 256; Ret->SY = 256; strcpy((char*)Ret->MediaName,Name); Ret->SourceIndex = 0; while (*Name && (!IsDeci(*Name))) Name++; while (*Name && (IsDeci(*Name))) {Ret->SourceIndex *= 10; Ret->SourceIndex += IsDeci(*Name++) - 1;}; if (Ret->SourceIndex >= MAX_INPMED) Ret->SourceIndex = 0; Ret->Image.SetSize(Ret->SX, Ret->SY, 1); Ret->dTotalTime = 0; Ret->dAvgFramePerSecond = 30.0; //Ret->imgFinder.Init(/*true*/false); return (INPUT_IO *)Ret; };