Пример #1
0
/*
 * ============= Draw_FindPic =============
 */
image_t        *
Draw_FindPic(char *name)
{
	image_t        *gl;
	char		fullname[MAX_QPATH];

	if (name[0] != '/' && name[0] != '\\') {
		Com_sprintf(fullname, sizeof(fullname), "pics/%s.pcx", name);
		gl = GL_FindImage(fullname, it_pic);
	} else
		gl = GL_FindImage(name + 1, it_pic);

	return gl;
}
Пример #2
0
void
RefreshFont(void)
{
	font_color->modified = false;

	draw_chars = GL_FindImage(va("fonts/%s.pcx", font_color->string), it_pic);
	if (!draw_chars)	/* fall back on default font */
		draw_chars = GL_FindImage("fonts/default.pcx", it_pic);
	if (!draw_chars)	/* fall back on old Q2 conchars */
		draw_chars = GL_FindImage("pics/conchars.pcx", it_pic);
	if (!draw_chars)	/* Knightmare- prevent crash caused by missing font */
		ri.Sys_Error(ERR_FATAL, "RefreshFont: couldn't load pics/conchars");

	GL_Bind(draw_chars->texnum);
}
Пример #3
0
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel (model_t *mod, FILE *file, long base)
{
	dsprite_t	*sprout;
	int			i;

	Prof_Begin(__FUNCTION__);

	sprout = Hunk_Alloc (&hunk_ref, modfilelen);
	ri.FS_Read(sprout, modfilelen, file);

	mod->sprite = sprout;

	if (sprout->version != SPRITE_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, sprout->version, SPRITE_VERSION);

	if (sprout->numframes > MAX_MD2SKINS)
		ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
				 mod->name, sprout->numframes, MAX_MD2SKINS);

	// load the images.
	for (i=0 ; i<sprout->numframes ; i++)
	{
		mod->skins[i] = GL_FindImage (sprout->frames[i].name,
			it_sprite);
	}

	mod->type = mod_sprite;

	Prof_End();
}
Пример #4
0
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel (model_t *mod, void *buffer)
{
	dsprite_t	*sprin, *sprout;
	int			i;

	sprin = (dsprite_t *)buffer;
	sprout = Hunk_Alloc (modfilelen);

	sprout->ident = LittleLong (sprin->ident);
	sprout->version = LittleLong (sprin->version);
	sprout->numframes = LittleLong (sprin->numframes);

	if (sprout->version != SPRITE_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, sprout->version, SPRITE_VERSION);

	if (sprout->numframes > MAX_MD2SKINS)
		ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
				 mod->name, sprout->numframes, MAX_MD2SKINS);

	// byte swap everything
	for (i=0 ; i<sprout->numframes ; i++)
	{
		sprout->frames[i].width = LittleLong (sprin->frames[i].width);
		sprout->frames[i].height = LittleLong (sprin->frames[i].height);
		sprout->frames[i].origin_x = LittleLong (sprin->frames[i].origin_x);
		sprout->frames[i].origin_y = LittleLong (sprin->frames[i].origin_y);
		memcpy (sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
		mod->skins[i] = GL_FindImage (sprout->frames[i].name,
			it_sprite);
	}

	mod->type = mod_sprite;
}
Пример #5
0
void R_SetSky (const char *name, float rotate, vec3_t axis)
{
	int		i;
	char	pathname[MAX_QPATH];

	Q_strncpyz (skyname, name, sizeof(skyname));
	skyrotate = rotate;
	VectorCopy (axis, skyaxis);

	// chop down rotating skies for less memory
	if (gl_skymip->integer || skyrotate)
		gl_picmip->integer++;

	for (i=0 ; i<6 ; i++)
	{
		Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);

		sky_images[i] = GL_FindImage (pathname, it_sky);
		if (!sky_images[i])
			sky_images[i] = r_notexture;
	}
	if (gl_skymip->integer || skyrotate)
	{	// take less memory
		gl_picmip->integer--;
		sky_min = 0.00390625f;
		sky_max = 0.99609375f;
	}
	else	
	{
		sky_min = 0.001953125f;
		sky_max = 0.998046875f;
	}
}
Пример #6
0
/*
===============
Draw_InitLocal
===============
*/
void Draw_InitLocal (void)
{
	// load console characters (don't bilerp characters)
	draw_chars = GL_FindImage ("pics/conchars.pcx", it_pic);
	GL_Bind( draw_chars->texnum );
	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
Пример #7
0
/*
=================
Mod_LoadTexinfo
=================
*/
void Mod_LoadTexinfo (lump_t *l, FILE *file, long base)
{
	texinfo_t in[MAX_MAP_TEXINFO];
	mtexinfo_t *out, *step;
	int 	i, j, count;
	char	name[MAX_QPATH];
	int		next;
	
	Com_DPrintf("%s\n", __FUNCTION__);

	fseek(file, base + l->fileofs, SEEK_SET);

	if (l->filelen % sizeof(texinfo_t))
		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
	count = l->filelen / sizeof(texinfo_t);
	if (count > MAX_MAP_TEXINFO)
		ri.Sys_Error(ERR_DROP, "%s: Too many (%d) in %s", __FUNCTION__, count, loadmodel->name);
	out = Hunk_Alloc (&hunk_ref, count*sizeof(*out));	

	loadmodel->texinfo = out;
	loadmodel->numtexinfo = count;

	ri.FS_Read(in, l->filelen, file);

	for ( i=0 ; i<count ; i++, out++)
	{
		for (j=0 ; j<8 ; j++)
			out->vecs[0][j] = LittleFloat (in[i].vecs[0][j]);

		out->flags = LittleLong (in[i].flags);
		next = LittleLong (in[i].nexttexinfo);
		if (next > 0)
			out->next = loadmodel->texinfo + next;
		else
			out->next = NULL;
		Com_sprintf (name, sizeof(name), "textures/%s.wal", in[i].texture);

		out->image = GL_FindImage (name, it_wall);
		if (!out->image)
		{
			ri.Con_Printf (PRINT_ALL, "Couldn't load %s\n", name);
		}
	}

	// count animation frames
	for (i=0 ; i<count ; i++)
	{
		out = &loadmodel->texinfo[i];
		out->numframes = 1;
		for (step = out->next ; step && step != out ; step=step->next)
			out->numframes++;
	}
	
	Com_DPrintf("%s OK\n", __FUNCTION__);
}
Пример #8
0
void R_InitParticleTexture (void)
{
	int		x,y;
	byte	data[8][8][4];

	//
	// particle texture
	//
	for (x=0 ; x<8 ; x++)
	{
		for (y=0 ; y<8 ; y++)
		{
			data[y][x][0] = 255;
			data[y][x][1] = 255;
			data[y][x][2] = 255;
			data[y][x][3] = dottexture[x][y]*255;
		}
	}

	r_particletexture = GL_FindImage ("particle.png", "particle", it_sprite);
	
	if (!r_particletexture)
		r_particletexture = GL_FindImage ("particle.tga", "particle", it_sprite);

	if (!r_particletexture)
		r_particletexture = GL_LoadPic ("***particle***", (byte *)data, 8, 8, it_sprite, 32);

	//
	// also use this for bad textures, but without alpha
	//
	for (x=0 ; x<8 ; x++)
	{
		for (y=0 ; y<8 ; y++)
		{
			data[y][x][0] = dottexture[x&3][y&3]*255;
			data[y][x][1] = 0; // dottexture[x&3][y&3]*255;
			data[y][x][2] = 0; //dottexture[x&3][y&3]*255;
			data[y][x][3] = 255;
		}
	}
	r_notexture = GL_LoadPic ("***r_notexture***", (byte *)data, 8, 8, it_wall, 32);
}
Пример #9
0
/*
@@@@@@@@@@@@@@@@@@@@@
R_RegisterModel

@@@@@@@@@@@@@@@@@@@@@
*/
struct model_s *R_RegisterModel (char *name)
{
	model_t	*mod;
	int		i;
	dsprite_t	*sprout;
	dmdl_t		*pheader;

	mod = Mod_ForName (name, false);
	if (mod)
	{
		mod->registration_sequence = registration_sequence;

		// register any images used by the models
		if (mod->type == mod_sprite)
		{
			sprout = (dsprite_t *)mod->extradata;
			for (i=0 ; i<sprout->numframes ; i++)
				mod->skins[i] = GL_FindImage (sprout->frames[i].name, it_sprite);
		}
		else if (mod->type == mod_alias)
		{
			pheader = (dmdl_t *)mod->extradata;
			for (i=0 ; i<pheader->num_skins ; i++)
				mod->skins[i] = GL_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
//PGM
			mod->numframes = pheader->num_frames;
//PGM
		}
		else if (mod->type == mod_brush)
		{
			for (i=0 ; i<mod->numtexinfo ; i++)
				mod->texinfo[i].image->registration_sequence = registration_sequence;
		}
	}
	return mod;
}
Пример #10
0
/*
=================
Mod_LoadTexinfo
=================
*/
void Mod_LoadTexinfo (lump_t *l)
{
	texinfo_t *in;
	mtexinfo_t *out, *step;
	int 	i, j, count;
	char	name[MAX_QPATH];
	int		next;

	in = (void *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
	count = l->filelen / sizeof(*in);
	out = Hunk_Alloc ( count*sizeof(*out));	

	loadmodel->texinfo = out;
	loadmodel->numtexinfo = count;

	for ( i=0 ; i<count ; i++, in++, out++)
	{
		for (j=0 ; j<8 ; j++)
			out->vecs[0][j] = LittleFloat (in->vecs[0][j]);

		out->flags = LittleLong (in->flags);
		next = LittleLong (in->nexttexinfo);
		if (next > 0)
			out->next = loadmodel->texinfo + next;
		else
		    out->next = NULL;
		Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);

		out->image = GL_FindImage (name, it_wall);
		if (!out->image)
		{
			ri.Con_Printf (PRINT_ALL, "Couldn't load %s\n", name);
			out->image = r_notexture;
		}
	}

	// count animation frames
	for (i=0 ; i<count ; i++)
	{
		out = &loadmodel->texinfo[i];
		out->numframes = 1;
		for (step = out->next ; step && step != out ; step=step->next)
			out->numframes++;
	}
}
Пример #11
0
void R_SetSky (char *name, float rotate, vec3_t axis)
{
	int		i;
	char	pathname[MAX_QPATH];

	Prof_Begin(__FUNCTION__);

	strncpy (skyname, name, sizeof(skyname)-1);
	skyrotate = rotate;
	VectorCopy (axis, skyaxis);

	for (i=0 ; i<6 ; i++)
	{
		// chop down rotating skies for less memory
		if (gl_skymip->value || skyrotate)
			gl_picmip->value++;

#ifndef PSP
		if ( qglColorTableEXT && gl_ext_palettedtexture->value )
#endif
		{
			Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]);
		}
#ifndef PSP
		else
		{
			Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
		}
#endif

		sky_images[i] = GL_FindImage (pathname, it_sky);

		if (gl_skymip->value || skyrotate)
		{	// take less memory
			gl_picmip->value--;
			sky_min = 1.0/256;
			sky_max = 255.0/256;
		}
		else	
		{
			sky_min = 1.0/512;
			sky_max = 511.0/512;
		}
	}

	Prof_End();
}
Пример #12
0
void R_SetSky (char *name, float rotate, vec3_t axis)
{
	int		i;
	char	pathname[MAX_QPATH];

	strncpy (skyname, name, sizeof(skyname)-1);
	skyrotate = rotate;
	VectorCopy (axis, skyaxis);

	for (i=0 ; i<6 ; i++)
	{
		// jkrige - texture quality
		// chop down rotating skies for less memory
		//if (gl_skymip->value || skyrotate)
		//	gl_picmip->value++;
		// jkrige - texture quality

		// jkrige - palette removal
		//if ( qglColorTableEXT && gl_ext_palettedtexture->value )
		//	Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]);
		//else
			Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
		// jkrige - palette removal

		sky_images[i] = GL_FindImage (pathname, it_sky);
		if (!sky_images[i])
			sky_images[i] = r_notexture;

		// jkrige - texture quality
		/*if (gl_skymip->value || skyrotate)
		{	// take less memory
			gl_picmip->value--;
			sky_min = 1.0/256;
			sky_max = 255.0/256;
		}
		else	
		{
			sky_min = 1.0/512;
			sky_max = 511.0/512;
		}*/
		// jkrige - texture quality
	}
}
Пример #13
0
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel (model_t *mod, void *buffer)
{
	dsprite_t	*sprin, *sprout;
	int			i;

	sprin = (dsprite_t *)buffer;
	sprout = (dsprite_t *) Hunk_Alloc (modfilelen);

	sprout->ident = LittleLong(sprin->ident);
	sprout->version = LittleLong(sprin->version);
	sprout->numframes = LittleLong(sprin->numframes);

	if (sprout->version != SPRITE_VERSION)
		VID_Error (ERR_DROP, "sprite %s has wrong version number (%i should be %i)",
				 mod->name, sprout->version, SPRITE_VERSION);

	if (sprout->numframes > MAX_MD2SKINS)
		VID_Error (ERR_DROP, "sprite %s has too many frames (%i > %i)",
				 mod->name, sprout->numframes, MAX_MD2SKINS);

	if (sprout->numframes <= 0)
		VID_Error (ERR_DROP, "sprite %s has no frames", mod->name);

	// byte swap everything
	for (i=0 ; i<sprout->numframes ; i++)
	{
		sprout->frames[i].width = LittleLong(sprin->frames[i].width);
		sprout->frames[i].height = LittleLong(sprin->frames[i].height);
		sprout->frames[i].origin_x = LittleLong(sprin->frames[i].origin_x);
		sprout->frames[i].origin_y = LittleLong(sprin->frames[i].origin_y);
		memcpy (sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
		fast_strlwr (sprout->frames[i].name);
		mod->skins[i] = GL_FindImage (sprout->frames[i].name, sprout->frames[i].name, it_sprite);

		//r1: sprites crash if they don't have valid skins for framenum so be noisy
		if (!mod->skins[i])
			VID_Printf (PRINT_ALL, "GL_FindImage: Couldn't find skin '%s' for sprite '%s'\n", sprout->frames[i].name, mod->name);
	}

	mod->type = mod_sprite;
}
Пример #14
0
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel (model_t *mod, FILE *file, long base)
{
	dsprite_t	*sprout;
	int			i;

	sprout = Hunk_Alloc (&hunk_ref, modfilelen);
	ri.FS_Read(sprout, modfilelen, file);

	mod->sprite = sprout;

	sprout->ident = LittleLong (sprout->ident);
	sprout->version = LittleLong (sprout->version);
	sprout->numframes = LittleLong (sprout->numframes);

	if (sprout->version != SPRITE_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, sprout->version, SPRITE_VERSION);

	if (sprout->numframes > MAX_MD2SKINS)
		ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
				 mod->name, sprout->numframes, MAX_MD2SKINS);

	// byte swap everything and load the images.
	for (i=0 ; i<sprout->numframes ; i++)
	{
		sprout->frames[i].width = LittleLong (sprout->frames[i].width);
		sprout->frames[i].height = LittleLong (sprout->frames[i].height);
		sprout->frames[i].origin_x = LittleLong (sprout->frames[i].origin_x);
		sprout->frames[i].origin_y = LittleLong (sprout->frames[i].origin_y);

		mod->skins[i] = GL_FindImage (sprout->frames[i].name,
			it_sprite);
	}

	mod->type = mod_sprite;
}
Пример #15
0
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, FILE *file, long base)
{
	int				i, j;
	dmdl_t			inmodel;
	mmdl_t			*pheader;
	daliasframe_t	*poutframe;
	int				*poutcmd;
	int				version;

	ri.FS_Read(&inmodel, sizeof(inmodel), file);

	version = LittleLong (inmodel.version);
	if (version != ALIAS_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, version, ALIAS_VERSION);

	pheader = &mod->alias;

	// byte swap the header fields and sanity check
	for (i=0 ; i<sizeof(inmodel)/4 ; i++)
		((int *)&inmodel)[i] = LittleLong (((int *)&inmodel)[i]);

	pheader->framesize = inmodel.framesize;
	pheader->num_xyz = inmodel.num_xyz;
	pheader->num_tris = inmodel.num_tris;
	pheader->num_glcmds = inmodel.num_glcmds;
	pheader->num_frames = inmodel.num_frames;

	if (pheader->num_xyz <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);

	if (pheader->num_xyz > MAX_VERTS)
		ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);

	if (pheader->num_tris <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);

	if (pheader->num_frames <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);

