当前位置: 首页>>代码示例>>C++>>正文


C++ idVec3::ProjectOntoPlane方法代码示例

本文整理汇总了C++中idVec3::ProjectOntoPlane方法的典型用法代码示例。如果您正苦于以下问题:C++ idVec3::ProjectOntoPlane方法的具体用法?C++ idVec3::ProjectOntoPlane怎么用?C++ idVec3::ProjectOntoPlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idVec3的用法示例。


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

示例1: SlideMove

/*
=====================
idPhysics_Monster::SlideMove
=====================
*/
monsterMoveResult_t idPhysics_Monster::SlideMove(idVec3 &start, idVec3 &velocity, const idVec3 &delta)
{
	int i;
	trace_t tr;
	idVec3 move;

	blockingEntity = NULL;
	move = delta;

	for (i = 0; i < 3; i++) {
		gameLocal.clip.Translation(tr, start, start + move, clipModel, clipModel->GetAxis(), clipMask, self);

		start = tr.endpos;

		if (tr.fraction == 1.0f) {
			if (i > 0) {
				return MM_SLIDING;
			}

			return MM_OK;
		}

		if (tr.c.entityNum != ENTITYNUM_NONE) {
			blockingEntity = gameLocal.entities[ tr.c.entityNum ];
		}

		// clip the movement delta and velocity
		move.ProjectOntoPlane(tr.c.normal, OVERCLIP);
		velocity.ProjectOntoPlane(tr.c.normal, OVERCLIP);
	}

	return MM_BLOCKED;
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:38,代码来源:Physics_Monster.cpp

示例2: SlideMove

/*
================
rvPhysics_Particle::SlideMove
================
*/
bool rvPhysics_Particle::SlideMove( idVec3 &start, idVec3 &velocity, const idVec3 &delta ) {
	int		i;
	trace_t tr;
	idVec3	move;
	bool collide, rtnValue = false;

	move = delta;
	for( i = 0; i < 3; i++ ) { // be sure if you change this upper value in the for() to update the exit condition below!!!!!
		gameLocal.Translation( self, tr, start, start + move, clipModel, clipModel->GetAxis(), clipMask, self, extraPassEntity );

		start = tr.endpos;

		if ( tr.fraction == 1.0f ) {
			if ( i > 0 ) {
				return false;
			}
			return true;
		}
		
		bool hitTeleporter = false;
		
		// let the entity know about the collision
		collide = self->Collide( tr, current.velocity, hitTeleporter );
		
		idEntity* ent;
		ent = gameLocal.entities[tr.c.entityNum];
		assert ( ent );
		
		// If we hit water just clip the move for now and keep on going
		if ( ent->GetPhysics()->GetContents() & CONTENTS_WATER ) {
			// Make sure we dont collide with water again
			clipMask &= ~CONTENTS_WATER;
			
			current.inWater = true;
			
			// Allow the loop to go one more round to push us through the water
			i--;
						
			velocity *= 0.4f;
						
			move.ProjectOntoPlane( tr.c.normal, PRT_OVERCLIP );
			continue;
		// bounce the projectile
		} else if ( !current.inWater && allowBounce && bouncyness ) {
			if ( !hitTeleporter ) {
				float dot;
				move = tr.endpos;
				dot = DotProduct( velocity, tr.c.normal );
				velocity  = ( velocity - ( 2.0f * dot * tr.c.normal ) ) * bouncyness;
			}
			return true;
//RAVEN BEGIN
//jshepard: tr.c.material can (did) crash here if null
		} else if ( allowBounce && tr.c.material && (tr.c.material->GetSurfaceFlags ( ) & SURF_BOUNCE) ) {
//RAVEN END
			float dot;
			move = tr.endpos;
			dot = DotProduct( velocity, tr.c.normal );
			velocity  = ( velocity - ( 2.0f * dot * tr.c.normal ) );
			return true;
		}			
// RAVEN BEGIN
// dluetscher: removed redundant trace calls
		else {
			i = 4;
			rtnValue = true;
		}
// RAVEN END

		// clip the movement delta and velocity
		if( collide ) {
			move.ProjectOntoPlane( tr.c.normal, PRT_OVERCLIP );
			velocity.ProjectOntoPlane( tr.c.normal, PRT_OVERCLIP );
		}
	}

	return rtnValue;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:83,代码来源:Physics_Particle.cpp


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