您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DotProduct函数代码示例

51自学网 2021-06-01 20:29:46
  C++
这篇教程C++ DotProduct函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DotProduct函数的典型用法代码示例。如果您正苦于以下问题:C++ DotProduct函数的具体用法?C++ DotProduct怎么用?C++ DotProduct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DotProduct函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sqrt

 double Vector2::Magnitude() const {     return sqrt( DotProduct( *this ) ); }
开发者ID:jpgaribotti,项目名称:libvector,代码行数:4,


示例2: PM_DrawPhysEntBBox

/*================PM_DrawPhysEntBBox(int num)================*/void PM_DrawPhysEntBBox(int num, int pcolor, float life){	physent_t *pe;	vec3_t     org;	int        j;	vec3_t     tmp;	vec3_t     p[8];	float      gap = BOX_GAP;	vec3_t     modelmins, modelmaxs;	if(num >= pmove->numphysent ||	   num <= 0)		return;	pe = &pmove->physents[num];	if(pe->model)	{		VectorCopy(pe->origin, org);		pmove->PM_GetModelBounds(pe->model, modelmins, modelmaxs);		for(j = 0; j < 8; j++)		{			tmp[0] = (j & 1) ? modelmins[0] - gap : modelmaxs[0] + gap;			tmp[1] = (j & 2) ? modelmins[1] - gap : modelmaxs[1] + gap;			tmp[2] = (j & 4) ? modelmins[2] - gap : modelmaxs[2] + gap;			VectorCopy(tmp, p[j]);		}		// If the bbox should be rotated, do that		if(pe->angles[0] || pe->angles[1] || pe->angles[2])		{			vec3_t forward, right, up;			AngleVectorsTranspose(pe->angles, forward, right, up);			for(j = 0; j < 8; j++)			{				VectorCopy(p[j], tmp);				p[j][0] = DotProduct(tmp, forward);				p[j][1] = DotProduct(tmp, right);				p[j][2] = DotProduct(tmp, up);			}		}		// Offset by entity origin, if any.		for(j = 0; j < 8; j++)			VectorAdd(p[j], org, p[j]);		for(j = 0; j < 6; j++)		{			PM_DrawRectangle(			    p[PM_boxpnt[j][1]],			    p[PM_boxpnt[j][0]],			    p[PM_boxpnt[j][2]],			    p[PM_boxpnt[j][3]],			    pcolor, life);		}	}	else	{		for(j = 0; j < 8; j++)		{			tmp[0] = (j & 1) ? pe->mins[0] : pe->maxs[0];			tmp[1] = (j & 2) ? pe->mins[1] : pe->maxs[1];			tmp[2] = (j & 4) ? pe->mins[2] : pe->maxs[2];			VectorAdd(tmp, pe->origin, tmp);			VectorCopy(tmp, p[j]);		}		for(j = 0; j < 6; j++)		{			PM_DrawRectangle(			    p[PM_boxpnt[j][1]],			    p[PM_boxpnt[j][0]],			    p[PM_boxpnt[j][2]],			    p[PM_boxpnt[j][3]],			    pcolor, life);		}	}}
开发者ID:Sh1ft0x0EF,项目名称:HLSDKRevamp,代码行数:88,


示例3: SV_Physics_Toss

//.........这里部分代码省略.........	}	SV_CheckVelocity( ent );	// add gravity	switch( ent->v.movetype )	{	case MOVETYPE_FLY:	case MOVETYPE_FLYMISSILE:	case MOVETYPE_BOUNCEMISSILE:		break;	default:		SV_AddGravity( ent );		break;	}	// move angles (with friction)	switch( ent->v.movetype )	{	case MOVETYPE_TOSS:	case MOVETYPE_BOUNCE:		SV_AngularMove( ent, host.frametime, ent->v.friction );		break;         	default:		SV_AngularMove( ent, host.frametime, 0.0f );		break;	}	// move origin	// Base velocity is not properly accounted for since this entity will move again	// after the bounce without taking it into account	VectorAdd( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );	SV_CheckVelocity( ent );	VectorScale( ent->v.velocity, host.frametime, move );	VectorSubtract( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );	trace = SV_PushEntity( ent, move, vec3_origin, NULL );	if( ent->free ) return;	SV_CheckVelocity( ent );	if( trace.allsolid )	{		// entity is trapped in another solid		VectorClear( ent->v.avelocity );		VectorClear( ent->v.velocity );		return;	}	if( trace.fraction == 1.0f )	{		SV_CheckWaterTransition( ent );		return;	}	if( ent->v.movetype == MOVETYPE_BOUNCE )		backoff = 2.0f - ent->v.friction;	else if( ent->v.movetype == MOVETYPE_BOUNCEMISSILE )		backoff = 2.0f;	else backoff = 1.0f;	SV_ClipVelocity( ent->v.velocity, trace.plane.normal, ent->v.velocity, backoff );	// stop if on ground	if( trace.plane.normal[2] > 0.7f )	{				float	vel;		VectorAdd( ent->v.velocity, ent->v.basevelocity, move );		vel = DotProduct( move, move );		if( ent->v.velocity[2] < sv_gravity->value * host.frametime )		{			// we're rolling on the ground, add static friction.			ent->v.groundentity = trace.ent;			ent->v.flags |= FL_ONGROUND;			ent->v.velocity[2] = 0.0f;		}		if( vel < 900.0f || ( ent->v.movetype != MOVETYPE_BOUNCE && ent->v.movetype != MOVETYPE_BOUNCEMISSILE ))		{			ent->v.flags |= FL_ONGROUND;			ent->v.groundentity = trace.ent;			VectorClear( ent->v.avelocity );			VectorClear( ent->v.velocity );		}		else		{			VectorScale( ent->v.velocity, (1.0f - trace.fraction) * host.frametime * 0.9f, move );			VectorMA( move, (1.0f - trace.fraction) * host.frametime * 0.9f, ent->v.basevelocity, move );			trace = SV_PushEntity( ent, move, vec3_origin, NULL );			if( ent->free ) return;		}	}		// check for in water	SV_CheckWaterTransition( ent );}
开发者ID:Fograin,项目名称:hl-subsmod-ex,代码行数:101,


示例4: StudioFrameAdvance

//=========================================================// Hornet is flying, gently tracking target//=========================================================void CHornet::TrackTarget(void){	Vector	vecFlightDir;	Vector	vecDirToEnemy;	float	flDelta;	StudioFrameAdvance();	if (gpGlobals->time > m_flStopAttack)	{		SetTouch(NULL);		SetThink(&CHornet::SUB_Remove);		SetNextThink(0.1);		return;	}	// UNDONE: The player pointer should come back after returning from another level	if (m_hEnemy == NULL)	{// enemy is dead.		Look(512);		m_hEnemy = BestVisibleEnemy();	}	if (m_hEnemy != NULL && FVisible(m_hEnemy))	{		m_vecEnemyLKP = m_hEnemy->BodyTarget(pev->origin);	}	else	{		m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1;	}	vecDirToEnemy = (m_vecEnemyLKP - pev->origin).Normalize();	if (pev->velocity.Length() < 0.1)		vecFlightDir = vecDirToEnemy;	else		vecFlightDir = pev->velocity.Normalize();	// measure how far the turn is, the wider the turn, the slow we'll go this time.	flDelta = DotProduct(vecFlightDir, vecDirToEnemy);	if (flDelta < 0.5)	{// hafta turn wide again. play sound		switch (RANDOM_LONG(0, 2))		{		case 0:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM);	break;		case 1:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM);	break;		case 2:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM);	break;		}	}	if (flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED)	{// no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far.		flDelta = 0.25;	}	pev->velocity = (vecFlightDir + vecDirToEnemy).Normalize();	if (pev->owner && (pev->owner->v.flags & FL_MONSTER))	{		// random pattern only applies to hornets fired by monsters, not players. 		pev->velocity.x += RANDOM_FLOAT(-0.10, 0.10);// scramble the flight dir a bit.		pev->velocity.y += RANDOM_FLOAT(-0.10, 0.10);		pev->velocity.z += RANDOM_FLOAT(-0.10, 0.10);	}	switch (m_iHornetType)	{	case HORNET_TYPE_RED:		pev->velocity = pev->velocity * (m_flFlySpeed * flDelta);// scale the dir by the ( speed * width of turn )		SetNextThink(RANDOM_FLOAT(0.1, 0.3));		break;	case HORNET_TYPE_ORANGE:		pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn.		SetNextThink(0.1);// fixed think time		break;	}	pev->angles = UTIL_VecToAngles(pev->velocity);	pev->solid = SOLID_BBOX;	// if hornet is close to the enemy, jet in a straight line for a half second.	// (only in the single player game)	if (m_hEnemy != NULL && !g_pGameRules->IsMultiplayer())	{		if (flDelta >= 0.4 && (pev->origin - m_vecEnemyLKP).Length() <= 300)		{			MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin);			WRITE_BYTE(TE_SPRITE);			WRITE_COORD(pev->origin.x);	// pos			WRITE_COORD(pev->origin.y);			WRITE_COORD(pev->origin.z);			WRITE_SHORT(iHornetPuff);		// model			// WRITE_BYTE( 0 );				// life * 10//.........这里部分代码省略.........
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.9--VC2010,代码行数:101,


示例5: MakeRGBScales

//.........这里部分代码省略.........						, transparency	#endif						) || (i==j))					{						continue;					}					useback = true;				}				else				{					continue;				}#else                continue;#endif            }            normal2 = getPlaneFromFaceNumber(patch2->faceNumber)->normal;            // calculate transferemnce            VectorSubtract(patch2->origin, origin, delta);#ifdef HLRAD_TRANSLUCENT			if (useback)			{				VectorSubtract (patch2->origin, backorigin, delta);			}#endif#ifdef HLRAD_ACCURATEBOUNCE			// move emitter back to its plane			VectorMA (delta, -PATCH_HUNT_OFFSET, normal2, delta);#endif            dist = VectorNormalize(delta);            dot1 = DotProduct(delta, normal1);#ifdef HLRAD_TRANSLUCENT			if (useback)			{				dot1 = DotProduct (delta, backnormal);			}#endif            dot2 = -DotProduct(delta, normal2);#ifdef HLRAD_ACCURATEBOUNCE#ifdef HLRAD_ACCURATEBOUNCE_ALTERNATEORIGIN			bool light_behind_surface = false;			if (dot1 <= NORMAL_EPSILON)			{				light_behind_surface = true;			}#else			if (dot1 <= NORMAL_EPSILON)			{				continue;			}#endif			if (dot2 * dist <= MINIMUM_PATCH_DISTANCE)			{				continue;			}#endif			#ifdef HLRAD_DIVERSE_LIGHTING			if (lighting_diversify	#ifdef HLRAD_ACCURATEBOUNCE_ALTERNATEORIGIN				&& !light_behind_surface	#endif				)
开发者ID:emileb,项目名称:XashXT,代码行数:67,


示例6: CONPRINT

// draws this grass particle//extern void RenderFog ( void );	// Fograin92: Disabledvoid CGrassParticle::Draw( void ){	if (m_bIngoreParticle == true)		return;	if(sParticle.pTexture == NULL) {		CONPRINT("Null texture in particle/n");		return;	}	Vector vForward, vRight, vUp, vDir;	AngleVectors(v_angles, vForward, vRight, vUp );	vDir = ( sParticle.vPosition - flPlayerOrigin ).Normalize( );	if ( DotProduct ( vDir, vForward ) < 0 )		return;	int iHealth = 0;	// lets make sure transparency doesn't overflow or udnerflow	if (sParticle.iTransparency > 255)		sParticle.iTransparency = 255;	if (sParticle.iTransparency < 0)		sParticle.iTransparency = 0;	iHealth = sParticle.iTransparency;	if (pSys->bLOD) // fade out particles that are further away (LOD)	{		float flDistance = sqrt(sParticle.flSquareDistanceToPlayer);		if ((flDistance > m_flLodMinDistance) && (flDistance < m_flLodMaxDistance))		{			float flTransparencyFactor = 1 - ((flDistance - m_flLodMinDistance) / (m_flLodMaxDistance - m_flLodMinDistance));							if (flTransparencyFactor > 1)				flTransparencyFactor = 1;			if (flTransparencyFactor < 0)				flTransparencyFactor = 0;			iHealth *= flTransparencyFactor;		}	}	vec3_t vPoint, vPosition;	vec3_t vWaveForward, vWaveRight, vWaveUp;	// We again copy part->origin into another vector to prevent us accidentally messing with it	VectorCopy( sParticle.vPosition, vPosition );	AngleVectors(m_vNormal, vForward, vRight, vUp);	AngleVectors(m_vWaveNormal, vWaveForward, vWaveRight, vWaveUp);	glColor4ub(sParticle.iRed, sParticle.iGreen, sParticle.iBlue,iHealth);  	//RenderFog();	// Fograin92: Disabled	// Finally, we draw the particle	glBindTexture(GL_TEXTURE_2D, sParticle.pTexture->iID);	glBegin(GL_QUADS);	glTexCoord2f(0, 0.95f);	VectorMA (sParticle.vPosition, sParticle.flSize, vWaveUp, vPoint);	VectorMA (vPoint, -sParticle.flSize, vWaveRight, vPoint);	glVertex3fv(vPoint); 	glTexCoord2f(0.95f, 0.95f); 	VectorMA (sParticle.vPosition, sParticle.flSize, vWaveUp, vPoint);	VectorMA (vPoint, sParticle.flSize, vWaveRight, vPoint);	glVertex3fv(vPoint);	glTexCoord2f(0.95f, 0);	VectorMA (sParticle.vPosition, -sParticle.flSize, vUp, vPoint);	VectorMA (vPoint, sParticle.flSize, vRight, vPoint);	glVertex3fv(vPoint);	glTexCoord2f(0, 0);	VectorMA (sParticle.vPosition, -sParticle.flSize, vUp, vPoint);	VectorMA (vPoint, -sParticle.flSize, vRight, vPoint);	glVertex3fv(vPoint);    	glEnd();}
开发者ID:Hammermaps-DEV,项目名称:SOHL-V1.9-Opposing-Force-Edition,代码行数:81,


示例7: R_RecursiveClipBPoly

void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf) {	bedge_t *psideedges[2], *pnextedge, *ptedge;	int i, side, lastside;	float dist, frac, lastdist;	mplane_t *splitplane, tplane;	mvertex_t *pvert, *plastvert, *ptvert;	mnode_t *pn;	psideedges[0] = psideedges[1] = NULL;	makeclippededge = false;	// transform the BSP plane into model space	// FIXME: cache these?	splitplane = pnode->plane;	tplane.dist = -PlaneDiff(r_entorigin, splitplane);	tplane.normal[0] = PlaneDist (entity_rotation[0], splitplane);	tplane.normal[1] = PlaneDist (entity_rotation[1], splitplane);	tplane.normal[2] = PlaneDist (entity_rotation[2], splitplane);	// clip edges to BSP plane	for ( ; pedges ; pedges = pnextedge) {		pnextedge = pedges->pnext;		// set the status for the last point as the previous point		// FIXME: cache this stuff somehow?		plastvert = pedges->v[0];				lastdist = DotProduct (plastvert->position, tplane.normal) - tplane.dist;		lastside = (lastdist <= 0);		pvert = pedges->v[1];				dist = DotProduct (pvert->position, tplane.normal) - tplane.dist;		side = (dist <= 0);		if (side != lastside) {			// clipped			if (numbverts >= MAX_BMODEL_VERTS)				return;			// generate the clipped vertex			frac = lastdist / (lastdist - dist);			ptvert = &pbverts[numbverts++];			ptvert->position[0] = plastvert->position[0] + frac * (pvert->position[0] -	plastvert->position[0]);			ptvert->position[1] = plastvert->position[1] + frac * (pvert->position[1] - plastvert->position[1]);			ptvert->position[2] = plastvert->position[2] + frac * (pvert->position[2] - plastvert->position[2]);			// split into two edges, one on each side, and remember entering			// and exiting points			// FIXME: share the clip edge by having a winding direction flag?			if (numbedges >= (MAX_BMODEL_EDGES - 1)) {				Com_Printf ("Out of edges for bmodel/n");				return;			}			ptedge = &pbedges[numbedges];			ptedge->pnext = psideedges[lastside];			psideedges[lastside] = ptedge;			ptedge->v[0] = plastvert;			ptedge->v[1] = ptvert;			ptedge = &pbedges[numbedges + 1];			ptedge->pnext = psideedges[side];			psideedges[side] = ptedge;			ptedge->v[0] = ptvert;			ptedge->v[1] = pvert;			numbedges += 2;			if (side == 0) {				// entering for front, exiting for back				pfrontenter = ptvert;				makeclippededge = true;			} else {				pfrontexit = ptvert;				makeclippededge = true;			}		} else {			// add the edge to the appropriate side			pedges->pnext = psideedges[side];			psideedges[side] = pedges;		}	}	// if anything was clipped, reconstitute and add the edges along the clip	// plane to both sides (but in opposite directions)	if (makeclippededge) {		if (numbedges >= (MAX_BMODEL_EDGES - 2)) {			Com_Printf ("Out of edges for bmodel/n");			return;		}		ptedge = &pbedges[numbedges];		ptedge->pnext = psideedges[0];		psideedges[0] = ptedge;		ptedge->v[0] = pfrontexit;		ptedge->v[1] = pfrontenter;		ptedge = &pbedges[numbedges + 1];//.........这里部分代码省略.........
开发者ID:AAS,项目名称:ezquake-source,代码行数:101,


示例8: R_DrawAliasFrameLerp

/*=================R_DrawAliasFrameLerp=================*/void R_DrawAliasFrameLerp (maliasmodel_t *paliashdr, entity_t *e){	int			i, j, k, meshnum;	maliasframe_t	*frame, *oldframe;	maliasmesh_t	mesh;	maliasvertex_t	*v, *ov;	vec3_t		move, delta, vectors[3];	vec3_t		curScale, oldScale, curNormal, oldNormal;	vec3_t		tempNormalsArray[MD3_MAX_VERTS];	vec2_t		tempSkinCoord;	vec3_t		meshlight, lightcolor;	float		alpha, meshalpha, thisalpha, shellscale, frontlerp, backlerp = e->backlerp;	image_t		*skin;	renderparms_t	skinParms;	qboolean	shellModel = e->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM);	frontlerp = 1.0 - backlerp;	if (e->flags & RF_TRANSLUCENT)		alpha = e->alpha;	else		alpha = 1.0;	frame = paliashdr->frames + e->frame;	oldframe = paliashdr->frames + e->oldframe;	VectorScale(frame->scale, frontlerp, curScale);	VectorScale(oldframe->scale, backlerp, oldScale);	// move should be the delta back to the previous frame * backlerp	VectorSubtract (e->oldorigin, e->origin, delta);	AngleVectors (e->angles, vectors[0], vectors[1], vectors[2]);	move[0] = DotProduct (delta, vectors[0]);	// forward	move[1] = -DotProduct (delta, vectors[1]);	// left	move[2] = DotProduct (delta, vectors[2]);	// up	VectorAdd (move, oldframe->translate, move);	for (i=0 ; i<3 ; i++)		move[i] = backlerp*move[i] + frontlerp*frame->translate[i];	R_SetVertexOverbrights(true);	R_SetShellBlend (true);	// new outer loop for whole model	for (k=0, meshnum=0; k < paliashdr->num_meshes; k++, meshnum++)	{		mesh = paliashdr->meshes[k];		skinParms = mesh.skins[e->skinnum].renderparms;		// select skin		if (e->skin)			skin = e->skin;	// custom player skin		else			skin = currentmodel->skins[k][e->skinnum];		if (!skin)			skin = r_notexture;		if ( !shellModel )			GL_Bind(skin->texnum);		else if (FlowingShell())			alpha = 0.7;		// md3 skin scripting		if (skinParms.nodraw) 			continue; // skip this mesh for this skin		if (skinParms.twosided)			GL_Disable(GL_CULL_FACE);		if (skinParms.alphatest && !shellModel)			GL_Enable(GL_ALPHA_TEST);		if (skinParms.fullbright)			VectorSet(meshlight, 1.0f, 1.0f, 1.0f);		else			VectorCopy(shadelight, meshlight);		meshalpha = alpha * skinParms.basealpha;		if (meshalpha < 1.0f || skinParms.blend)			GL_Enable (GL_BLEND);		else			GL_Disable (GL_BLEND);		if (skinParms.blend && !shellModel)			GL_BlendFunc (skinParms.blendfunc_src, skinParms.blendfunc_dst);		else			GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);		// md3 skin scripting		v = mesh.vertexes + e->frame*mesh.num_verts;		ov = mesh.vertexes + e->oldframe*mesh.num_verts;		rb_vertex = 0;//.........这里部分代码省略.........
开发者ID:ptitSeb,项目名称:gravitybone-pandora,代码行数:101,


示例9: RB_BeginDrawingView

/*=================RB_BeginDrawingViewAny mirrored or portaled views have already been drawn, so prepareto actually render the visible surfaces for this view=================*/void RB_BeginDrawingView (void) {	int clearBits = 0;	// sync with gl if needed	if ( r_finish->integer == 1 && !glState.finishCalled ) {		qglFinish ();		glState.finishCalled = qtrue;	}	if ( r_finish->integer == 0 ) {		glState.finishCalled = qtrue;	}	// we will need to change the projection matrix before drawing	// 2D images again	backEnd.projection2D = qfalse;	//	// set the modelview matrix for the viewer	//	SetViewportAndScissor();	// ensures that depth writes are enabled for the depth clear	GL_State( GLS_DEFAULT );	// clear relevant buffers	clearBits = GL_DEPTH_BUFFER_BIT;	if ( r_measureOverdraw->integer || r_shadows->integer == 2 )	{		clearBits |= GL_STENCIL_BUFFER_BIT;	}	if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )	{		clearBits |= GL_COLOR_BUFFER_BIT;	// FIXME: only if sky shaders have been used#ifdef _DEBUG		qglClearColor( 0.8f, 0.7f, 0.4f, 1.0f );	// FIXME: get color of sky#else		qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f );	// FIXME: get color of sky#endif	}	qglClear( clearBits );	if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) )	{		RB_Hyperspace();		return;	}	else	{		backEnd.isHyperspace = qfalse;	}	glState.faceCulling = -1;		// force face culling to set next time	// we will only draw a sun if there was sky rendered in this view	backEnd.skyRenderedThisView = qfalse;	// clip to the plane of the portal	if ( backEnd.viewParms.isPortal ) {		float	plane[4];#ifdef IOS		float		plane2[4];#else		double	plane2[4];#endif // IOS		plane[0] = backEnd.viewParms.portalPlane.normal[0];		plane[1] = backEnd.viewParms.portalPlane.normal[1];		plane[2] = backEnd.viewParms.portalPlane.normal[2];		plane[3] = backEnd.viewParms.portalPlane.dist;		plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane);		plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);		plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);		plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];		qglLoadMatrixf( s_flipMatrix );		qglClipPlane (GL_CLIP_PLANE0, plane2);		qglEnable (GL_CLIP_PLANE0);	} else {		qglDisable (GL_CLIP_PLANE0);	}}
开发者ID:he110world,项目名称:quake3-ios,代码行数:90,


示例10: ShortestLineSegBewteen2LineSegs

float ShortestLineSegBewteen2LineSegs( vec3_t start1, vec3_t end1, vec3_t start2, vec3_t end2, vec3_t close_pnt1, vec3_t close_pnt2 ){	float	current_dist, new_dist;	vec3_t	new_pnt;	//start1, end1 : the first segment	//start2, end2 : the second segment	//output, one point on each segment, the closest two points on the segments.	//compute some temporaries:	//vec start_dif = start2 - start1	vec3_t	start_dif;	VectorSubtract( start2, start1, start_dif );	//vec v1 = end1 - start1	vec3_t	v1;	VectorSubtract( end1, start1, v1 );	//vec v2 = end2 - start2	vec3_t	v2;	VectorSubtract( end2, start2, v2 );	//	float v1v1 = DotProduct( v1, v1 );	float v2v2 = DotProduct( v2, v2 );	float v1v2 = DotProduct( v1, v2 );	//the main computation	float denom = (v1v2 * v1v2) - (v1v1 * v2v2);	//if denom is small, then skip all this and jump to the section marked below	if ( fabs(denom) > 0.001f )	{		float s = -( (v2v2*DotProduct( v1, start_dif )) - (v1v2*DotProduct( v2, start_dif )) ) / denom;		float t = ( (v1v1*DotProduct( v2, start_dif )) - (v1v2*DotProduct( v1, start_dif )) ) / denom;		qboolean done = qtrue;		if ( s < 0 )		{			done = qfalse;			s = 0;// and see note below		}		if ( s > 1 ) 		{			done = qfalse;			s = 1;// and see note below		}		if ( t < 0 ) 		{			done = qfalse;			t = 0;// and see note below		}		if ( t > 1 ) 		{			done = qfalse;			t = 1;// and see note below		}		//vec close_pnt1 = start1 + s * v1		VectorMA( start1, s, v1, close_pnt1 );		//vec close_pnt2 = start2 + t * v2		VectorMA( start2, t, v2, close_pnt2 );		current_dist = Distance( close_pnt1, close_pnt2 );		//now, if none of those if's fired, you are done. 		if ( done )		{			return current_dist;		}		//If they did fire, then we need to do some additional tests.		//What we are gonna do is see if we can find a shorter distance than the above		//involving the endpoints.	}	else	{		//******start here for paralell lines with current_dist = infinity****		current_dist = Q3_INFINITE;	}	//test 2 close_pnts first	/*	G_FindClosestPointOnLineSegment( start1, end1, close_pnt2, new_pnt );	new_dist = Distance( close_pnt2, new_pnt );	if ( new_dist < current_dist )	{//then update close_pnt1 close_pnt2 and current_dist		VectorCopy( new_pnt, close_pnt1 );		VectorCopy( close_pnt2, close_pnt2 );		current_dist = new_dist;	}	G_FindClosestPointOnLineSegment( start2, end2, close_pnt1, new_pnt );	new_dist = Distance( close_pnt1, new_pnt );	if ( new_dist < current_dist )	{//then update close_pnt1 close_pnt2 and current_dist		VectorCopy( close_pnt1, close_pnt1 );		VectorCopy( new_pnt, close_pnt2 );		current_dist = new_dist;	}//.........这里部分代码省略.........
开发者ID:BishopExile,项目名称:OpenJK,代码行数:101,


示例11: R_CullAliasModel

/*=================R_CullAliasModel=================*/static qboolean R_CullAliasModel ( vec3_t bbox[8], entity_t *e ){	int			i, j;	vec3_t		mins, maxs, tmp; //angles;	vec3_t		vectors[3];	maliasmodel_t	*paliashdr;	maliasframe_t	*pframe, *poldframe;	int			mask, aggregatemask = ~0;				paliashdr = (maliasmodel_t *)currentmodel->extradata;	if ( ( e->frame >= paliashdr->num_frames ) || ( e->frame < 0 ) )	{		VID_Printf (PRINT_ALL, "R_CullAliasModel %s: no such frame %d/n", 			currentmodel->name, e->frame);		e->frame = 0;	}	if ( ( e->oldframe >= paliashdr->num_frames ) || ( e->oldframe < 0 ) )	{		VID_Printf (PRINT_ALL, "R_CullAliasModel %s: no such oldframe %d/n", 			currentmodel->name, e->oldframe);		e->oldframe = 0;	}	pframe = paliashdr->frames + e->frame;	poldframe = paliashdr->frames + e->oldframe;	// compute axially aligned mins and maxs	if ( pframe == poldframe )	{		VectorCopy(pframe->mins, mins);		VectorCopy(pframe->maxs, maxs);	}	else	{		for ( i = 0; i < 3; i++ )		{			if (pframe->mins[i] < poldframe->mins[i])				mins[i] = pframe->mins[i];			else				mins[i] = poldframe->mins[i];			if (pframe->maxs[i] > poldframe->maxs[i])				maxs[i] = pframe->maxs[i];			else				maxs[i] = poldframe->maxs[i];		}	}	// jitspoe's bbox rotation fix	// compute and rotate bonding box	e->angles[ROLL] = -e->angles[ROLL]; // roll is backwards	AngleVectors(e->angles, vectors[0], vectors[1], vectors[2]);	e->angles[ROLL] = -e->angles[ROLL]; // roll is backwards	VectorSubtract(vec3_origin, vectors[1], vectors[1]); // AngleVectors returns "right" instead of "left"	for (i = 0; i < 8; i++)	{		tmp[0] = ((i & 1) ? mins[0] : maxs[0]);		tmp[1] = ((i & 2) ? mins[1] : maxs[1]);		tmp[2] = ((i & 4) ? mins[2] : maxs[2]);		bbox[i][0] = vectors[0][0] * tmp[0] + vectors[1][0] * tmp[1] + vectors[2][0] * tmp[2] + e->origin[0];		bbox[i][1] = vectors[0][1] * tmp[0] + vectors[1][1] * tmp[1] + vectors[2][1] * tmp[2] + e->origin[1];		bbox[i][2] = vectors[0][2] * tmp[0] + vectors[1][2] * tmp[1] + vectors[2][2] * tmp[2] + e->origin[2];	}	// cull	for (i=0; i<8; i++)	{		mask = 0;		for (j=0; j<4; j++)		{			float dp = DotProduct(frustum[j].normal, bbox[i]);			if ( ( dp - frustum[j].dist ) < 0 )				mask |= (1<<j);		}		aggregatemask &= mask;	}	if ( aggregatemask )		return true;	return false;}
开发者ID:ptitSeb,项目名称:gravitybone-pandora,代码行数:90,


示例12: VPROF_BUDGET

//-----------------------------------------------------------------------------// Purpose: Do the headlight//-----------------------------------------------------------------------------void CFlashlightEffect::UpdateLightNew(const Vector &vecPos, const Vector &vecForward, const Vector &vecRight, const Vector &vecUp){    VPROF_BUDGET("CFlashlightEffect::UpdateLightNew", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING);    FlashlightState_t state;    // We will lock some of the flashlight params if player is on a ladder, to prevent oscillations due to the trace-rays    bool bPlayerOnLadder = (C_BasePlayer::GetLocalPlayer()->GetMoveType() == MOVETYPE_LADDER);    const float flEpsilon = 0.1f;			// Offset flashlight position along vecUp    const float flDistCutoff = 128.0f;    const float flDistDrag = 0.2;    CTraceFilterSkipPlayerAndViewModel traceFilter;    float flOffsetY = r_flashlightoffsety.GetFloat();    if (r_swingflashlight.GetBool())    {        // This projects the view direction backwards, attempting to raise the vertical        // offset of the flashlight, but only when the player is looking down.        Vector vecSwingLight = vecPos + vecForward * -12.0f;        if (vecSwingLight.z > vecPos.z)        {            flOffsetY += (vecSwingLight.z - vecPos.z);        }    }    Vector vOrigin = vecPos + flOffsetY * vecUp;    // Not on ladder...trace a hull    if (!bPlayerOnLadder)    {        trace_t pmOriginTrace;        UTIL_TraceHull(vecPos, vOrigin, Vector(-4, -4, -4), Vector(4, 4, 4), MASK_SOLID & ~(CONTENTS_HITBOX), &traceFilter, &pmOriginTrace);        if (pmOriginTrace.DidHit())        {            vOrigin = vecPos;        }    }    else // on ladder...skip the above hull trace    {        vOrigin = vecPos;    }    // Now do a trace along the flashlight direction to ensure there is nothing within range to pull back from    int iMask = MASK_OPAQUE_AND_NPCS;    iMask &= ~CONTENTS_HITBOX;    iMask |= CONTENTS_WINDOW;    Vector vTarget = vecPos + vecForward * r_flashlightfar.GetFloat();    // Work with these local copies of the basis for the rest of the function    Vector vDir = vTarget - vOrigin;    Vector vRight = vecRight;    Vector vUp = vecUp;    VectorNormalize(vDir);    VectorNormalize(vRight);    VectorNormalize(vUp);    // Orthonormalize the basis, since the flashlight texture projection will require this later...    vUp -= DotProduct(vDir, vUp) * vDir;    VectorNormalize(vUp);    vRight -= DotProduct(vDir, vRight) * vDir;    VectorNormalize(vRight);    vRight -= DotProduct(vUp, vRight) * vUp;    VectorNormalize(vRight);    AssertFloatEquals(DotProduct(vDir, vRight), 0.0f, 1e-3);    AssertFloatEquals(DotProduct(vDir, vUp), 0.0f, 1e-3);    AssertFloatEquals(DotProduct(vRight, vUp), 0.0f, 1e-3);    trace_t pmDirectionTrace;    UTIL_TraceHull(vOrigin, vTarget, Vector(-4, -4, -4), Vector(4, 4, 4), iMask, &traceFilter, &pmDirectionTrace);    if (r_flashlightvisualizetrace.GetBool() == true)    {        debugoverlay->AddBoxOverlay(pmDirectionTrace.endpos, Vector(-4, -4, -4), Vector(4, 4, 4), QAngle(0, 0, 0), 0, 0, 255, 16, 0);        debugoverlay->AddLineOverlay(vOrigin, pmDirectionTrace.endpos, 255, 0, 0, false, 0);    }    float flDist = (pmDirectionTrace.endpos - vOrigin).Length();    if (flDist < flDistCutoff)    {        // We have an intersection with our cutoff range        // Determine how far to pull back, then trace to see if we are clear        float flPullBackDist = bPlayerOnLadder ? r_flashlightladderdist.GetFloat() : flDistCutoff - flDist;	// Fixed pull-back distance if on ladder        m_flDistMod = Lerp(flDistDrag, m_flDistMod, flPullBackDist);        if (!bPlayerOnLadder)        {            trace_t pmBackTrace;            UTIL_TraceHull(vOrigin, vOrigin - vDir*(flPullBackDist - flEpsilon), Vector(-4, -4, -4), Vector(4, 4, 4), iMask, &traceFilter, &pmBackTrace);            if (pmBackTrace.DidHit())            {                // We have an intersection behind us as well, so limit our m_flDistMod                float flMaxDist = (pmBackTrace.endpos - vOrigin).Length() - flEpsilon;//.........这里部分代码省略.........
开发者ID:Yosam02,项目名称:game,代码行数:101,


示例13: CG_DamageFeedback

/*==============CG_DamageFeedback==============*/void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {	float		left, front, up;	float		kick;	int			health;	float		scale;	vec3_t		dir;	vec3_t		angles;	float		dist;	float		yaw, pitch;	//FIXME: Based on MOD, do different kinds of damage effects,	//		for example, Borg damage could progressively tint screen green and raise FOV?	// the lower on health you are, the greater the view kick will be	health = cg.snap->ps.stats[STAT_HEALTH];	if ( health < 40 ) {		scale = 1;	} else {		scale = 40.0 / health;	}	kick = damage * scale;	if (kick < 5)		kick = 5;	if (kick > 10)		kick = 10;	// if yaw and pitch are both 255, make the damage always centered (falling, etc)	if ( yawByte == 255 && pitchByte == 255 ) {		cg.damageX = 0;		cg.damageY = 0;		cg.v_dmg_roll = 0;		cg.v_dmg_pitch = -kick;	} else {		// positional		pitch = pitchByte / 255.0 * 360;		yaw = yawByte / 255.0 * 360;		angles[PITCH] = pitch;		angles[YAW] = yaw;		angles[ROLL] = 0;		AngleVectors( angles, dir, NULL, NULL );		VectorSubtract( vec3_origin, dir, dir );		front = DotProduct (dir, cg.refdef.viewaxis[0] );		left = DotProduct (dir, cg.refdef.viewaxis[1] );		up = DotProduct (dir, cg.refdef.viewaxis[2] );		dir[0] = front;		dir[1] = left;		dir[2] = 0;		dist = VectorLength( dir );		if ( dist < 0.1 ) {			dist = 0.1f;		}		cg.v_dmg_roll = kick * left;		cg.v_dmg_pitch = -kick * front;		if ( front <= 0.1 ) {			front = 0.1f;		}		cg.damageX = -left / front;		cg.damageY = up / dist;	}	// clamp the position	if ( cg.damageX > 1.0 ) {		cg.damageX = 1.0;	}	if ( cg.damageX < - 1.0 ) {		cg.damageX = -1.0;	}	if ( cg.damageY > 1.0 ) {		cg.damageY = 1.0;	}	if ( cg.damageY < - 1.0 ) {		cg.damageY = -1.0;	}	// don't let the screen flashes vary as much	if ( kick > 10 ) {		kick = 10;	}	cg.damageValue = kick;	cg.v_dmg_time = cg.time + DAMAGE_TIME;	cg.damageTime = cg.snap->serverTime;}
开发者ID:AlexXT,项目名称:OpenJK,代码行数:96,


示例14: R_MeshQueue_BeginScene

void R_MeshQueue_BeginScene(void){	mqt_count = 0;	mqt_viewplanedist = DotProduct(r_refdef.view.origin, r_refdef.view.forward);	mqt_viewmaxdist = 0;}
开发者ID:paulvortex,项目名称:DpOmnicide,代码行数:6,


示例15: AI_AddNode_Door

/** AI_AddNode_Door* Drop a node at each side of the door* and force them to link. Only typical* doors are covered.*/static int AI_AddNode_Door( edict_t *ent ){	edict_t	*other;	vec3_t mins, maxs;	vec3_t door_origin, movedir, moveangles;	vec3_t moveaxis[3];	vec3_t MOVEDIR_UP = { 0, 0, 1 };	float nodeOffset = NODE_DENSITY * 0.75f;	int i, j;	int dropped[4];	if( ent->flags & FL_TEAMSLAVE )		return NODE_INVALID; // only team master will drop the nodes	for( i = 0; i < 4; i++ )		dropped[i] = NODE_INVALID;	//make box formed by all team members boxes	VectorCopy( ent->r.absmin, mins );	VectorCopy( ent->r.absmax, maxs );	for( other = ent->teamchain; other; other = other->teamchain )	{		AddPointToBounds( other->r.absmin, mins, maxs );		AddPointToBounds( other->r.absmax, mins, maxs );	}	for( i = 0; i < 3; i++ )		door_origin[i] = ( maxs[i] + mins[i] ) * 0.5;	VectorSubtract( ent->moveinfo.end_origin, ent->moveinfo.start_origin, movedir );	VectorNormalizeFast( movedir );	VecToAngles( movedir, moveangles );	AnglesToAxis( moveangles, moveaxis );	//add nodes in "side" direction	nodes[nav.num_nodes].flags = 0;	VectorMA( door_origin, nodeOffset, moveaxis[1], nodes[nav.num_nodes].origin );#ifdef SHOW_JUMPAD_GUESS	AI_JumpadGuess_ShowPoint( nodes[nav.num_nodes].origin, PATH_AMMO_BOX_MODEL );#endif	if( AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, NULL ) )	{		nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, NULL );		dropped[0] = nav.num_nodes;		nav.num_nodes++;	}	nodes[nav.num_nodes].flags = 0;	VectorMA( door_origin, -nodeOffset, moveaxis[1], nodes[nav.num_nodes].origin );#ifdef SHOW_JUMPAD_GUESS	AI_JumpadGuess_ShowPoint( nodes[nav.num_nodes].origin, PATH_AMMO_BOX_MODEL );#endif	if( AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, NULL ) )	{		nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, NULL );		dropped[1] = nav.num_nodes;		nav.num_nodes++;	}	// if moving in the Y axis drop also in the other crossing direction and hope the	// bad ones are inhibited by a solid	if( DotProduct( MOVEDIR_UP, moveaxis[0] ) > 0.8 || DotProduct( MOVEDIR_UP, moveaxis[0] ) < -0.8 )	{		nodes[nav.num_nodes].flags = 0;		VectorMA( door_origin, nodeOffset, moveaxis[2], nodes[nav.num_nodes].origin );#ifdef SHOW_JUMPAD_GUESS		AI_JumpadGuess_ShowPoint( nodes[nav.num_nodes].origin, PATH_AMMO_BOX_MODEL );#endif		if( AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, NULL ) )		{			nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, NULL );			dropped[2] = nav.num_nodes;			nav.num_nodes++;		}		nodes[nav.num_nodes].flags = 0;		VectorMA( door_origin, -nodeOffset, moveaxis[2], nodes[nav.num_nodes].origin );#ifdef SHOW_JUMPAD_GUESS		AI_JumpadGuess_ShowPoint( nodes[nav.num_nodes].origin, PATH_AMMO_BOX_MODEL );#endif		if( AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, NULL ) )		{			nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, NULL );			dropped[3] = nav.num_nodes;			nav.num_nodes++;		}	}	// link those we dropped	for( i = 0; i < 4; i++ )	{//.........这里部分代码省略.........
开发者ID:Racenet,项目名称:racesow,代码行数:101,


示例16: RB_AddFlare

/*==================RB_AddFlareThis is called at surface tesselation time==================*/void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) {	int				i;	flare_t			*f, *oldest;	vec3_t			local;	float			d;	vec4_t			eye, clip, normalized, window;	backEnd.pc.c_flareAdds++;	// if the point is off the screen, don't bother adding it	// calculate screen coordinates and depth	R_TransformModelToClip( point, backEnd.or.modelMatrix, 		backEnd.viewParms.projectionMatrix, eye, clip );	// check to see if the point is completely off screen	for ( i = 0 ; i < 3 ; i++ ) {		if ( clip[i] >= clip[3] || clip[i] <= -clip[3] ) {			return;		}	}	R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window );	if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth		|| window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) {		return;	// shouldn't happen, since we check the clip[] above, except for FP rounding	}	// see if a flare with a matching surface, scene, and view exists	oldest = r_flareStructs;	for ( f = r_activeFlares ; f ; f = f->next ) {		if ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum			&& f->inPortal == backEnd.viewParms.isPortal ) {			break;		}	}	// allocate a new one	if (!f ) {		if ( !r_inactiveFlares ) {			// the list is completely full			return;		}		f = r_inactiveFlares;		r_inactiveFlares = r_inactiveFlares->next;		f->next = r_activeFlares;		r_activeFlares = f;		f->surface = surface;		f->frameSceneNum = backEnd.viewParms.frameSceneNum;		f->inPortal = backEnd.viewParms.isPortal;		f->addedFrame = -1;	}	if ( f->addedFrame != backEnd.viewParms.frameCount - 1 ) {		f->visible = qfalse;		f->fadeTime = backEnd.refdef.time - 2000;	}	f->addedFrame = backEnd.viewParms.frameCount;	f->fogNum = fogNum;	VectorCopy( color, f->color );	// fade the intensity of the flare down as the	// light surface turns away from the viewer	if ( normal ) {		VectorSubtract( backEnd.viewParms.or.origin, point, local );		VectorNormalizeFast( local );		d = DotProduct( local, normal );		VectorScale( f->color, d, f->color ); 	}	// save info needed to test	f->windowX = backEnd.viewParms.viewportX + window[0];	f->windowY = backEnd.viewParms.viewportY + window[1];	f->eyeZ = eye[2];}
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:86,


示例17: ClipSkyPolygon

/*================ClipSkyPolygon================*/static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) {	float	*norm;	float	*v;	qboolean	front, back;	float	d, e;	float	dists[MAX_CLIP_VERTS];	int		sides[MAX_CLIP_VERTS];	vec3_t	newv[2][MAX_CLIP_VERTS];	int		newc[2];	int		i, j;	if (nump > MAX_CLIP_VERTS-2)		Com_Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS");	if (stage == 6)	{	// fully clipped, so draw it		AddSkyPolygon (nump, vecs);		return;	}	front = back = qfalse;	norm = sky_clip[stage];	for (i=0, v = vecs ; i<nump ; i++, v+=3)	{		d = DotProduct (v, norm);		if (d > ON_EPSILON)		{			front = qtrue;			sides[i] = SIDE_FRONT;		}		else if (d < -ON_EPSILON)		{			back = qtrue;			sides[i] = SIDE_BACK;		}		else			sides[i] = SIDE_ON;		dists[i] = d;	}	if (!front || !back)	{	// not clipped		ClipSkyPolygon (nump, vecs, stage+1);		return;	}	// clip it	sides[i] = sides[0];	dists[i] = dists[0];	VectorCopy (vecs, (vecs+(i*3)) );	newc[0] = newc[1] = 0;	for (i=0, v = vecs ; i<nump ; i++, v+=3)	{		switch (sides[i])		{		case SIDE_FRONT:			VectorCopy (v, newv[0][newc[0]]);			newc[0]++;			break;		case SIDE_BACK:			VectorCopy (v, newv[1][newc[1]]);			newc[1]++;			break;		case SIDE_ON:			VectorCopy (v, newv[0][newc[0]]);			newc[0]++;			VectorCopy (v, newv[1][newc[1]]);			newc[1]++;			break;		}		if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])			continue;		d = dists[i] / (dists[i] - dists[i+1]);		for (j=0 ; j<3 ; j++)		{			e = v[j] + d*(v[j+3] - v[j]);			newv[0][newc[0]][j] = e;			newv[1][newc[1]][j] = e;		}		newc[0]++;		newc[1]++;	}	// continue	ClipSkyPolygon (newc[0], newv[0][0], stage+1);	ClipSkyPolygon (newc[1], newv[1][0], stage+1);}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:95,


示例18: Norm

float Light::Geometric(Vector n, Vector l, Vector v) {    Vector m;    float G;    if (Norm(l + v) == 0) {        G = 1.0f;        return G;    }    Vector h = (l + v) / Norm(l + v);    Vector n0 = (l * DotProduct(n, l)) + (v * DotProduct(n, v)) - (l * (DotProduct(v, l) * DotProduct(v, n))) -                (v * (DotProduct(v, l) * DotProduct(l, n)));    if (Norm(n0) != 0) {        m = n0 / Norm(n0);    } else {        m = h;    }    Vector hp = (m * (2 * DotProduct(m, h))) - h;    if ((DotProduct(v, hp) >= 0) || (DotProduct(m, v) >= DotProduct(m, l))) {        G = 1.0f;    } else if ((DotProduct(v, hp) < 0) && (DotProduct(l, hp) >= 0)) {        G = (2 * DotProduct(m, h) * DotProduct(m, v)) / DotProduct(h, v);    } else {        G = DotProduct(m, v) / DotProduct(m, l);    }    return G;}
开发者ID:stevenandrewcarter,项目名称:RayTracer,代码行数:25,


示例19: main

int main(void){    //assign X component    vec1[0] = 2.0;    //assign Y component    vec1[1] = 2.0;    //assign Z component    vec1[2] = 2.0;    vec2[0] = 5.0;    vec2[1] = 5.0;    vec2[2] = 5.0;    VectorAdd(vec1,vec2,vec3);    printf("Vector addition: ");    int i;    for(i = 0; i < 3; i++)    {        printf("%g ", vec3[i]);    }    VectorSubtract(vec1,vec2,vec3);    printf("/nVector subtraction: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec3[i]);    }    DotProduct(vec1,vec2,cheez);    printf("/nDot product: %g", cheez);    Scaling(vec1, 2);    printf("/nScaling by 2: ");    for(i = 0; i < sizeof(vec1)/sizeof(int); i++)    {        printf("%g ", vec1[i]);    }    VCopy(vec1, vec3);    printf("/nCopying vec1 to vec3: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec3[i]);    }    VClear(vec3);    printf("/nClearing vec3: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec3[i]);    }    Inverse(vec2);    printf("/nInverse of vec2: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec2[i]);    }    Cross(vec1, vec2, vec3);    printf("/nCross of vec1 and vec2: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec3[i]);    }    Magnitude(vec2);    printf("/nMagnitude of vec2: ");    printf("%g ", Magnitude(vec2));    Normalize(vec2);    printf("/nNormalize of vec2: ");    for(i = 0; i < sizeof(vec3)/sizeof(int); i++)    {        printf("%g ", vec2[i]);    }}
开发者ID:whiteim,项目名称:CS3545,代码行数:81,


示例20: DotProduct

float Light::Phong_Model(Vector v, Vector l, Vector n, float f) {    Vector r = (n * (2 * DotProduct(l, n))) - l;    float vr = DotProduct(v, r.Normalize());    return pow(vr, f);}
开发者ID:stevenandrewcarter,项目名称:RayTracer,代码行数:5,


示例21: R_RecursiveWorldNode

void R_RecursiveWorldNode (mnode_t *node, int clipflags) {	int i, c, side, *pindex;	vec3_t acceptpt, rejectpt;	mplane_t *plane;	msurface_t *surf, **mark;	mleaf_t *pleaf;	double d, dot;	if (node->contents == CONTENTS_SOLID)		return;		// solid	if (node->visframe != r_visframecount)		return;	// cull the clipping planes if not trivial accept	// FIXME: the compiler is doing a lousy job of optimizing here; it could be twice as fast in ASM	if (clipflags) {		for (i = 0; i < 4; i++) {			if (!(clipflags & (1<<i)) )				continue;	// don't need to clip against it			// generate accept and reject points			// FIXME: do with fast look-ups or integer tests based on the sign bit of the floating point values			pindex = pfrustum_indexes[i];			rejectpt[0] = (float)node->minmaxs[pindex[0]];			rejectpt[1] = (float)node->minmaxs[pindex[1]];			rejectpt[2] = (float)node->minmaxs[pindex[2]];			d = DotProduct (rejectpt, view_clipplanes[i].normal);			d -= view_clipplanes[i].dist;			if (d <= 0)				return;			acceptpt[0] = (float)node->minmaxs[pindex[3+0]];			acceptpt[1] = (float)node->minmaxs[pindex[3+1]];			acceptpt[2] = (float)node->minmaxs[pindex[3+2]];			d = DotProduct (acceptpt, view_clipplanes[i].normal);			d -= view_clipplanes[i].dist;			if (d >= 0)				clipflags &= ~(1<<i);	// node is entirely on screen		}	}		// if a leaf node, draw stuff	if (node->contents < 0) {		pleaf = (mleaf_t *)node;		mark = pleaf->firstmarksurface;		c = pleaf->nummarksurfaces;		if (c) {			do {				(*mark)->visframe = r_framecount;				mark++;			} while (--c);		}		// deal with model fragments in this leaf		if (pleaf->efrags)			R_StoreEfrags (&pleaf->efrags);		pleaf->key = r_currentkey;		r_currentkey++;		// all bmodels in a leaf share the same key	} else {		// node is just a decision point, so go down the apropriate sides		// find which side of the node we are on		plane = node->plane;		dot = PlaneDiff (modelorg, plane);		side = (dot < 0);		// recurse down the children, front side first		R_RecursiveWorldNode (node->children[side], clipflags);		// draw stuff		c = node->numsurfaces;		if (c) {			surf = cl.worldmodel->surfaces + node->firstsurface;			if (dot < -BACKFACE_EPSILON) {				do {					if ((surf->flags & SURF_PLANEBACK) && surf->visframe == r_framecount)						R_RenderFace (surf, clipflags);					surf++;				} while (--c);			} else if (dot > BACKFACE_EPSILON) {				do				{					if (!(surf->flags & SURF_PLANEBACK) && surf->visframe == r_framecount)						R_RenderFace (surf, clipflags);					surf++;				} while (--c);			}//.........这里部分代码省略.........
开发者ID:AAS,项目名称:ezquake-source,代码行数:101,


示例22: MakeScales

//.........这里部分代码省略.........						, transparency	#endif						))					{						continue;					}					useback = true;				}				else				{					continue;				}#else                continue;#endif            }            normal2 = getPlaneFromFaceNumber(patch2->faceNumber)->normal;            // calculate transferemnce            VectorSubtract(patch2->origin, origin, delta);#ifdef HLRAD_TRANSLUCENT			if (useback)			{				VectorSubtract (patch2->origin, backorigin, delta);			}#endif#ifdef HLRAD_ACCURATEBOUNCE			// move emitter back to its plane			VectorMA (delta, -PATCH_HUNT_OFFSET, normal2, delta);#endif            dist = VectorNormalize(delta);            dot1 = DotProduct(delta, normal1);#ifdef HLRAD_TRANSLUCENT			if (useback)			{				dot1 = DotProduct (delta, backnormal);			}#endif            dot2 = -DotProduct(delta, normal2);#ifdef HLRAD_ACCURATEBOUNCE#ifdef HLRAD_ACCURATEBOUNCE_ALTERNATEORIGIN			bool light_behind_surface = false;			if (dot1 <= NORMAL_EPSILON)			{				light_behind_surface = true;			}#else			if (dot1 <= NORMAL_EPSILON)			{				continue;			}#endif			if (dot2 * dist <= MINIMUM_PATCH_DISTANCE)			{				continue;			}#endif#ifdef HLRAD_DIVERSE_LIGHTING			if (lighting_diversify	#ifdef HLRAD_ACCURATEBOUNCE_ALTERNATEORIGIN				&& !light_behind_surface	#endif				)
开发者ID:emileb,项目名称:XashXT,代码行数:67,


示例23: CG_OffsetFirstPersonView

/*===============CG_OffsetFirstPersonView===============*/static void CG_OffsetFirstPersonView( void ){  float         *origin;  float         *angles;  float         bob;  float         ratio;  float         delta;  float         speed;  float         f;  vec3_t        predictedVelocity;  int           timeDelta;  float         bob2;  vec3_t        normal, baseOrigin;  playerState_t *ps = &cg.predictedPlayerState;  if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )  {    if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING )      VectorSet( normal, 0.0f, 0.0f, -1.0f );    else      VectorCopy( ps->grapplePoint, normal );  }  else    VectorSet( normal, 0.0f, 0.0f, 1.0f );  if( cg.snap->ps.pm_type == PM_INTERMISSION )    return;  origin = cg.refdef.vieworg;  angles = cg.refdefViewAngles;  VectorCopy( origin, baseOrigin );  // if dead, fix the angle and don't add any kick  if( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 )  {    angles[ ROLL ] = 40;    angles[ PITCH ] = -15;    angles[ YAW ] = cg.snap->ps.stats[ STAT_VIEWLOCK ];    origin[ 2 ] += cg.predictedPlayerState.viewheight;    return;  }  // add angles based on weapon kick  VectorAdd( angles, cg.kick_angles, angles );  // add angles based on damage kick  if( cg.damageTime )  {    ratio = cg.time - cg.damageTime;    if( ratio < DAMAGE_DEFLECT_TIME )    {      ratio /= DAMAGE_DEFLECT_TIME;      angles[ PITCH ] += ratio * cg.v_dmg_pitch;      angles[ ROLL ] += ratio * cg.v_dmg_roll;    }    else    {      ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;      if( ratio > 0 )      {        angles[ PITCH ] += ratio * cg.v_dmg_pitch;        angles[ ROLL ] += ratio * cg.v_dmg_roll;      }    }  }  // add pitch based on fall kick#if 0  ratio = ( cg.time - cg.landTime) / FALL_TIME;  if (ratio < 0)    ratio = 0;  angles[PITCH] += ratio * cg.fall_value;#endif  // add angles based on velocity  VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );  delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 0 ] );  angles[ PITCH ] += delta * cg_runpitch.value;  delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 1 ] );  angles[ ROLL ] -= delta * cg_runroll.value;  // add angles based on bob  // bob amount is class dependant  if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR )    bob2 = 0.0f;  else    bob2 = BG_FindBobForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] );//.........这里部分代码省略.........
开发者ID:ZdrytchX,项目名称:tremulous-derelict,代码行数:101,


示例24: CG_OffsetFirstPersonView

/*===============CG_OffsetFirstPersonView===============*/static void CG_OffsetFirstPersonView( void ) {	float           *origin;	float           *angles;	float bob;	float ratio;	float delta;	float speed;	float f;	vec3_t predictedVelocity;	int timeDelta;	if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {		return;	}	origin = cg.refdef.vieworg;	angles = cg.refdefViewAngles;	// if dead, fix the angle and don't add any kick	if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {		angles[ROLL] = 40;		angles[PITCH] = -15;		angles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];		origin[2] += cg.predictedPlayerState.viewheight;		return;	}	// add angles based on weapon kick	VectorAdd( angles, cg.kick_angles, angles );	// RF, add new weapon kick angles	CG_KickAngles();	VectorAdd( angles, cg.kickAngles, angles );	// RF, pitch is already added	//angles[0] -= cg.kickAngles[PITCH];	// add angles based on damage kick	if ( cg.damageTime ) {		ratio = cg.time - cg.damageTime;		if ( ratio < DAMAGE_DEFLECT_TIME ) {			ratio /= DAMAGE_DEFLECT_TIME;			angles[PITCH] += ratio * cg.v_dmg_pitch;			angles[ROLL] += ratio * cg.v_dmg_roll;		} else {			ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;			if ( ratio > 0 ) {				angles[PITCH] += ratio * cg.v_dmg_pitch;				angles[ROLL] += ratio * cg.v_dmg_roll;			}		}	}	// add pitch based on fall kick#if 0	ratio = ( cg.time - cg.landTime ) / FALL_TIME;	if ( ratio < 0 ) {		ratio = 0;	}	angles[PITCH] += ratio * cg.fall_value;#endif	// add angles based on velocity	VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );	delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[0] );	angles[PITCH] += delta * cg_runpitch.value;	delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[1] );	angles[ROLL] -= delta * cg_runroll.value;	// add angles based on bob	// make sure the bob is visible even at low speeds	speed = cg.xyspeed > 200 ? cg.xyspeed : 200;	delta = cg.bobfracsin * cg_bobpitch.value * speed;	if ( cg.predictedPlayerState.pm_flags & PMF_DUCKED ) {		delta *= 3;     // crouching	}	angles[PITCH] += delta;	delta = cg.bobfracsin * cg_bobroll.value * speed;	if ( cg.predictedPlayerState.pm_flags & PMF_DUCKED ) {		delta *= 3;     // crouching accentuates roll	}	if ( cg.bobcycle & 1 ) {		delta = -delta;	}	angles[ROLL] += delta;//===================================	// add view height	origin[2] += cg.predictedPlayerState.viewheight;//.........这里部分代码省略.........
开发者ID:ptitSeb,项目名称:RtCW-OpenPandora,代码行数:101,


示例25: CG_smoothWWTransitions

/*===============CG_smoothWWTransitions===============*/static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t out ){  vec3_t    surfNormal, rotAxis, temp;  vec3_t    refNormal     = { 0.0f, 0.0f,  1.0f };  vec3_t    ceilingNormal = { 0.0f, 0.0f, -1.0f };  int       i;  float     stLocal, sFraction, rotAngle;  float     smoothTime, timeMod;  qboolean  performed = qfalse;  vec3_t    inAxis[ 3 ], lastAxis[ 3 ], outAxis[ 3 ];  if( cg.snap->ps.pm_flags & PMF_FOLLOW )  {    VectorCopy( in, out );    return;  }  //set surfNormal  if( !( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) )    VectorCopy( ps->grapplePoint, surfNormal );  else    VectorCopy( ceilingNormal, surfNormal );  AnglesToAxis( in, inAxis );  //if we are moving from one surface to another smooth the transition  if( !VectorCompare( surfNormal, cg.lastNormal ) )  {    //if we moving from the ceiling to the floor special case    //( x product of colinear vectors is undefined)    if( VectorCompare( ceilingNormal, cg.lastNormal ) &&        VectorCompare( refNormal,     surfNormal ) )    {      AngleVectors( in, temp, NULL, NULL );      ProjectPointOnPlane( rotAxis, temp, refNormal );      VectorNormalize( rotAxis );      rotAngle = 180.0f;      timeMod = 1.5f;    }    else    {      AnglesToAxis( cg.lastVangles, lastAxis );      rotAngle = DotProduct( inAxis[ 0 ], lastAxis[ 0 ] ) +                 DotProduct( inAxis[ 1 ], lastAxis[ 1 ] ) +                 DotProduct( inAxis[ 2 ], lastAxis[ 2 ] );      rotAngle = RAD2DEG( acos( ( rotAngle - 1.0f ) / 2.0f ) );      CrossProduct( lastAxis[ 0 ], inAxis[ 0 ], temp );      VectorCopy( temp, rotAxis );      CrossProduct( lastAxis[ 1 ], inAxis[ 1 ], temp );      VectorAdd( rotAxis, temp, rotAxis );      CrossProduct( lastAxis[ 2 ], inAxis[ 2 ], temp );      VectorAdd( rotAxis, temp, rotAxis );      VectorNormalize( rotAxis );      timeMod = 1.0f;    }    //add the op    CG_addSmoothOp( rotAxis, rotAngle, timeMod );  }  //iterate through ops  for( i = MAXSMOOTHS - 1; i >= 0; i-- )  {    smoothTime = (int)( cg_wwSmoothTime.integer * cg.sList[ i ].timeMod );    //if this op has time remaining, perform it    if( cg.time < cg.sList[ i ].time + smoothTime )    {      stLocal = 1.0f - ( ( ( cg.sList[ i ].time + smoothTime ) - cg.time ) / smoothTime );      sFraction = -( cos( stLocal * M_PI ) + 1.0f ) / 2.0f;      RotatePointAroundVector( outAxis[ 0 ], cg.sList[ i ].rotAxis,        inAxis[ 0 ], sFraction * cg.sList[ i ].rotAngle );      RotatePointAroundVector( outAxis[ 1 ], cg.sList[ i ].rotAxis,        inAxis[ 1 ], sFraction * cg.sList[ i ].rotAngle );      RotatePointAroundVector( outAxis[ 2 ], cg.sList[ i ].rotAxis,        inAxis[ 2 ], sFraction * cg.sList[ i ].rotAngle );      AxisCopy( outAxis, inAxis );      performed = qtrue;    }  }  //if we performed any ops then return the smoothed angles  //otherwise simply return the in angles  if( performed )    AxisToAngles( outAxis, out );  else    VectorCopy( in, out );  //copy the current normal to the lastNormal//.........这里部分代码省略.........
开发者ID:ZdrytchX,项目名称:tremulous-derelict,代码行数:101,


示例26: DotProduct

/*static*/float CVector3f::DotProduct( const CVector3f &v1, const CVector3f &v2 ){	return DotProduct( v1.x, v1.y, v1.z, v2.x, v2.y, v2.z );}
开发者ID:jameskelly396,项目名称:HavokStarChaser,代码行数:5,


示例27: AnimateRiders

//.........这里部分代码省略.........				pVeh->m_ulFlags	|=  VEH_SABERINLEFTHAND;			}			WeaponPose = (pVeh->m_ulFlags&VEH_SABERINLEFTHAND)?(WPOSE_SABERLEFT):(WPOSE_SABERRIGHT);		}		 		if (Attacking && WeaponPose)		{// Attack!			iBlend	= 100; 			iFlags	= SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART;			if (Turbo)			{				Right = true;				Left = false;			}			// Auto Aiming			//===============================================			if (!Left && !Right)		// Allow player strafe keys to override			{#ifndef _JK2MP				if (pVeh->m_pPilot->enemy)				{					vec3_t	toEnemy;					float	toEnemyDistance;					vec3_t	actorRight;					float	actorRightDot;					VectorSubtract(pVeh->m_pPilot->currentOrigin, pVeh->m_pPilot->enemy->currentOrigin, toEnemy);					toEnemyDistance = VectorNormalize(toEnemy);					AngleVectors(pVeh->m_pParentEntity->currentAngles, 0, actorRight, 0);					actorRightDot = DotProduct(toEnemy, actorRight);	 				if (fabsf(actorRightDot)>0.5f || pilotPS->weapon==WP_SABER)					{						Left	= (actorRightDot>0.0f);						Right	= !Left;					}					else					{						Right = Left = false;					}				}				else#endif				if (pilotPS->weapon==WP_SABER && !Left && !Right)				{					Left = (WeaponPose==WPOSE_SABERLEFT);					Right	= !Left;				}			}			if (Left)			{// Attack Left				switch(WeaponPose)				{				case WPOSE_BLASTER:		Anim = BOTH_VT_ATL_G;		break;				case WPOSE_SABERLEFT:	Anim = BOTH_VT_ATL_S;		break;				case WPOSE_SABERRIGHT:	Anim = BOTH_VT_ATR_TO_L_S;	break;				default:				assert(0);				}			}			else if (Right)
开发者ID:Wookiee-,项目名称:openbase,代码行数:67,


示例28: modified

//.........这里部分代码省略.........			// actually covered some distance			VectorCopy( trace.endpos, ent->v.origin );			VectorCopy( ent->v.velocity, original_velocity );			numplanes = 0;		}		if( trace.fraction == 1.0f )			 break; // moved the entire distance		if( !trace.ent )			MsgDev( D_ERROR, "SV_FlyMove: trace.ent == NULL/n" );		if( trace.plane.normal[2] > 0.7f )		{			blocked |= 1; // floor         			if( trace.ent->v.solid == SOLID_BSP || trace.ent->v.solid == SOLID_SLIDEBOX ||			trace.ent->v.movetype == MOVETYPE_PUSHSTEP || (trace.ent->v.flags & FL_CLIENT))			{				ent->v.flags |= FL_ONGROUND;				ent->v.groundentity = trace.ent;			}		}		if( trace.plane.normal[2] == 0.0f )		{			blocked |= 2; // step			if( steptrace ) *steptrace = trace; // save for player extrafriction		}		// run the impact function		SV_Impact( ent, trace.ent, &trace );		// break if removed by the impact function		if( ent->free ) break;		time_left -= time_left * trace.fraction;		// clipped to another plane		if( numplanes >= MAX_CLIP_PLANES )		{			// this shouldn't really happen			VectorClear( ent->v.velocity );			break;		}		VectorCopy( trace.plane.normal, planes[numplanes] );		numplanes++;		// modify original_velocity so it parallels all of the clip planes		for( i = 0; i < numplanes; i++ )		{			SV_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0f );			for( j = 0; j < numplanes; j++ )			{				if( j != i )				{					if( DotProduct( new_velocity, planes[j] ) < 0.0f )						break; // not ok				}			}			if( j == numplanes )				break;		}		if( i != numplanes )		{			// go along this plane			VectorCopy( new_velocity, ent->v.velocity );		}		else		{			// go along the crease			if( numplanes != 2 )			{				VectorClear( ent->v.velocity );				break;			}			CrossProduct( planes[0], planes[1], dir );			d = DotProduct( dir, ent->v.velocity );			VectorScale( dir, d, ent->v.velocity );		}		// if current velocity is against the original velocity,		// stop dead to avoid tiny occilations in sloping corners		if( DotProduct( ent->v.velocity, primal_velocity ) <= 0.0f )		{			VectorClear( ent->v.velocity );			break;		}	}	if( allFraction == 0.0f )		VectorClear( ent->v.velocity );	return blocked;}
开发者ID:Fograin,项目名称:hl-subsmod-ex,代码行数:101,


示例29: AIFunc_DefaultStart

/*================AIFunc_WarriorZombieDefense================*/char *AIFunc_WarriorZombieDefense( cast_state_t *cs ) {	gentity_t *ent, *enemy;	vec3_t enemyDir, vec;	float dist;	ent = &g_entities[cs->entityNum];	if ( !( ent->flags & FL_DEFENSE_GUARD ) ) {		if ( cs->weaponFireTimes[cs->weaponNum] < level.time - 100 ) {			return AIFunc_DefaultStart( cs );		}		return NULL;	}	if ( ( cs->enemyNum < 0 ) || ( cs->dangerEntityValidTime >= level.time ) ) {		ent->flags &= ~FL_DEFENSE_GUARD;		ent->client->ps.torsoTimer = 0;		ent->client->ps.legsTimer = 0;		return NULL;	}	enemy = &g_entities[cs->enemyNum];	if ( cs->thinkFuncChangeTime < level.time - 1500 ) {		// if we cant see them		if ( !AICast_EntityVisible( cs, cs->enemyNum, qtrue ) ) {			ent->flags &= ~FL_DEFENSE_GUARD;			ent->client->ps.torsoTimer = 0;			ent->client->ps.legsTimer = 0;			return NULL;		}		// if our enemy isn't using a dangerous weapon		if ( enemy->client->ps.weapon < WP_LUGER || enemy->client->ps.weapon > WP_CLASS_SPECIAL ) {			ent->flags &= ~FL_DEFENSE_GUARD;			ent->client->ps.torsoTimer = 0;			ent->client->ps.legsTimer = 0;			return NULL;		}		// if our enemy isn't looking right at us, abort		VectorSubtract( ent->client->ps.origin, enemy->client->ps.origin, vec );		dist = VectorNormalize( vec );		if ( dist > 512 ) {			dist = 512;		}		AngleVectors( enemy->client->ps.viewangles, enemyDir, NULL, NULL );		if ( DotProduct( vec, enemyDir ) < ( 0.98 - 0.2 * ( dist / 512 ) ) ) {			ent->flags &= ~FL_DEFENSE_GUARD;			ent->client->ps.torsoTimer = 0;			ent->client->ps.legsTimer = 0;			return NULL;		}	}	cs->weaponFireTimes[cs->weaponNum] = level.time;	if ( !ent->client->ps.torsoTimer ) {		ent->flags &= ~FL_DEFENSE_GUARD;		ent->client->ps.torsoTimer = 0;		ent->client->ps.legsTimer = 0;		return NULL;	}	// face them	AICast_AimAtEnemy( cs );	// crouching position, use smaller bounding box	trap_EA_Crouch( cs->bs->client );	return NULL;}
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:76,



注:本文中的DotProduct函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ Double函数代码示例
C++ DotProd函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。