示例#1
0
/**
 *	@brief Absolute vertical rotation
 *	@param angle	The rotation angle in degrees
 *
 *	Rotation is not from current direction but from origin.
 */
void RCamera::rotate_vert_abs(float angle) {
	psi_rot = angle;
	if (third_person)
		RANGE_BOUND(psi_rot, -90.0f, 90.0f);
	else {
		psi_rot = FLOAT_MOD(psi_rot, 360.0);
		if (psi_rot < 0)
			psi_rot = 360.0f - psi_rot;
	}
}
示例#2
0
/**
 *	@brief Vertically rotate the camera
 *	@param angle	The rotation angle in degrees
 */
void RCamera::rotate_vert(float angle) {
	psi_rot += angle;
	if (third_person)
		RANGE_BOUND(psi_rot, -180.0f, 179.9f);
		if (psi_rot < 0)
			psi_rot = 0.01f;
	else {
		psi_rot = FLOAT_MOD(psi_rot, 360.0);
		if (psi_rot < 0)
			psi_rot = 360.0f - psi_rot;
	}
}
示例#3
0
/*
 *	Backend function for:
 *		rotate_model()
 *		rotate_model_absolute()
 */
static void _rotate_model(enum MD3_BODY_PARTS type, int axis, float degree, int absolute) {
	struct md3_model_t* m = NULL;
	
	if ((axis != X_AXIS) && (axis != Y_AXIS) && (axis != Z_AXIS))
		/* not a valid axis */
		return;
	
	m = world_get_model_by_type(type);
	if (!m)
		return;
	
	if (absolute)
		m->rot[axis] = degree;
	else
		m->rot[axis] += degree;
	
	/* modulate axis rotation to be between 0 and 359 */
	m->rot[axis] = FLOAT_MOD(m->rot[axis], 360);
}
示例#4
0
/*
 *	Rotate all models along the specified axis __to an absolute degree__.
 *
 *	axis can be one of:
 *		X_AXIS
 *		Y_AXIS
 *		Z_AXIS
 *
 *	Exclude can be any MD3_BODY_PARTS OR'ed togther that will not be applied.
 */
void rotate_all_models_absolute(int axis, float degree, unsigned int exclude) {
	struct world_link_models_t* ln = g_world->models;
	while (ln) {
		if (!ln->model) {
			ln = ln->next;
			continue;
		}
		
		if ((ln->model->body_part & exclude) == exclude) {
			/* skip this one */
			ln = ln->next;
			continue;
		}

		ln->model->rot[axis] = degree;
		
		/* modulate axis rotation to be between 0 and 359 */
		ln->model->rot[axis] = FLOAT_MOD(ln->model->rot[axis], 360);

		ln = ln->next;
	}
}
示例#5
0
/**
 *	@brief Absolute horizontal rotation
 *	@param angle	The rotation angle in degrees
 *
 *	Rotation is not from current direction but from origin.
 */
void RCamera::rotate_hor_abs(float angle) {
	theta_rot = FLOAT_MOD(angle, 360.0);
	if (theta_rot < 0)
		theta_rot = 360.0f - theta_rot;
}