示例#1
0
fixed_t M_LengthVec2Fixed(const v2fixed_t *v)
{
	double fx = FIXED2DOUBLE(v->x);
	double fy = FIXED2DOUBLE(v->y);
	
	return DOUBLE2FIXED(sqrt(fx * fx + fy * fy));
}
示例#2
0
fixed_t M_LengthVec3Fixed(const v3fixed_t *v)
{
	double fx = FIXED2DOUBLE(v->x);
	double fy = FIXED2DOUBLE(v->y);
	double fz = FIXED2DOUBLE(v->z);
	
	return DOUBLE2FIXED(sqrt(fx * fx + fy * fy + fz * fz));
}
示例#3
0
//
// R_MapSlopedPlane
//
// Calculates the vectors a, b, & c, which are used to texture map a sloped
// plane.
//
// Based in part on R_MapSlope() and R_SlopeLights() from Eternity Engine,
// written by SoM/Quasar
//
void R_MapSlopedPlane(int y, int x1, int x2)
{
	int len = x2 - x1 + 1;
	if (len <= 0)
		return;

	// center of the view plane
	v3double_t s;
	s.x = x1 - centerx;
	s.y = y - centery + 1;
	s.z = FIXED2DOUBLE(FocalLengthX);

	ds_iu = M_DotProductVec3(&s, &a) * flatwidth;
	ds_iv = M_DotProductVec3(&s, &b) * flatheight;
	ds_id = M_DotProductVec3(&s, &c);
	
	ds_iustep = a.x * flatwidth;
	ds_ivstep = b.x * flatheight;
	ds_idstep = c.x;

	// From R_SlopeLights, Eternity Engine
	double map1, map2;
	map1 = 256.0 - (shade - plight * ds_id);
	if (len > 1)
	{
		double id = ds_id + ds_idstep * (x2 - x1);
		map2 = 256.0 - (shade - plight * id);
	}
	else
		map2 = map1;

	if (fixedlightlev)
		for (int i = 0; i < len; i++)
			slopelighting[i] = basecolormap + fixedlightlev;
	else if (fixedcolormap)
		for (int i = 0; i < len; i++)
			slopelighting[i] = fixedcolormap;
	else
	{
		fixed_t mapstart = FLOAT2FIXED((256.0 - map1) / 256.0 * NUMCOLORMAPS);
		fixed_t mapend = FLOAT2FIXED((256.0 - map2) / 256.0 * NUMCOLORMAPS);
		fixed_t map = mapstart;
		fixed_t step = 0;

		if (len > 1)
			step = (mapend - mapstart) / (len - 1);

		for (int i = 0; i < len; i++)
		{
			int index = (int)(map >> FRACBITS) + 1;
			index -= (foggy ? 0 : extralight << 2);
			
			if (index < 0)
				slopelighting[i] = basecolormap;
			else if (index >= NUMCOLORMAPS)
				slopelighting[i] = basecolormap + 256 * (NUMCOLORMAPS - 1);
			else
				slopelighting[i] = basecolormap + 256 * index;
			
			map += step;
		}
	}

   	ds_y = y;
	ds_x1 = x1;
	ds_x2 = x2;

	spanslopefunc();
}
示例#4
0
void M_SetVec3(v3double_t *dest, fixed_t x, fixed_t y, fixed_t z)
{
	dest->x = FIXED2DOUBLE(x);
	dest->y = FIXED2DOUBLE(y);	
	dest->z = FIXED2DOUBLE(z);
}
示例#5
0
void M_ActorMomentumToVec3(v3double_t *dest, const AActor *thing)
{
	dest->x = FIXED2DOUBLE(thing->momx);
	dest->y = FIXED2DOUBLE(thing->momy);
	dest->z = FIXED2DOUBLE(thing->momz);
}
示例#6
0
void M_ActorPositionToVec3(v3double_t *dest, const AActor *thing)
{
	dest->x = FIXED2DOUBLE(thing->x);
	dest->y = FIXED2DOUBLE(thing->y);
	dest->z = FIXED2DOUBLE(thing->z);
}
示例#7
0
文件: fixed.c 项目: xxzc/imgLabs
int main()
{
	fixed a1 = INT2FIXED(100),a2 = INT2FIXED(3);
	printf("%f",FIXED2DOUBLE(FDIV(a1,a2)));
}