Beispiel #1
0
bool ETHRenderEntity::DrawHalo(const float maxHeight, const float minHeight, const bool rotateHalo, const Vector2 &zAxisDirection)
{
	GS2D_UNUSED_ARGUMENT(minHeight);
	GS2D_UNUSED_ARGUMENT(maxHeight);

	if (!GetHalo() || !HasLightSource() || IsHidden())
		return false;

	m_pHalo->SetOrigin(Sprite::EO_CENTER);
	const ETHLight* light = m_properties.light.get();

	const Vector3 v3EntityPos = GetPosition();

	// will remain as 1.0 for a while
	m_provider->GetVideo()->SetSpriteDepth(1.0f/*ETHGlobal::ComputeDepth(m_data.entity.light.pos.z+v3EntityPos.z+ETH_HALO_DEPTH_SHIFT, maxHeight, minHeight)*/);

	// if it has a particle system in the first slot, adjust the light
	// brightness according to the number of active particles
	float brightness = 1.0f;
	const ETHParticleManagerPtr paticleManager = GetParticleManager(0);
	if (paticleManager)
	{
		brightness = static_cast<float>(paticleManager->GetNumActiveParticles())/static_cast<float>(paticleManager->GetNumParticles());
	}

	Vector3 v3HaloPos = light->pos + v3EntityPos;

	Color dwColor = ConvertToDW(light->color * light->haloBrightness * brightness);
	Vector2 v2Size(light->haloSize, light->haloSize);

	m_pHalo->DrawShaped(
		ETHGlobal::ToScreenPos(v3HaloPos, zAxisDirection) + ComputeParallaxOffset(),
		v2Size * m_properties.scale,
		dwColor, dwColor, dwColor, dwColor,
		(rotateHalo) ? ComputeHaloAngle() : 0.0f);
	return true;
}
Beispiel #2
0
int EchScatRead (Hdr *phdr, double xsize, double ysize,
                 ScatterFunctions *scf, int verbose) {

/* arguments
Hdr *phdr               i: primary header
double xsize, ysize;    i: aperture size in arcsec
ScatterFunctions *scf;  o: data structure with scattering functions
int verbose;            i: verbosity flag
*/
        char fname[STIS_LINE];          /* file names */
        Image halo1;                    /* halo images */
        Image halo2;
        Image halo3;
        Image psf1;                     /* psf images */
        Image psf2;
        Image psf3;

        int no_default = 0;             /* missing keyword is fatal error */
        int status;

        void InitImage (Image *);
        void FreeImage (Image *);

        InitImage (&halo1);
        InitImage (&halo2);
        InitImage (&halo3);
        InitImage (&psf1);
        InitImage (&psf2);
        InitImage (&psf3);

        /* Get scattering functions. */

        if ((status = Get_KeyS (phdr, "ECHSCTAB", no_default, "",
                                fname, STIS_LINE))) {
            printf (
"WARNING  The input file *might* not have the required keywords\n");
            printf (
"         to run the scattered light correction algorithm.\n");
            fflush (stdout);
            return (status);
        }
        if (verbose) {
            printf ("Reading ECHSCTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetScatter (fname, scf)))
            return (status);

        /* Get echelle x-disp spread function. */

        if ((status = Get_KeyS (phdr, "EXSTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading EXSTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetEchelleScatter (fname, scf)))
            return (status);

        /* Get x-disp function. */

        if ((status = Get_KeyS (phdr, "CDSTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading CDSTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetXDisp (fname, scf)))
            return (status);

        /* Get echelle ripple functions. */

        if ((status = Get_KeyS (phdr, "RIPTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading RIPTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetRipple (phdr, fname, scf)))
            return (status);

        /* Get wavelengths of halo and telescope PSF images. */

        if ((status = Get_KeyS (phdr, "SRWTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading SRWTAB: %s\n", fname);
            fflush (stdout);
        }

        if ((status = GetRefWave (phdr, fname, scf)))
            return (status);

        /* Get halo and telescope psf images, and build FTs */

        if ((status = Get_KeyS (phdr, "HALOTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading HALOTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetHalo (fname, scf, &halo1, &halo2, &halo3)))
            return (status);

        if ((status = Get_KeyS (phdr, "TELTAB", no_default, "",
                                fname, STIS_LINE)))
            return (status);
        if (verbose) {
            printf ("Reading TELTAB: %s\n", fname);
            fflush (stdout);
        }
        if ((status = GetPSF (fname, phdr, xsize, ysize, scf,
                              &psf1, &psf2, &psf3)))
            return (status);

        InitCmplxArray (&(scf->ft1));
        InitCmplxArray (&(scf->ft2));
        InitCmplxArray (&(scf->ft3));
        InitCmplxArray (&(scf->fto1));
        InitCmplxArray (&(scf->fto2));
        InitCmplxArray (&(scf->fto3));

        if (verbose) {
            printf (
            "Computing Fourier Transforms of kernel at wavelength  %g\n",
                     scf->kernw[0]);
            fflush (stdout);
        }
        if ((status = MakeFT (&halo1, &psf1, scf, &(scf->ft1), &(scf->fto1))))
            return (status);

        if (scf->nwave > 1) {
            if (verbose) {
                printf (
                "Computing Fourier Transforms of kernel at wavelength  %g\n",
                         scf->kernw[1]);
                fflush (stdout);
            }
            if ((status = MakeFT (&halo2, &psf2, scf, &(scf->ft2), &(scf->fto2))))
                return (status);
        }

        if (scf->nwave > 2) {
            if (verbose) {
                printf (
                "Computing Fourier Transforms of kernel at wavelength  %g\n",
                         scf->kernw[2]);
                fflush (stdout);
            }
            if ((status = MakeFT (&halo3, &psf3, scf, &(scf->ft3), &(scf->fto3))))
                return (status);
        }

        FreeImage (&halo1);
        FreeImage (&halo2);
        FreeImage (&halo3);
        FreeImage (&psf1);
        FreeImage (&psf2);
        FreeImage (&psf3);

        return (STIS_OK);
}