예제 #1
0
파일: collision.c 프로젝트: jogi1/camquake
float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
{
	trace_t trace = PM_TraceLine (start, end); /* PM_TraceLine hits bmodels and players */
	VectorCopy (trace.endpos, impact);
	if (normal)
		VectorCopy (trace.plane.normal, normal);

	return 0.0;
}
예제 #2
0
/*
=================
CL_UpdateBeams
=================
*/
void CL_UpdateBeams (void)
{
    int			i;
    beam_t		*b;
    vec3_t		dist, org;
    float		d, dec;
    entity_t	ent;
    vec3_t		angles;

    dec = 30;
    memset (&ent, 0, sizeof(entity_t));
    ent.colormap = 0;

// update lightning
    for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++)
    {
        if (!b->model || b->endtime < cl.time)
            continue;

        // if coming from the player, update the start position
        if (b->entity == Cam_PlayerNum() + 1 && !cl.intermission)
        {
            VectorCopy (cl.simorg, b->start);
            b->start[2] += cl.crouch;
            if (cl_fakeshaft.value && cl.allow_fakeshaft)
            {
                vec3_t	forward;
                vec3_t	v, org;
                vec3_t	ang;
                float	f, delta;
                trace_t	trace;

                f = max(0, min(1, cl_fakeshaft.value));

                VectorSubtract (playerbeam_end, cl.simorg, v);
                v[2] -= 22;		// adjust for view height
                vectoangles (v, ang);

                // lerp pitch
                ang[0] = -ang[0];
                if (ang[0] < -180)
                    ang[0] += 360;
                ang[0] += (cl.simangles[0] - ang[0]) * f;

                // lerp yaw
                delta = cl.simangles[1] - ang[1];
                if (delta > 180)
                    delta -= 360;
                if (delta < -180)
                    delta += 360;
                ang[1] += delta*f;
                ang[2] = 0;

                AngleVectors (ang, forward, NULL, NULL);
                VectorScale (forward, 600, forward);
                VectorCopy (cl.simorg, org);
                org[2] += 16;
                VectorAdd (org, forward, b->end);

                trace = PM_TraceLine (&cl.pmove, org, b->end);
                if (trace.fraction < 1)
                    VectorCopy (trace.endpos, b->end);
            }
        }

        // calculate pitch and yaw
        VectorSubtract (b->end, b->start, dist);
        vectoangles (dist, angles);

        // add new entities for the lightning
        VectorCopy (b->start, org);
        d = VectorNormalize (dist);
        VectorScale (dist, dec, dist);

        while (d > 0)
        {
            VectorCopy (org, ent.origin);
            ent.model = b->model;
            ent.angles[PITCH] = angles[PITCH];
            ent.angles[YAW] = angles[YAW];
            ent.angles[ROLL] = rand() % 360;
            if (b->model == cl_bolt2_mod)
                ent.alpha = r_shaftalpha.value;

            V_AddEntity (&ent);

            d -= dec;
            VectorAdd (org, dist, org);
        }
    }
}