//
// load the frames
//
	pheader->frames = Hunk_Alloc(&hunk_ref, pheader->num_frames * pheader->framesize);

	fseek(file, base + inmodel.ofs_frames, SEEK_SET);
	ri.FS_Read(pheader->frames, pheader->num_frames * pheader->framesize, file);

	for (i=0 ; i<pheader->num_frames ; i++)
	{

		poutframe = (daliasframe_t *) (pheader->frames + i * pheader->framesize);

		for (j=0 ; j<3 ; j++)
		{
			poutframe->scale[j] = LittleFloat (poutframe->scale[j]);
			poutframe->translate[j] = LittleFloat (poutframe->translate[j]);
		}
	}

	mod->type = mod_alias;

	//
	// load the glcmds
	//

	pheader->glcmds = Hunk_Alloc(&hunk_ref, pheader->num_glcmds * sizeof(int));

	fseek(file, base + inmodel.ofs_glcmds, SEEK_SET);
	ri.FS_Read(pheader->glcmds, pheader->num_glcmds * sizeof(int), file);

	poutcmd = pheader->glcmds;
	for (i=0 ; i<pheader->num_glcmds ; i++)
	{
		poutcmd[i] = LittleLong (poutcmd[i]);
	}

	// register all skins
	fseek(file, base + inmodel.ofs_skins, SEEK_SET);
	for (i=0 ; i<inmodel.num_skins ; i++)
	{
		char name[MAX_SKINNAME];

		ri.FS_Read(name, MAX_SKINNAME, file);

		assert(mod->skins[i] == NULL);
		mod->skins[i] = GL_FindImage (name, it_skin);
	}

	// TODO PeterM Is this used anywhere?
	mod->numframes = pheader->num_frames;

	mod->mins[0] = -32;
	mod->mins[1] = -32;
	mod->mins[2] = -32;
	mod->maxs[0] = 32;
	mod->maxs[1] = 32;
	mod->maxs[2] = 32;
}
Пример #16
0
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, void *buffer)
{
	unsigned int		i;
	dmdl_t				header;
	dmdl_t				*pinmodel, *pheader;
	dstvert_t			*pinst, *poutst;
	dtriangle_t			*pintri, *pouttri;
	daliasframe_t		*pinframe, *poutframe;
	int					*pincmd, *poutcmd;
	int					version;
	unsigned int		required;
	char				*skin_name;

	pinmodel = (dmdl_t *)buffer;

	version = LittleLong(pinmodel->version);
	if (version != ALIAS_VERSION)
		VID_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, version, ALIAS_VERSION);

	//pheader = Hunk_Alloc (size);
	pheader = &header;
	
	// byte swap the header fields and sanity check
	memcpy (pheader, buffer, sizeof(dmdl_t));

	if (pheader->skinheight > MAX_LBM_HEIGHT)
		Com_DPrintf("model %s has a skin taller than traditional maximum of %d", mod->name,
				   MAX_LBM_HEIGHT);

	if (pheader->num_xyz <= 0)
		VID_Error (ERR_DROP, "model %s has no vertices", mod->name);

	if (pheader->num_xyz > MAX_VERTS)
		VID_Error (ERR_DROP, "model %s has too many vertices", mod->name);

	if (pheader->num_st <= 0)
		VID_Error (ERR_DROP, "model %s has no st vertices", mod->name);

	if (pheader->num_tris <= 0)
		VID_Error (ERR_DROP, "model %s has no triangles", mod->name);

	if (pheader->num_frames <= 0)
		VID_Error (ERR_DROP, "model %s has no frames", mod->name);

	if (pheader->num_skins >= 31)
		VID_Error (ERR_DROP, "model %s has too many skins", mod->name);

	if (pheader->ofs_st <= 0 || pheader->ofs_frames <= 0 || pheader->ofs_glcmds <= 0 ||
		pheader->ofs_skins <= 0 || pheader->ofs_tris <= 0)
		VID_Error (ERR_DROP, "model %s has invalid offsets", mod->name);

	required = 0;

	required += sizeof(dmdl_t);

	required += pheader->num_st * sizeof(dstvert_t);
	required += pheader->num_tris * sizeof(dtriangle_t);
	required += pheader->num_frames * (sizeof(daliasframe_t)-4);

	//variable sized
	required += pheader->num_xyz * pheader->num_frames * sizeof(dtrivertx_t);

	required += pheader->num_glcmds * sizeof(int);
	required += pheader->num_skins * MAX_SKINNAME;

	if (pheader->ofs_end != required)
		VID_Error (ERR_DROP, "model %s has bad size header (%d != %d)", mod->name, pheader->ofs_end, required);

	if (pheader->ofs_frames + pheader->num_frames * sizeof(daliasframe_t) > required)
		VID_Error (ERR_DROP, "model %s has illegal frames offset", mod->name);

	if (pheader->ofs_glcmds + pheader->num_glcmds * sizeof(int) > required)
		VID_Error (ERR_DROP, "model %s has illegal glcmds offset", mod->name);
	
	if (pheader->ofs_skins + pheader->num_skins * MAX_SKINNAME > required)
		VID_Error (ERR_DROP, "model %s has illegal skins offset", mod->name);

	if (pheader->ofs_st + pheader->num_st * sizeof(dstvert_t) > required)
		VID_Error (ERR_DROP, "model %s has illegal vertices offset", mod->name);

	if (pheader->ofs_tris + pheader->num_tris * sizeof(dtriangle_t) > required)
		VID_Error (ERR_DROP, "model %s has illegal triangles offset", mod->name);

	if (pheader->framesize * pheader->num_frames != pheader->num_frames * (int)((sizeof(daliasframe_t)-4) + pheader->num_xyz*sizeof(dtrivertx_t)))
		VID_Error (ERR_DROP, "model %s has invalid frame size", mod->name);

	pheader = (dmdl_t *) Hunk_Alloc (required);
	memcpy (pheader, &header, sizeof(dmdl_t));
	//
// load base s and t vertices (not used in gl version)
//
	pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
	poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);

	memcpy (poutst, pinst, pheader->num_st * sizeof(dstvert_t));

//
// load triangle lists
//
	pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
	pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);

	memcpy (pouttri, pintri, pheader->num_tris * sizeof(dtriangle_t));

//
// load the frames
//

	for (i=0 ; i<pheader->num_frames ; i++)
	{
		pinframe = (daliasframe_t *) ((byte *)pinmodel 
			+ pheader->ofs_frames + i * pheader->framesize);
		poutframe = (daliasframe_t *) ((byte *)pheader 
			+ pheader->ofs_frames + i * pheader->framesize);

		memcpy (poutframe, pinframe, sizeof(daliasframe_t)-4);
		memcpy (poutframe->verts, pinframe->verts, pheader->num_xyz*sizeof(dtrivertx_t));
	}

	mod->type = mod_alias;

	//
	// load the glcmds
	//
	pincmd = (int *) ((byte *)pinmodel + pheader->ofs_glcmds);
	poutcmd = (int *) ((byte *)pheader + pheader->ofs_glcmds);

	memcpy (poutcmd, pincmd, pheader->num_glcmds * sizeof(int));


	// register all skins
	memcpy ((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
		pheader->num_skins*MAX_SKINNAME);

	for (i=0 ; i<pheader->num_skins ; i++)
	{
		skin_name = (char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME;
		fast_strlwr (skin_name);
		mod->skins[i] = GL_FindImage (skin_name, skin_name, it_skin);
	}

	mod->mins[0] = -32;
	mod->mins[1] = -32;
	mod->mins[2] = -32;

	mod->maxs[0] = 32;
	mod->maxs[1] = 32;
	mod->maxs[2] = 32;
}
Пример #17
0
void R_SetSky (char *name, float rotate, vec3_t axis)
{
	int		i;
	char	pathname[MAX_QPATH];
	char	*s;

	if (!skycanchange) // so people can't shut fog off.
		return;

	Q_strncpyz(skyname, name, sizeof(skyname) - 1);
	skyrotate = rotate;
	VectorCopy(axis, skyaxis);

	// ==
	// jitfog -- parse fog code from sky name
	if ((s = strstr(skyname, "fog "))) // jitodo
	{
		sscanf(s + 4, "%f %f %f %f",
			&fogcolor[0], &fogcolor[1], &fogcolor[2],
			&fogdistance);
		fogdensity = 0.0f;
		fogenabled = true;
		skycanchange = false;
	}
	else if ((s = strstr(skyname, "fogd "))) // jitfog
	{
		sscanf(s + 5, "%f %f %f %f",
			&fogcolor[0], &fogcolor[1], &fogcolor[2],
			&fogdensity);
		fogdistance = 0.0f;

		if (fogdensity)
			fogenabled = true;

		skycanchange = false;
	}

	// jitfog -- strip fog code from sky name:
	if ((s = strchr(skyname, ' ')))
		*s = 0;

	if (gl_skyedge->value > 0.01)
		ri.Cvar_Set("gl_skyedge", "0.01");

	for (i = 0; i < 6; i++)
	{
		Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
		sky_images[i] = GL_FindImage(pathname, it_sky);

		if (!sky_images[i])
		{
			if (fogenabled) // jitfog
				sky_images[i] = r_whitetexture;
			else
				sky_images[i] = r_notexture;
		}
	}

	sky_min = 0 + gl_skyedge->value;
	sky_max = 1 - gl_skyedge->value;

	if (s) // jitfog -- reenable fog code.
		*s = ' ';
}
Пример #18
0
/*
=================
Mod_LoadTexinfo
=================
*/
void Mod_LoadTexinfo (lump_t *l)
{
	texinfo_t *in;
//	image_t	*last_image;
	mtexinfo_t *out, *step;
	int 	i, count;
	char	name[MAX_QPATH];
	int		next;
	size_t	length;

	in = (texinfo_t *)(mod_base + l->fileofs);
	
	if (l->filelen % sizeof(*in))
		VID_Error (ERR_DROP, "Mod_LoadTexinfo: funny lump size in %s",loadmodel->name);

	count = l->filelen / sizeof(*in);
	out = (mtexinfo_t *) Hunk_Alloc ( count*sizeof(*out));

	loadmodel->texinfo = out;
	loadmodel->numtexinfo = count;

	for ( i=0 ; i<count ; i++, in++, out++)
	{
		memcpy (out->vecs, in->vecs, sizeof(out->vecs));

		out->flags = LittleLong(in->flags);
		next = LittleLong(in->nexttexinfo);

		if (next > 0)
			out->next = loadmodel->texinfo + next;
		else
		    out->next = NULL;

		fast_strlwr (in->texture);

		out->image = GL_FindImageBase (in->texture, it_wall);

		if (out->image)
			continue;

		Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
		
		if (!GetWalInfo (name, &global_hax_texture_x, &global_hax_texture_y))
		{
			VID_Printf (PRINT_ALL, "Couldn't load %s\n", name);
			out->image = r_notexture;
			continue;
		}

		length = strlen(name);

		if (load_tga_wals)
		{
			//Com_sprintf (name, sizeof(name), "textures/%s.tga", in->texture);
			memcpy (name + length-3, "tga", 3);
			out->image = GL_FindImage (name, in->texture, it_wall);
		}
		else
		{
			out->image = NULL;
		}

		if (!out->image)
		{
			if (load_png_wals)
			{
				memcpy (name + length-3, "png", 3);
				//Com_sprintf (name, sizeof(name), "textures/%s.png", in->texture);
				out->image = GL_FindImage (name, in->texture, it_wall);
			}

			if (!out->image)
			{
				if (load_jpg_wals)
				{
					memcpy (name + length-3, "jpg", 3);
					//Com_sprintf (name, sizeof(name), "textures/%s.jpg", in->texture);
					out->image = GL_FindImage (name, in->texture, it_wall);
				}

				if (!out->image)
				{
					memcpy (name + length-3, "wal", 3);
					//Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
					out->image = GL_FindImage (name, in->texture, it_wall);
					
					if (!out->image)
					{
						VID_Printf (PRINT_ALL, "Couldn't load %s\n", name);
						out->image = r_notexture;
					}
				}
			}
		}

		//last_image = out->image;

		global_hax_texture_x = global_hax_texture_y = 0;
	}

	// count animation frames
	for (i=0 ; i<count ; i++)
	{
		out = &loadmodel->texinfo[i];
		out->numframes = 1;
		for (step = out->next ; step && step != out ; step=step->next)
			out->numframes++;
	}
}
Пример #19
0
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, void *buffer)
{
	int					i, j;
	dmdl_t				*pinmodel, *pheader;
	dstvert_t			*pinst, *poutst;
	dtriangle_t			*pintri, *pouttri;
	daliasframe_t		*pinframe, *poutframe;
	int					*pincmd, *poutcmd;
	int					version;

	pinmodel = (dmdl_t *)buffer;

	version = LittleLong (pinmodel->version);
	if (version != ALIAS_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
				 mod->name, version, ALIAS_VERSION);

	pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));
	
	// byte swap the header fields and sanity check
	for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
		((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);

	if (pheader->skinheight > MAX_LBM_HEIGHT)
		ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
				   MAX_LBM_HEIGHT);

	if (pheader->num_xyz <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);

	if (pheader->num_xyz > MAX_VERTS)
		ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);

	if (pheader->num_st <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);

	if (pheader->num_tris <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);

	if (pheader->num_frames <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);

