Пример #1
0
void R_GetTags (const model_t* mod, const char* tagName, int currentFrame, int oldFrame, const mAliasTagOrientation_t **current, const mAliasTagOrientation_t **old)
{
	const int index = R_GetTagIndexByName(mod, tagName);
	if (index == -1) {
		*current = NULL;
		*old = NULL;
		Com_Printf("Could not get tags for tag %s of model %s\n", tagName, mod->name);
	}
	*current = R_GetTagOrientByFrame(mod, index, currentFrame);
	*old = R_GetTagOrientByFrame(mod, index, oldFrame);
}
Пример #2
0
bool R_GetTagMatrix (const model_t* mod, const char* tagName, int frame, float matrix[16])
{
	const int index = R_GetTagIndexByName(mod, tagName);
	mAliasTagOrientation_t *orient;

	if (index == -1) {
		Com_Printf("Could not get tag matrix for tag %s of model %s\n", tagName, mod->name);
		return false;
	}

	orient = R_GetTagOrientByFrame(mod, index, frame);
	R_ComputeGLMatrixFromTag(matrix, orient);
	return true;
}
Пример #3
0
/**
 * @brief Calculates the muzzle for the current weapon the actor is shooting with
 * @param[in] actor The actor that is shooting. Might not be @c nullptr
 * @param[out] muzzle The muzzle vector to spawn the particle at. Might not be @c nullptr. This is not
 * modified if there is no tag for the muzzle found for the weapon or item the actor has
 * in the hand (also see the given shoot type)
 * @param[in] shootType The shoot type to determine which tag of the actor should be used
 * to resolve the world coordinates. Also used to determine which item (or better which hand)
 * should be used to resolve the actor's item.
 */
static void CL_ActorGetMuzzle (const le_t* actor, vec3_t muzzle, shoot_types_t shootType)
{
	if (actor == nullptr)
		return;

	const Item* weapon;
	const char* tag;
	if (IS_SHOT_RIGHT(shootType)) {
		tag = "tag_rweapon";
		weapon = actor->getRightHandItem();
	} else {
		tag = "tag_lweapon";
		weapon = actor->getLeftHandItem();
	}

	if (!weapon || !weapon->def())
		return;

	const objDef_t* od = weapon->def();
	const model_t* model = cls.modelPool[od->idx];
	if (!model)
		Com_Error(ERR_DROP, "Model for item %s is not precached", od->id);

	/* not every weapon has a muzzle tag assigned */
	if (R_GetTagIndexByName(model, "tag_muzzle") == -1)
		return;

	float modifiedMatrix[16];
	if (!R_GetTagMatrix(actor->model1, tag, actor->as.frame, modifiedMatrix))
		Com_Error(ERR_DROP, "Could not find tag %s for actor model %s", tag, actor->model1->name);

	float mc[16];
	GLMatrixAssemble(actor->origin, actor->angles, mc);

	float matrix[16];
	GLMatrixMultiply(mc, modifiedMatrix, matrix);

	R_GetTagMatrix(model, "tag_muzzle", 0, modifiedMatrix);
	GLMatrixMultiply(matrix, modifiedMatrix, mc);

	muzzle[0] = mc[12];
	muzzle[1] = mc[13];
	muzzle[2] = mc[14];
}