• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetPhysics函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetBindMaster

/*
================
idTrigger_Touch::TouchEntities
================
*/
void idTrigger_Touch::TouchEntities( void ) {
    int numClipModels, i;
    idBounds bounds;
    idClipModel *cm, *clipModelList[ MAX_GENTITIES ];

// RAVEN BEGIN
// abahr: now scriptFunction list
    if ( clipModel == NULL || !scriptFunctions.Num() ) {
// RAVEN END
        return;
    }

    bounds.FromTransformedBounds( clipModel->GetBounds(), GetBindMaster()!=NULL?GetPhysics()->GetOrigin():clipModel->GetOrigin(), GetBindMaster()!=NULL?GetPhysics()->GetAxis():clipModel->GetAxis() );
// RAVEN BEGIN
// MCG: filterTeam
    if ( filterTeam != -1 )
    {
        idActor* actor;
        // Iterate through the filter team
        for( actor = aiManager.GetAllyTeam ( (aiTeam_t)filterTeam ); actor; actor = actor->teamNode.Next() ) {
            // Skip hidden actors and actors that can't be targeted
            if( actor->fl.notarget || actor->fl.isDormant || ( actor->IsHidden ( ) && !actor->IsInVehicle() ) ) {
                continue;
            }
            if ( !bounds.IntersectsBounds ( actor->GetPhysics()->GetAbsBounds ( ) ) ) {
                continue;
            }
            cm = actor->GetPhysics()->GetClipModel();
            if ( !cm || !cm->IsTraceModel() ) {
                continue;
            }
            if ( !gameLocal.ContentsModel( this, cm->GetOrigin(), cm, cm->GetAxis(), -1,
                                           clipModel->GetCollisionModel(), GetBindMaster()!=NULL?GetPhysics()->GetOrigin():clipModel->GetOrigin(), GetBindMaster()!=NULL?GetPhysics()->GetAxis():clipModel->GetAxis() ) ) {
                continue;
            }
            ActivateTargets( (idEntity*)actor );

            CallScript( (idEntity*)actor );
        }
        return;
    }
// ddynerman: multiple clip worlds
    numClipModels = gameLocal.ClipModelsTouchingBounds( this, bounds, -1, clipModelList, MAX_GENTITIES );
// RAVEN END

    for ( i = 0; i < numClipModels; i++ ) {
        cm = clipModelList[ i ];

        if ( !cm->IsTraceModel() ) {
            continue;
        }

        idEntity *entity = cm->GetEntity();

        if ( !entity ) {
            continue;
        }

// RAVEN BEGIN
// ddynerman: multiple clip worlds
        if ( !gameLocal.ContentsModel( this, cm->GetOrigin(), cm, cm->GetAxis(), -1,
                                       clipModel->GetCollisionModel(), clipModel->GetOrigin(), clipModel->GetAxis() ) ) {
// RAVEN END
            continue;
        }

        ActivateTargets( entity );

// RAVEN BEGIN
// abahr: changed to be compatible with new script function utility
        CallScript( entity );
// RAVEN END
    }
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:79,代码来源:Trigger.cpp


示例17: PostEventSec

/*
================
idExplodingBarrel::Killed
================
*/
void idExplodingBarrel::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) {

	if ( IsHidden() || state == EXPLODING || state == BURNING ) {
		return;
	}

	float f = spawnArgs.GetFloat( "burn" );
	if ( f > 0.0f && state == NORMAL ) {
		state = BURNING;
		PostEventSec( &EV_Explode, f );
		StartSound( "snd_burn", SND_CHANNEL_ANY, 0, false, NULL );
		AddParticles( spawnArgs.GetString ( "model_burn", "" ), true );
		return;
	} else {
		state = EXPLODING;
		if ( gameLocal.isServer ) {
			idBitMsg	msg;
			byte		msgBuf[MAX_EVENT_PARAM_SIZE];

			msg.Init( msgBuf, sizeof( msgBuf ) );
			msg.WriteLong( gameLocal.time );
			ServerSendEvent( EVENT_EXPLODE, &msg, false, -1 );
		}
	}

	// do this before applying radius damage so the ent can trace to any damagable ents nearby
	Hide();
	physicsObj.SetContents( 0 );

	const char *splash = spawnArgs.GetString( "def_splash_damage", "damage_explosion" );
	if ( splash && *splash ) {
		gameLocal.RadiusDamage( GetPhysics()->GetOrigin(), this, attacker, this, this, splash );
	}

	ExplodingEffects( );

	//FIXME: need to precache all the debris stuff here and in the projectiles
	const idKeyValue *kv = spawnArgs.MatchPrefix( "def_debris" );
	// bool first = true;
	while ( kv ) {
		const idDict *debris_args = gameLocal.FindEntityDefDict( kv->GetValue(), false );
		if ( debris_args ) {
			idEntity *ent;
			idVec3 dir;
			idDebris *debris;
			//if ( first ) {
				dir = physicsObj.GetAxis()[1];
			//	first = false;
			//} else {
				dir.x += gameLocal.random.CRandomFloat() * 4.0f;
				dir.y += gameLocal.random.CRandomFloat() * 4.0f;
				//dir.z = gameLocal.random.RandomFloat() * 8.0f;
			//}
			dir.Normalize();

			gameLocal.SpawnEntityDef( *debris_args, &ent, false );
			if ( !ent || !ent->IsType( idDebris::Type ) ) {
				gameLocal.Error( "'projectile_debris' is not an idDebris" );
			}

			debris = static_cast<idDebris *>(ent);
			debris->Create( this, physicsObj.GetOrigin(), dir.ToMat3() );
			debris->Launch();
			debris->GetRenderEntity()->shaderParms[ SHADERPARM_TIME_OF_DEATH ] = ( gameLocal.time + 1500 ) * 0.001f;
			debris->UpdateVisuals();

		}
		kv = spawnArgs.MatchPrefix( "def_debris", kv );
	}

	physicsObj.PutToRest();
	CancelEvents( &EV_Explode );
	CancelEvents( &EV_Activate );

	f = spawnArgs.GetFloat( "respawn" );
	if ( f > 0.0f ) {
		PostEventSec( &EV_Respawn, f );
	} else {
		PostEventMS( &EV_Remove, 5000 );
	}

	if ( spawnArgs.GetBool( "triggerTargets" ) ) {
		ActivateTargets( this );
	}
}
开发者ID:alepulver,项目名称:dhewm3,代码行数:90,代码来源:Moveable.cpp