//
// load base s and t vertices (not used in gl version)
//
	pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
	poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);

	for (i=0 ; i<pheader->num_st ; i++)
	{
		poutst[i].s = LittleShort (pinst[i].s);
		poutst[i].t = LittleShort (pinst[i].t);
	}

//
// load triangle lists
//
	pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
	pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);

	for (i=0 ; i<pheader->num_tris ; i++)
	{
		for (j=0 ; j<3 ; j++)
		{
			pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);
			pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);
		}
	}

//
// load the frames
//
	for (i=0 ; i<pheader->num_frames ; i++)
	{
		pinframe = (daliasframe_t *) ((byte *)pinmodel 
			+ pheader->ofs_frames + i * pheader->framesize);
		poutframe = (daliasframe_t *) ((byte *)pheader 
			+ pheader->ofs_frames + i * pheader->framesize);

		memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
		for (j=0 ; j<3 ; j++)
		{
			poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
			poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
		}
		// verts are all 8 bit, so no swapping needed
		memcpy (poutframe->verts, pinframe->verts, 
			pheader->num_xyz*sizeof(dtrivertx_t));

	}

	mod->type = mod_alias;

	//
	// load the glcmds
	//
	pincmd = (int *) ((byte *)pinmodel + pheader->ofs_glcmds);
	poutcmd = (int *) ((byte *)pheader + pheader->ofs_glcmds);
	for (i=0 ; i<pheader->num_glcmds ; i++)
		poutcmd[i] = LittleLong (pincmd[i]);


	// register all skins
	memcpy ((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
		pheader->num_skins*MAX_SKINNAME);
	for (i=0 ; i<pheader->num_skins ; i++)
	{
		mod->skins[i] = GL_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME
			, it_skin);
	}

	mod->mins[0] = -32;
	mod->mins[1] = -32;
	mod->mins[2] = -32;
	mod->maxs[0] = 32;
	mod->maxs[1] = 32;
	mod->maxs[2] = 32;
}
Пример #20
0
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, FILE *file, long base)
{
	int				i, j;
	dmdl_t			inmodel;
	mmdl_t			*pheader;
	daliasframe_t	*poutframe;
	int				*poutcmd;

	Prof_Begin(__FUNCTION__);

	ri.FS_Read(&inmodel, sizeof(inmodel), file);

	if (inmodel.version != ALIAS_VERSION)
		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
		mod->name, inmodel.version, ALIAS_VERSION);

	pheader = &mod->alias;

	pheader->framesize = inmodel.framesize;
	pheader->num_xyz = inmodel.num_xyz;
	pheader->num_tris = inmodel.num_tris;
	pheader->num_frames = inmodel.num_frames;

	if (pheader->num_xyz <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);

	if (pheader->num_xyz > MAX_VERTS)
		ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);

	if (pheader->num_tris <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);

	if (pheader->num_frames <= 0)
		ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);

	mod->type = mod_alias;

	//
	// load the frames
	//
	pheader->frames = Hunk_Alloc(&hunk_ref, pheader->num_frames * pheader->framesize);

	fseek(file, base + inmodel.ofs_frames, SEEK_SET);
	ri.FS_Read(pheader->frames, pheader->num_frames * pheader->framesize, file);

	mod->type = mod_alias;

	//
	// load the glcmds
	//

	pheader->glcmds = Hunk_Alloc(&hunk_ref, inmodel.num_glcmds * sizeof(int));

	fseek(file, base + inmodel.ofs_glcmds, SEEK_SET);
	ri.FS_Read(pheader->glcmds, inmodel.num_glcmds * sizeof(int), file);

	// Count the number of vertices.
	pheader->num_vertices = 0;
	poutcmd = pheader->glcmds;
	while (1)
	{
		int count;
		
		count = *poutcmd;
		if (count < 0)
		{
			count = -count;
		}
		else if (count == 0)
		{
			break;
		}
		
		pheader->num_vertices += count;

		poutcmd += ((count * 3) + 1);
	}

	// register all skins
	fseek(file, base + inmodel.ofs_skins, SEEK_SET);
	for (i=0 ; i<inmodel.num_skins ; i++)
	{
		char name[MAX_SKINNAME];

		ri.FS_Read(name, MAX_SKINNAME, file);

		assert(mod->skins[i] == NULL);
		mod->skins[i] = GL_FindImage (name, it_skin);
	}

	// TODO PeterM Is this used anywhere?
	mod->numframes = pheader->num_frames;

	mod->mins[0] = -32;
	mod->mins[1] = -32;
	mod->mins[2] = -32;
	mod->maxs[0] = 32;
	mod->maxs[1] = 32;
	mod->maxs[2] = 32;

	Prof_End();
}