Ejemplo n.º 1
0
void Brush_MakeFacePlanes (brush_t *b)
{
	face_t	*f;
	int		j;
	vec3_t	t1, t2, t3;

	for (f=b->brush_faces ; f ; f=f->next)
	{
		// convert to a vector / dist plane
		for (j=0 ; j<3 ; j++)
		{
			t1[j] = f->planepts[0][j] - f->planepts[1][j];
			t2[j] = f->planepts[2][j] - f->planepts[1][j];
			t3[j] = f->planepts[1][j];
		}

		Math_CrossProduct(t1,t2,f->plane.normal);
		if(Math_VectorCompare(f->plane.normal,vec3_origin))
			printf("WARNING: brush plane with no normal!\n");
		Math_VectorNormalize(f->plane.normal);
		f->plane.dist = Math_DotProduct(t3,f->plane.normal);
	}
}
Ejemplo n.º 2
0
void Discus_Follow(ServerEntity_t *ent)
{
	vec3_t	vtemp;

	// [23/5/2012] Quick fix for possible issue ~hogsy
	if(!ent || !ent->v.enemy)
		return;

	vtemp[0] = ent->v.enemy->v.origin[0]-ent->v.origin[0];
	vtemp[1] = ent->v.enemy->v.origin[1]-ent->v.origin[1];
	vtemp[2] = ent->v.enemy->v.origin[2]+22.0f-ent->v.origin[2];

	Math_VectorNormalize(vtemp);
	ent->v.velocity[0] = vtemp[0]*3000.0f;
	ent->v.velocity[1] = vtemp[1]*3000.0f;
	ent->v.velocity[2] = vtemp[2]*3000.0f;

	// [25/6/2012] Simplified ~hogsy
	Math_MVToVector(Math_VectorToAngles(ent->v.velocity),ent->v.angles);

	ent->v.think		= Discus_Follow;
	ent->v.dNextThink	= Server.dTime+0.01;
}
Ejemplo n.º 3
0
winding_t *BasePolyForPlane (plane_t *p)
{
	int			i, x;
	vec_t		max, v;
	vec3_t		org, vright, vup;
	winding_t	*w;

	// find the major axis
	max = -BOGUS_RANGE;
	x = -1;
	for (i=0 ; i<3; i++)
	{
		v = fabs(p->normal[i]);
		if (v > max)
		{
			x = i;
			max = v;
		}
	}

	if (x==-1)
		Error("BasePolyForPlane: no axis found");

	Math_VectorCopy(vec3_origin,vup);
	switch (x)
	{
	case 0:
	case 1:
		vup[2] = 1;
		break;
	case 2:
		vup[0] = 1;
		break;
	}


	v = Math_DotProduct(vup,p->normal);
	Math_VectorMA(vup,-v,p->normal,vup);
	Math_VectorNormalize(vup);

	Math_VectorScale(p->normal,p->dist,org);

	Math_CrossProduct(vup,p->normal,vright);

	Math_VectorScale(vup,8192,vup);
	Math_VectorScale(vright,8192,vright);

// project a really big	axis aligned box onto the plane
	w = NewWinding (4);

	Math_VectorSubtract(org,vright,w->points[0]);
	Math_VectorAdd(w->points[0],vup,w->points[0]);

	Math_VectorAdd(org,vright,w->points[1]);
	Math_VectorAdd(w->points[1],vup,w->points[1]);

	Math_VectorAdd(org,vright,w->points[2]);
	Math_VectorSubtract(w->points[2],vup,w->points[2]);

	Math_VectorSubtract(org,vright,w->points[3]);
	Math_VectorSubtract(w->points[3],vup,w->points[3]);

	w->numpoints = 4;

	return w;
}