示例18: at

/*
================
idTrigger_Timer::Spawn

Repeatedly fires its targets.
Can be turned on or off by using.
================
*/
void idTrigger_Timer::Spawn( void ) {
    spawnArgs.GetFloat( "random", "1", random );
    spawnArgs.GetFloat( "wait", "1", wait );
    spawnArgs.GetBool( "start_on", "0", on );
    spawnArgs.GetFloat( "delay", "0", delay );
    onName = spawnArgs.GetString( "onName" );
    offName = spawnArgs.GetString( "offName" );

    if ( random >= wait && wait >= 0 ) {
        random = wait - 0.001;
        gameLocal.Warning( "idTrigger_Timer '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString(0) );
    }

    if ( on ) {
        PostEventSec( &EV_Timer, delay );
    }
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:25,代码来源:Trigger.cpp


示例19: FUNCTION_PROFILER

//////////////////////////////////////////////////////////////////////////
// NOTE: This function must be thread-safe. Before adding stuff contact MarcoC.
void CVehicleMovementHelicopter::ProcessMovement(const float deltaTime)
{
	FUNCTION_PROFILER( GetISystem(), PROFILE_GAME );

	IPhysicalEntity* pPhysics = GetPhysics();
	assert(pPhysics);
	
	if (m_arcade.m_handling.maxSpeedForward>0.f) // Use the new handling code
	{
		CryAutoCriticalSection lk(m_lock);

		if (!m_isEnginePowered)
			return;

		CVehicleMovementBase::ProcessMovement(deltaTime);
		SVehiclePhysicsStatus* physStatus = &m_physStatus[k_physicsThread];

		if(m_bApplyNoiseAsVelocity)
		{
			physStatus->v -= m_pNoise->m_posDifference;
			physStatus->w -= m_pNoise->m_angDifference;

			m_pNoise->Update(deltaTime);
		}

	
		///////////////////////////////////////////////////////////////
		// Pass on the movement request to the active physics handler
		// NB: m_physStatus is update by this call
		SVehiclePhysicsHelicopterProcessParams params;
		params.pPhysics = pPhysics;
		params.pPhysStatus = physStatus;
		params.pInputAction = &m_inputAction;
		params.dt = deltaTime;
		params.haveDriver = (m_actorId!=0)||m_remotePilot;
		params.isAI = m_movementAction.isAI;
		params.aiRequiredVel = m_CurrentVel;
		
		m_arcade.ProcessMovement(params);
		
		// Network error adjustment
		m_netPosAdjust *= max(0.f, 1.f-deltaTime*k_netErrorPosScale);
		physStatus->v += m_netPosAdjust * k_netErrorPosScale;

		if(m_bApplyNoiseAsVelocity)
		{
			physStatus->v += m_pNoise->m_posDifference;
			physStatus->w += m_pNoise->m_angDifference;
		}

		//===============================================
		// Commit the velocity back to the physics engine
		//===============================================
		// if (fabsf(m_movementAction.rotateYaw)>0.05f || vel.GetLengthSquared()>0.001f || m_chassis.vel.GetLengthSquared()>0.001f || angVel.GetLengthSquared()>0.001f || angVel.GetLengthSquared()>0.001f) 
		{
			pe_action_set_velocity setVelocity;
			setVelocity.v = physStatus->v;
			setVelocity.w = physStatus->w;
			pPhysics->Action(&setVelocity, 1);
		}
		///////////////////////////////////////////////////////////////
	}
	else
	{
		if (m_isEnginePowered && pPhysics)
		{
			m_movementAction.isAI = true;
	
			pe_status_pos psp;
			pe_status_dynamics psd;
			if (!pPhysics->GetStatus(&psp) || !pPhysics->GetStatus(&psd))
				return;
			UpdatePhysicsStatus(&m_physStatus[k_physicsThread], &psp, &psd);

			ProcessAI(deltaTime);
		}
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:80,代码来源:VehicleMovementHelicopter.cpp


示例20: switch

//------------------------------------------------------------------------
void CVehicleMovementHelicopter::OnEvent(EVehicleMovementEvent event, const SVehicleMovementEventParams& params)
{
	switch (event)
	{
	case eVME_Repair:
		{
			if(params.fValue < 0.25)
			{
				m_damageActual = 0.0f;
				m_damage = 0.0f;
			}
		}
		break;

  case eVME_Collision:
    {
      if (0)
      {
        m_isEnginePowered = false;

        pe_simulation_params simParams;
        simParams.dampingFreefall = 0.01f;
        simParams.gravity = Vec3(0.0f, 0.0f, -9.8f);
        GetPhysics()->SetParams(&simParams);
      }
    }
    break;

	case eVME_GroundCollision:
		{
			const float stopOver = 1.0f;
		}
		break;

	case eVME_Damage:
		{
      if (!m_pVehicle->IsIndestructable())
      {
			  const float stopOver = 1.0f;

			  m_damage = params.fValue;

        if (m_damage > 0.95f)
        {
          m_isEngineDisabled	= true;
          m_isEnginePowered	= false;

          StopExhaust();
          StopSounds();

					IPhysicalEntity * pPhysicalEntity = GetPhysics();

          pe_action_impulse impulse;
          impulse.angImpulse = Vec3(0.1f, 100.f, 0.0f);
          pPhysicalEntity->Action(&impulse);

          pe_simulation_params simParams;
          simParams.dampingFreefall = 0.01f;
          simParams.gravity = Vec3(0.0f, 0.0f, -9.8f);
          pPhysicalEntity->SetParams(&simParams);

          SVehicleEventParams eventParams;
          eventParams.entityId = 0;
          m_pVehicle->BroadcastVehicleEvent(eVE_Destroyed, eventParams);

          if (m_pVehicle)
          {
            if (IEntity *entity = m_pVehicle->GetEntity())
            {
              if (IAIObject *aiobject = entity->GetAI())
              {
                aiobject->Event(AIEVENT_DISABLE, NULL);
              }
            }
          }
        }
      }
		}
		break;

	case eVME_WarmUpEngine:
		m_enginePower = m_enginePowerMax;
		break;

	//case eVME_Turbulence:
	//	m_turbulence = max(m_turbulence, params.fValue);
	//	break;

	default:
		CVehicleMovementBase::OnEvent(event, params);
		break; 
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:94,代码来源:VehicleMovementHelicopter.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetPictureScreen函数代码示例发布时间:2022-05-30
下一篇:
C++ GetPhaseMask函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap