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


C++ GetPhysics函数代码示例

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


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

示例1: GetEyePosition

bool idActor::CheckFOV( const noVec3 &pos ) const
{
	if ( fovDot == 1.0f ) {
		return true;
	}

	float	dot;
	noVec3	delta;

	delta = pos - GetEyePosition();

	// get our gravity normal
	const noVec3 &gravityDir = GetPhysics()->GetGravityNormal();

	// infinite vertical vision, so project it onto our orientation plane
	delta -= gravityDir * ( gravityDir * delta );

	delta.Normalize();
	dot = viewAxis[ 0 ] * delta;

	return ( dot >= fovDot );
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:22,代码来源:MD5Actor.cpp

示例2: GetPhysics

/*
================
idAF::SetConstraintPosition

  Only moves constraints that bind the entity to another entity.
================
*/
void idAF::SetConstraintPosition(const char *name, const idVec3 &pos)
{
	idAFConstraint *constraint;

	constraint = GetPhysics()->GetConstraint(name);

	if (!constraint) {
		gameLocal.Warning("can't find a constraint with the name '%s'", name);
		return;
	}

	if (constraint->GetBody2() != NULL) {
		gameLocal.Warning("constraint '%s' does not bind to another entity", name);
		return;
	}

	switch (constraint->GetType()) {
		case CONSTRAINT_BALLANDSOCKETJOINT: {
			idAFConstraint_BallAndSocketJoint *bs = static_cast<idAFConstraint_BallAndSocketJoint *>(constraint);
			bs->Translate(pos - bs->GetAnchor());
			break;
		}
		case CONSTRAINT_UNIVERSALJOINT: {
			idAFConstraint_UniversalJoint *uj = static_cast<idAFConstraint_UniversalJoint *>(constraint);
			uj->Translate(pos - uj->GetAnchor());
			break;
		}
		case CONSTRAINT_HINGE: {
			idAFConstraint_Hinge *hinge = static_cast<idAFConstraint_Hinge *>(constraint);
			hinge->Translate(pos - hinge->GetAnchor());
			break;
		}
		default: {
			gameLocal.Warning("cannot set the constraint position for '%s'", name);
			break;
		}
	}
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:45,代码来源:AF.cpp

示例3: GetPhysics

bool rvMonsterStroggHover::MarkerPosValid ( void )
{
	//debouncer ftw
	if( markerCheckTime > gameLocal.GetTime() )	{
		return true;
	}

	markerCheckTime = gameLocal.GetTime() + 500 + (gameLocal.random.RandomFloat() * 500);

	trace_t trace;
	gameLocal.TracePoint( this, trace, marker.GetEntity()->GetPhysics()->GetOrigin(), marker.GetEntity()->GetPhysics()->GetOrigin(), GetPhysics()->GetClipMask(), NULL );
	if ( !(trace.c.contents&GetPhysics()->GetClipMask()) )
	{//not in solid
		gameLocal.TracePoint( this, trace, marker.GetEntity()->GetPhysics()->GetOrigin(), GetEnemy()->GetEyePosition(), MASK_SHOT_BOUNDINGBOX, GetEnemy() );
		idActor* enemyAct = NULL;
		rvVehicle* enemyVeh = NULL;
		if ( GetEnemy()->IsType( rvVehicle::GetClassType() ) ) {
			enemyVeh = static_cast<rvVehicle*>(GetEnemy());
		} else if ( GetEnemy()->IsType( idActor::GetClassType() ) ) {
			enemyAct = static_cast<idActor*>(GetEnemy());
		}
		idEntity* hitEnt = gameLocal.entities[trace.c.entityNum];
		idActor* hitAct = NULL;
		if ( hitEnt && hitEnt->IsType( idActor::GetClassType() ) ) {
			hitAct = static_cast<idActor*>(hitEnt);
		}
		if ( trace.fraction >= 1.0f 
			|| (enemyAct && enemyAct->IsInVehicle() && enemyAct->GetVehicleController().GetVehicle() == gameLocal.entities[trace.c.entityNum])
			|| (enemyVeh && hitAct && hitAct->IsInVehicle() && hitAct->GetVehicleController().GetVehicle() == enemyVeh) )
		{//have a clear LOS to enemy
			if ( PointReachableAreaNum( marker.GetEntity()->GetPhysics()->GetOrigin() ) )
			{//valid AAS there...
				return true;
			}
		}
	}
	return false;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:38,代码来源:Monster_StroggHover.cpp

示例4: GetPhysics

/*
================
rvMonsterConvoyGround::OnDeath
================
*/
void rvMonsterConvoyGround::OnDeath	( void ) {
	idVec3 fxOrg;
	idVec3 up;
	idMat3 fxAxis;

	//center it
	fxOrg = GetPhysics()->GetCenterMass();

	//point it up
	up.Set( 0, 0, 1 );
	fxAxis = up.ToMat3();

	//if we can play it at the joint, do that
	jointHandle_t axisJoint = animator.GetJointHandle ( "axis" );
	if ( axisJoint != INVALID_JOINT ) {
		idMat3 junk;
		animator.GetJointLocalTransform( axisJoint, gameLocal.GetTime(), fxOrg, junk );
		fxOrg = renderEntity.origin + (fxOrg*renderEntity.axis);
	}

	gameLocal.PlayEffect ( spawnArgs, "fx_death", fxOrg, fxAxis );
	idAI::OnDeath ( );
}
开发者ID:AliKalkandelen,项目名称:quake4,代码行数:28,代码来源:Monster_ConvoyGround.cpp

示例5: GetPhysics

int CVehicleMovementAerodynamic::AddBox(Vec3 *_pvPos,Vec3 *_pvSize,float _fMass,int _iID/*=-1*/)
{
  IPhysicalEntity* pPhysics = GetPhysics();
	IGeomManager *pGeomManager = gEnv->pPhysicalWorld->GetGeomManager();

	primitives::box Box;
	Box.Basis.SetIdentity();
	Box.center.Set(0.0f,0.0f,0.0f);
	Box.size = (*_pvSize) / 2.0f;
	Box.bOriented = 0;
	IGeometry *pGeometry = pGeomManager->CreatePrimitive(primitives::box::type,&Box);
	phys_geometry *pPhysGeometry = pGeomManager->RegisterGeometry(pGeometry);
	pGeometry->Release();

	pe_geomparams partpos;
	partpos.pos = *_pvPos;
	partpos.mass = _fMass;
	int id = pPhysics->AddGeometry(pPhysGeometry,&partpos,_iID);

	pGeomManager->UnregisterGeometry(pPhysGeometry);

  return id;
}
开发者ID:RenEvo,项目名称:dead6,代码行数:23,代码来源:VehicleMovementAerodynamic.cpp

示例6: at

/*
================
idTrigger_EntityName::Spawn
================
*/
void idTrigger_EntityName::Spawn( void ) {
	spawnArgs.GetFloat( "wait", "0.5", wait );
	spawnArgs.GetFloat( "random", "0", random );
	spawnArgs.GetFloat( "delay", "0", delay );
	spawnArgs.GetFloat( "random_delay", "0", random_delay );
	if( random && ( random >= wait ) && ( wait >= 0 ) ) {
		random = wait - 1;
		gameLocal.Warning( "idTrigger_EntityName '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) );
	}
	if( random_delay && ( random_delay >= delay ) && ( delay >= 0 ) ) {
		random_delay = delay - 1;
		gameLocal.Warning( "idTrigger_EntityName '%s' at (%s) has random_delay >= delay", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) );
	}
	spawnArgs.GetBool( "triggerFirst", "0", triggerFirst );
	entityName = spawnArgs.GetString( "entityname" );
	if( !entityName.Length() ) {
		gameLocal.Error( "idTrigger_EntityName '%s' at (%s) doesn't have 'entityname' key specified", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) );
	}
	nextTriggerTime = 0;
	if( !spawnArgs.GetBool( "noTouch" ) ) {
		GetPhysics()->SetContents( CONTENTS_TRIGGER );
	}
}
开发者ID:nbohr1more,项目名称:Revelation,代码行数:28,代码来源:Trigger.cpp

示例7: ReadBindFromSnapshot

void hhProxDoor::ReadFromSnapshot( const idBitMsgDelta &msg ) {
	ReadBindFromSnapshot(msg);
	GetPhysics()->ReadFromSnapshot(msg);

	int num = msg.ReadBits(8);
	doorPieces.SetNum(num);
	for (int i = 0; i < num; i++) {
		int spawnId = msg.ReadBits(32);
		if (!spawnId) {
			doorPieces[i] = NULL;
		}
		else {
			doorPieces[i].SetSpawnId(spawnId);
		}
	}

	EProxState newProxState = (EProxState)msg.ReadBits(8);
	if (proxState != newProxState) {
		SetDoorState(newProxState);
	}

	lastAmount = msg.ReadFloat();

	bool closed = !!msg.ReadBits(1);
	if (aas_area_closed != closed) {
		SetAASAreaState(closed);
	}

	/*
	EPDoorSound newSndState = (EPDoorSound)msg.ReadBits(8);
	if (newSndState != doorSndState) {
		UpdateSoundState(newSndState);
	}
	*/

	hasNetData = true;
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:37,代码来源:game_proxdoor.cpp

示例8: SetSoundVolume

/*
=================
idMoveable::Collide
=================
*/
bool idMoveable::Collide( const trace_t &collision, const idVec3 &velocity ) {
	float v, f;
	idVec3 dir;
	idEntity *ent;

	//gameLocal.Printf("collision\n");

	v = -( velocity * collision.c.normal );
	if ( v > BOUNCE_SOUND_MIN_VELOCITY && gameLocal.time > nextSoundTime ) {
		f = v > BOUNCE_SOUND_MAX_VELOCITY ? 1.0f : idMath::Sqrt( v - BOUNCE_SOUND_MIN_VELOCITY ) * ( 1.0f / idMath::Sqrt( BOUNCE_SOUND_MAX_VELOCITY - BOUNCE_SOUND_MIN_VELOCITY ) );
		if ( StartSound( "snd_bounce", SND_CHANNEL_BODY, 0, false, NULL ) ) {
			// don't set the volume unless there is a bounce sound as it overrides the entire channel
			// which causes footsteps on ai's to not honor their shader parms
			SetSoundVolume( f );
		}
		nextSoundTime = gameLocal.time + 500;
	}
	

	if ( canDamage && damage.Length() && gameLocal.time > nextDamageTime ) {
		ent = gameLocal.entities[ collision.c.entityNum ];
		if ( ent && v > minDamageVelocity ) {
			f = v > maxDamageVelocity ? 1.0f : idMath::Sqrt( v - minDamageVelocity ) * ( 1.0f / idMath::Sqrt( maxDamageVelocity - minDamageVelocity ) );
			dir = velocity;
			dir.NormalizeFast();
			ent->Damage( this, GetPhysics()->GetClipModel()->GetOwner(), dir, damage, f, INVALID_JOINT );
			nextDamageTime = gameLocal.time + 1000;
		}
	}

	if ( fxCollide.Length() && gameLocal.time > nextCollideFxTime ) {
		idEntityFx::StartFx( fxCollide, &collision.c.point, NULL, this, false );
		nextCollideFxTime = gameLocal.time + 3500;
	}

	return false;
}
开发者ID:alepulver,项目名称:dhewm3,代码行数:42,代码来源:Moveable.cpp

示例9: GetPhysics

/*
=================
idEntityFx::ReadFromSnapshot
=================
*/
void idEntityFx::ReadFromSnapshot( const idBitMsgDelta &msg ) {
	int fx_index, start_time, max_lapse;

	GetPhysics()->ReadFromSnapshot( msg );
	ReadBindFromSnapshot( msg );
	fx_index = gameLocal.ClientRemapDecl( DECL_FX, msg.ReadLong() );
	start_time = msg.ReadLong();

	if ( fx_index != -1 && start_time > 0 && !fxEffect && started < 0 ) {
		spawnArgs.GetInt( "effect_lapse", "1000", max_lapse );
		if ( gameLocal.time - start_time > max_lapse ) {
			// too late, skip the effect completely
			started = 0;
			return;
		}
		const idDeclFX *fx = static_cast<const idDeclFX *>( declManager->DeclByIndex( DECL_FX, fx_index ) );
		if ( !fx ) {
			gameLocal.Error( "FX at index %d not found", fx_index );
		}
		fxEffect = fx;
		Setup( fx->GetName() );
		Start( start_time );
	}
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:29,代码来源:Fx.cpp

示例10: GetPhysics

/*
================
idTrigger_Hurt::Event_Touch
================
*/
void idTrigger_Hurt::Event_Touch( idEntity *other, trace_t *trace )
{
	const char *damage;
	
	if( on && other && gameLocal.time >= nextTime )
	{
#ifdef _D3XP
		bool playerOnly = spawnArgs.GetBool( "playerOnly" );
		if( playerOnly )
		{
			if( !other->IsType( idPlayer::Type ) )
			{
				return;
			}
		}
#endif
		damage = spawnArgs.GetString( "def_damage", "damage_painTrigger" );
		
#ifdef _D3XP
		idVec3 dir = vec3_origin;
		if( spawnArgs.GetBool( "kick_from_center", "0" ) )
		{
			dir = other->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();
			dir.Normalize();
		}
		other->Damage( NULL, NULL, dir, damage, 1.0f, INVALID_JOINT );
#else
		other->Damage( NULL, NULL, vec3_origin, damage, 1.0f, INVALID_JOINT );
#endif
		
		ActivateTargets( other );
		CallScript();
		
		nextTime = gameLocal.time + SEC2MS( delay );
	}
}
开发者ID:revelator,项目名称:MHDoom,代码行数:41,代码来源:Trigger.cpp

示例11: while

/*
================
rvEffect::Event_LookAtTarget

Reorients the effect entity towards its target and sets the end origin as well
================
*/
void rvEffect::Event_LookAtTarget ( void ) {
    const idKeyValue	*kv;
    idVec3				dir;

    if ( !effect || !clientEffect ) {
        return;
    }

    kv = spawnArgs.MatchPrefix( "target", NULL );
    while( kv ) {
        idEntity *ent = gameLocal.FindEntity( kv->GetValue() );
        if( ent ) {
            if( !idStr::Icmp( ent->GetEntityDefName(), "target_null" ) ) {
                dir = ent->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();
                dir.Normalize();

                clientEffect->SetEndOrigin ( ent->GetPhysics()->GetOrigin() );
                clientEffect->SetAxis ( dir.ToMat3( ) );
                return;
            }
        }
        kv = spawnArgs.MatchPrefix( "target", kv );
    }
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:31,代码来源:Effect.cpp

示例12: GetPhysics

/*
================
idTrigger_Multi::CheckFacing
================
*/
bool idTrigger_Multi::CheckFacing( idEntity *activator ) {
    if ( spawnArgs.GetBool( "facing" ) ) {
        if ( !activator->IsType( idPlayer::GetClassType() ) ) {
            return true;
        }
        idPlayer *player = static_cast< idPlayer* >( activator );

        // Unfortunately, the angle key rotates the trigger entity also.  So I've added
        //	an angleFacing key which is used instead when present, otherwise the code defaults
        //	to the behaviour present prior to this change
        idVec3 tFacing = GetPhysics()->GetAxis()[0];
        if ( spawnArgs.FindKey( "angleFacing" )) {
            idAngles angs(0,spawnArgs.GetFloat( "angleFacing", "0" ),0);
            tFacing = angs.ToForward();
        }
        float dot = player->viewAngles.ToForward() * tFacing;

        float angle = RAD2DEG( idMath::ACos( dot ) );
        if ( angle  > spawnArgs.GetFloat( "angleLimit", "30" ) ) {
            return false;
        }
    }
    return true;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:29,代码来源:Trigger.cpp

示例13: PostEventMS

/*
================
rvEffect::Spawn
================
*/
void rvEffect::Spawn( void ) {
    const char* fx;
    if ( !spawnArgs.GetString ( "fx", "", &fx ) || !*fx ) {
        if ( !( gameLocal.editors & EDITOR_FX ) ) {
            gameLocal.Warning ( "no effect file specified on effect entity '%s'", name.c_str() );
            PostEventMS ( &EV_Remove, 0 );
            return;
        }
    } else {
        effect = ( const idDecl * )declManager->FindEffect( spawnArgs.GetString ( "fx" ) );
        if( effect->IsImplicit() ) {
            common->Warning( "Unknown effect \'%s\' on entity \'%s\'", spawnArgs.GetString ( "fx" ), GetName() );
        }
    }

    spawnArgs.GetVector ( "endOrigin", "0 0 0", endOrigin );

    spawnArgs.GetBool ( "loop", "0", loop );

    // If look at target is set the effect will continually update itself to look at its target
    spawnArgs.GetBool( "lookAtTarget", "0", lookAtTarget );

    renderEntity.shaderParms[SHADERPARM_ALPHA] = spawnArgs.GetFloat ( "_alpha", "1" );
    renderEntity.shaderParms[SHADERPARM_BRIGHTNESS] = spawnArgs.GetFloat ( "_brightness", "1" );

    if( spawnArgs.GetBool( "start_on", loop ? "1" : "0" ) ) {
        ProcessEvent( &EV_Activate, this );
    }
#if 0
    // If anyone ever gets around to a flood fill from the origin rather than the over generous PushVolumeIntoTree bounds,
    // this warning will become useful. Until then, it's a bogus warning.
    if( gameRenderWorld->PointInArea( GetPhysics()->GetOrigin() ) < 0 ) {
        common->Warning( "Effect \'%s\' out of world", name.c_str() );
    }
#endif
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:41,代码来源:Effect.cpp

示例14: color

/*
================
idSecurityCamera::DrawFov
================
*/
void idSecurityCamera::DrawFov()
{
	int i;
	float radius, a, s, c, halfRadius;
	idVec3 right, up;
	idVec4 color( 1, 0, 0, 1 ), color2( 0, 0, 1, 1 );
	idVec3 lastPoint, point, lastHalfPoint, halfPoint, center;
	
	idVec3 dir = GetAxis();
	dir.NormalVectors( right, up );
	
	radius = tan( scanFov * idMath::PI / 360.0f );
	halfRadius = radius * 0.5f;
	lastPoint = dir + up * radius;
	lastPoint.Normalize();
	lastPoint = GetPhysics()->GetOrigin() + lastPoint * scanDist;
	lastHalfPoint = dir + up * halfRadius;
	lastHalfPoint.Normalize();
	lastHalfPoint = GetPhysics()->GetOrigin() + lastHalfPoint * scanDist;
	center = GetPhysics()->GetOrigin() + dir * scanDist;
	for( i = 1; i < 12; i++ )
	{
		a = idMath::TWO_PI * i / 12.0f;
		idMath::SinCos( a, s, c );
		point = dir + right * s * radius + up * c * radius;
		point.Normalize();
		point = GetPhysics()->GetOrigin() + point * scanDist;
		gameRenderWorld->DebugLine( color, lastPoint, point );
		gameRenderWorld->DebugLine( color, GetPhysics()->GetOrigin(), point );
		lastPoint = point;
		
		halfPoint = dir + right * s * halfRadius + up * c * halfRadius;
		halfPoint.Normalize();
		halfPoint = GetPhysics()->GetOrigin() + halfPoint * scanDist;
		gameRenderWorld->DebugLine( color2, point, halfPoint );
		gameRenderWorld->DebugLine( color2, lastHalfPoint, halfPoint );
		lastHalfPoint = halfPoint;
		
		gameRenderWorld->DebugLine( color2, halfPoint, center );
	}
}
开发者ID:ChristophHaag,项目名称:RBDOOM-3-BFG,代码行数:46,代码来源:SecurityCamera.cpp

示例15: GetPhysics

/*
================
idLight::GetPhysicsToSoundTransform
================
*/
bool idLight::GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis ) {
	origin = localLightOrigin + renderLight.lightCenter;
	axis = localLightAxis * GetPhysics()->GetAxis();
	return true;
}
开发者ID:alepulver,项目名称:dhewm3,代码行数:10,代码来源:Light.cpp


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