RwRGBA amb, ambDN; void CustomCVBuildingDNEnvMapPipeline::SetupEnv(RxPS2AllPipeData *p2all, RwFrame *envframe, RwMatrix *envmat) { static RwMatrix lastmat; static void *lastobject; static RwFrame *lastfrm; static RwUInt16 lastrenderframe; RwMatrix inv; RpAtomic *atomic; RpClump *clump; RwFrame *frame; if(envframe == NULL) envframe = RwCameraGetFrame(ENGINE->camera); atomic = ps2all->sourceObject; clump = RpAtomicGetClump(atomic); if(lastobject != (clump ? clump : atomic) || lastfrm != envframe || lastrenderframe != ENGINE->renderFrame){ RwMatrixInvert(&inv, RwFrameGetLTM(envframe)); frame = clump ? RpClumpGetFrame(clump) : RpAtomicGetFrame(atomic); RwMatrixMultiply(&lastmat, RwFrameGetLTM(frame), &inv); if((RwMatrixGetFlags(&lastmat) & rwMATRIXTYPEMASK) != rwMATRIXTYPEORTHONORMAL) RwMatrixOrthoNormalize(&lastmat); lastobject = (clump ? clump : atomic); lastfrm = envframe; lastrenderframe = ENGINE->renderFrame; } *envmat = lastmat; } RwBool CCustomCVBuildingDNEnvMapPipeline::BridgeCB(RxPS2AllPipeData *p2all) { RpMaterial *mat; RwTexture *tex; RpAtomic *atomic; int materialFlags; bool noFx; bool hasEnv1, hasEnv2, hasSpec; float lightmult; float shininess; float specularity; CustomEnvMapPipeMaterialData *envData; CustomEnvMapPipeAtomicData *atmEnvData; RwMatrix envmat; float envXform[4]; RwMatrix specmat; RwV3d specdir; mat = p2all->mesh->material; atomic = ps2all->sourceObject; envData = *RWPLUGINOFFSET(CustomEnvMapPipeMaterialData*, mat, CCustomCVCarEnvMapPipeline__ms_envMapPluginOffset); /* --- ... */ // --- upload texture tex = CCustomCVCarEnvMapPipeline::GetFxEnvTexture(mat); // --- upload env texture RpMeshPS2AllSyncTextureUpload(p2all); /* --- */ lightmult = 1.0; shininess = envData->shininess/255.0; CustomCVBuildingDNEnvMapPipeline::SetupEnv(p2all, NULL, &envmat); envXform[0] = 0.0f; envXform[1] = 0.0f; envXform[2] = envData->scaleX/8.0f; envXform[3] = envData->scaleY/8.0f; /* * --- construct packet */ return TRUE; }