Example #1
0
/**
 * @brief Loads the image or model for a given particle art
 */
static inline void CL_ParticleLoadArt (ptlArt_t *a)
{
	/* register the art */
	switch (a->type) {
	case ART_PIC:
		{
			const char *imageName;
			/* only one image */
			if (a->name[0] != '+')
				imageName = a->name;
			else /* load several frames */
				imageName = va("%s%c%c", a->name + 1, a->frame / 10 + '0', a->frame % 10 + '0');
			a->art.image = R_FindPics(imageName);
			if (!a->art.image)
				Com_Printf("CL_ParticleLoadArt: Could not load image: '%s'\n", imageName);
		}
		break;
	case ART_MODEL:
		/** @todo Support the frame data from ptlArt_t for models, too */
		a->art.model = R_FindModel(a->name);
		break;
	default:
		Com_Error(ERR_DROP, "CL_ParticleLoadArt: Unknown art type\n");
	}
}
Example #2
0
/**
 * @brief Add function for brush models
 * @sa LE_AddToScene
 */
bool LE_BrushModelAction (le_t* le, entity_t* ent)
{
	switch (le->type) {
	case ET_ROTATING:
	case ET_DOOR:
		/* These cause the model to render correctly */
		le->aabb.set(ent->eBox);
		VectorCopy(ent->origin, le->origin);
		VectorCopy(ent->angles, le->angles);
		break;
	case ET_DOOR_SLIDING:
		VectorCopy(le->origin, ent->origin);
		break;
	case ET_BREAKABLE:
		break;
	case ET_TRIGGER_RESCUE: {
		const int drawFlags = cl_map_draw_rescue_zone->integer;

		if (!((1 << cl_worldlevel->integer) & le->levelflags))
			return false;

		ent->flags = 0; /* Do not draw anything at all, if drawFlags set to 0 */
		enum { DRAW_TEXTURE = 0x1, DRAW_CIRCLES = 0x2 };
		ent->model = nullptr;
		ent->alpha = 0.3f;
		VectorSet(ent->color, 0.5f, 1.0f, 0.0f);
		if ((drawFlags & DRAW_TEXTURE) && ent->texture == nullptr) {
			ent->flags = RF_BOX;
			ent->texture = R_FindPics("sfx/misc/rescue");
			VectorSet(ent->color, 1, 1, 1);
		}
		ent->eBox.set(le->aabb);

		if (!(drawFlags & DRAW_CIRCLES))
			return false;

		/* The triggerbox seems to be 'off-by-one'. The '- UNIT_SIZE' compensates for that. */
		for (vec_t x = le->aabb.getMinX(); x < le->aabb.getMaxX() - UNIT_SIZE; x += UNIT_SIZE) {
			for (vec_t y = le->aabb.getMinY(); y < le->aabb.getMaxY() - UNIT_SIZE; y += UNIT_SIZE) {
				const vec3_t center = {x + UNIT_SIZE / 2, y + UNIT_SIZE / 2, le->aabb.getMinZ()};

				entity_t circle(RF_PATH);
				VectorCopy(center, circle.origin);
				circle.oldorigin[0] = circle.oldorigin[1] = circle.oldorigin[2] = UNIT_SIZE / 2.0f;
				VectorCopy(ent->color, circle.color);
				circle.alpha = ent->alpha;

				R_AddEntity(&circle);
			}
		}

		/* no other rendering entities should be added for the local entity */
		return false;
	}
	default:
		break;
	}

	return true;
}
Example #3
0
/**
 * @brief Precaches the models and images for a sequence
 * @return 1 - increase the command position of the sequence by one
 * @sa R_RegisterModelShort
 * @sa R_RegisterImage
 */
static int SEQ_ExecutePrecache (sequenceContext_t *context, const char *name, const char *data)
{
	if (Q_streq(name, "models")) {
		while (*data) {
			Com_DPrintf(DEBUG_CLIENT, "Precaching model: %s\n", data);
			R_FindModel(data);
			data += strlen(data) + 1;
		}
	} else if (Q_streq(name, "pics")) {
		while (*data) {
			Com_DPrintf(DEBUG_CLIENT, "Precaching image: %s\n", data);
			R_FindPics(data);
			data += strlen(data) + 1;
		}
	} else
		Com_Printf("SEQ_ExecutePrecache: unknown format '%s'\n", name);
	return 1;
}