void CGravControllerPoint::AttachEntity( CBasePlayer *pPlayer, CBaseEntity *pEntity, IPhysicsObject *pPhys, short physicsbone, const Vector &vGrabPosition ) { m_attachedEntity = pEntity; m_attachedPhysicsBone = physicsbone; pPhys->WorldToLocal( &m_localPosition, vGrabPosition ); m_worldPosition = vGrabPosition; pPhys->GetDamping( NULL, &m_saveDamping ); m_saveMass = pPhys->GetMass(); float damping = 2; pPhys->SetDamping( NULL, &damping ); pPhys->SetMass( 50000 ); m_controller = physenv->CreateMotionController( this ); m_controller->AttachObject( pPhys, true ); Vector position; QAngle angles; pPhys->GetPosition( &position, &angles ); SetTargetPosition( vGrabPosition, angles ); m_targetRotation = TransformAnglesToPlayerSpace( angles, pPlayer ); #ifdef ARGG // adnan // we need to grab the preferred/non preferred carry angles here for the rotatedcarryangles m_vecRotatedCarryAngles = m_targetRotation; // end adnan #endif }
bool SeekObject::SeekUpdateMoton(){ auto PtrSeek = GetComponent<SeekSteering>(); PtrSeek->SetTargetPosition(GetPlayerPosition()); if (GetPlayerLength() <= m_StateChangeSize){ return true; } return false; }
bool SeekObject::ArriveUpdateMoton(){ auto PtrArrive = GetComponent<ArriveSteering>(); PtrArrive->SetTargetPosition(GetPlayerPosition()); if (GetPlayerLength() > m_StateChangeSize){ //プレイヤーとの距離が一定以上ならtrue return true; } return false; }
/* ================ hhCameraInterpolator::UpdateTarget ================ */ void hhCameraInterpolator::UpdateTarget( const idVec3& idealPos, const idMat3& idealAxis, float eyeOffset, int interpFlags ) { if( !positionInfo.end.Compare(idealPos, VECTOR_EPSILON) ) { SetTargetPosition( idealPos, interpFlags ); } if( !idealAxis[2].Compare(GetIdealUpVector(), VECTOR_EPSILON) ) { SetTargetAxis( idealAxis, interpFlags ); } if( hhMath::Fabs(eyeOffset - hhMath::Fabs(eyeOffsetInfo.end)) >= VECTOR_EPSILON ) { SetTargetEyeOffset( eyeOffset, interpFlags ); } }
void CSoldierBase::Command(Sint32 n) { switch( n ){ case enSoldierCommandFuttobi: //吹っ飛びダウン m_sWalkType = enWalkTypeEscape; SetTargetPosition(9600*100); ChangeMoveType( enMoveTypeFlyDown ); SetFuttobi(180); SetEnd(); break; } }
void CGrabController::AttachEntity( CBaseEntity *pEntity, IPhysicsObject *pPhys, const Vector &position, const QAngle &rotation ) { pPhys->GetDamping( NULL, &m_saveRotDamping ); float damping = 10; pPhys->SetDamping( NULL, &damping ); m_controller = physenv->CreateMotionController( this ); m_controller->AttachObject( pPhys ); m_controller->SetPriority( IPhysicsMotionController::HIGH_PRIORITY ); pPhys->Wake(); PhysSetGameFlags( pPhys, FVPHYSICS_PLAYER_HELD ); SetTargetPosition( position, rotation ); m_attachedEntity = pEntity; m_flLoadWeight = pPhys->GetMass(); }
void CGravControllerPoint::AttachEntity( CBaseEntity *pEntity, IPhysicsObject *pPhys, const Vector &position ) { m_attachedEntity = pEntity; pPhys->WorldToLocal( &m_localPosition, position ); m_worldPosition = position; pPhys->GetDamping( NULL, &m_saveDamping ); float damping = 2; pPhys->SetDamping( NULL, &damping ); m_controller = physenv->CreateMotionController( this ); m_controller->AttachObject( pPhys, true ); m_controller->SetPriority( IPhysicsMotionController::HIGH_PRIORITY ); SetTargetPosition( position ); m_maxAcceleration = phys_gunforce.GetFloat() * pPhys->GetInvMass(); m_targetRotation = pEntity->GetAbsAngles(); float torque = phys_guntorque.GetFloat(); m_maxAngularAcceleration = torque * pPhys->GetInvInertia(); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // adnan // want to add an angles modifier key bool CGravControllerPoint::UpdateObject( CBasePlayer *pPlayer, CBaseEntity *pEntity ) { IPhysicsObject *pPhysics = GetPhysObjFromPhysicsBone( pEntity, m_attachedPhysicsBone ); if ( !pEntity || !pPhysics ) { return false; } #ifdef ARGG // adnan // if we've been rotating it, set it to its proper new angles (change m_attachedAnglesPlayerSpace while modifier) //Pickup_GetRotatedCarryAngles( pEntity, pPlayer, pPlayer->EntityToWorldTransform(), angles ); // added the ... && (mousedx | mousedy) so we dont have to calculate if no mouse movement // UPDATE: m_vecRotatedCarryAngles has become a temp variable... can be cleaned up by using actual temp vars #ifdef CLIENT_DLL if( m_bHasRotatedCarryAngles && (pPlayer->m_pCurrentCommand->mousedx || pPlayer->m_pCurrentCommand->mousedy) ) #else if( m_bHasRotatedCarryAngles && (pPlayer->GetCurrentCommand()->mousedx || pPlayer->GetCurrentCommand()->mousedy) ) #endif { // method II: relative orientation VMatrix vDeltaRotation, vCurrentRotation, vNewRotation; MatrixFromAngles( m_targetRotation, vCurrentRotation ); #ifdef CLIENT_DLL m_vecRotatedCarryAngles[YAW] = pPlayer->m_pCurrentCommand->mousedx*0.05; m_vecRotatedCarryAngles[PITCH] = pPlayer->m_pCurrentCommand->mousedy*-0.05; #else m_vecRotatedCarryAngles[YAW] = pPlayer->GetCurrentCommand()->mousedx*0.05; m_vecRotatedCarryAngles[PITCH] = pPlayer->GetCurrentCommand()->mousedy*-0.05; #endif m_vecRotatedCarryAngles[ROLL] = 0; MatrixFromAngles( m_vecRotatedCarryAngles, vDeltaRotation ); MatrixMultiply(vDeltaRotation, vCurrentRotation, vNewRotation); MatrixToAngles( vNewRotation, m_targetRotation ); } // end adnan #endif SetTargetPosition( m_targetPosition, m_targetRotation ); return true; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // adnan // want to add an angles modifier key bool CGravControllerPoint::UpdateObject( CBasePlayer *pPlayer, CBaseEntity *pEntity ) { if ( !pEntity || pPlayer->GetGroundEntity() == pEntity || !pEntity->VPhysicsGetObject() ) { return false; } //Adrian: Oops, our object became motion disabled, let go! IPhysicsObject *pPhys = pEntity->VPhysicsGetObject(); if ( pPhys && pPhys->IsMoveable() == false ) { return false; } SetTargetPosition( m_targetPosition, m_targetRotation ); return true; }
void CGravControllerPoint::AttachEntity( CBasePlayer *pPlayer, CBaseEntity *pEntity, IPhysicsObject *pPhys, const Vector &vGrabPosition ) { m_attachedEntity = pEntity; pPhys->WorldToLocal( &m_localPosition, vGrabPosition ); m_worldPosition = vGrabPosition; pPhys->GetDamping( NULL, &m_saveDamping ); m_saveMass = pPhys->GetMass(); float damping = 2; pPhys->SetDamping( NULL, &damping ); pPhys->SetMass( 50000 ); m_controller = physenv->CreateMotionController( this ); m_controller->AttachObject( pPhys, true ); Vector position; QAngle angles; pPhys->GetPosition( &position, &angles ); SetTargetPosition( vGrabPosition, angles ); m_targetRotation = angles; }
void CGrabController::AttachEntity( CBasePlayer *pPlayer, CBaseEntity *pEntity, IPhysicsObject *pPhys, bool bIsMegaPhysCannon, const Vector &vGrabPosition, bool bUseGrabPosition ) { // play the impact sound of the object hitting the player // used as feedback to let the player know he picked up the object int hitMaterial = pPhys->GetMaterialIndex(); int playerMaterial = pPlayer->VPhysicsGetObject() ? pPlayer->VPhysicsGetObject()->GetMaterialIndex() : hitMaterial; PhysicsImpactSound( pPlayer, pPhys, CHAN_STATIC, hitMaterial, playerMaterial, 1.0, 64 ); Vector position; QAngle angles; pPhys->GetPosition( &position, &angles ); // If it has a preferred orientation, use that instead. Pickup_GetPreferredCarryAngles( pEntity, pPlayer, pPlayer->EntityToWorldTransform(), angles ); // ComputeMaxSpeed( pEntity, pPhys ); // If we haven't been killed by a grab, we allow the gun to grab the nearest part of a ragdoll if ( bUseGrabPosition ) { IPhysicsObject *pChild = GetRagdollChildAtPosition( pEntity, vGrabPosition ); if ( pChild ) { pPhys = pChild; } } // Carried entities can never block LOS m_bCarriedEntityBlocksLOS = pEntity->BlocksLOS(); pEntity->SetBlocksLOS( false ); m_controller = physenv->CreateMotionController( this ); m_controller->AttachObject( pPhys, true ); // Don't do this, it's causing trouble with constraint solvers. //m_controller->SetPriority( IPhysicsMotionController::HIGH_PRIORITY ); pPhys->Wake(); PhysSetGameFlags( pPhys, FVPHYSICS_PLAYER_HELD ); SetTargetPosition( position, angles ); m_attachedEntity = pEntity; IPhysicsObject *pList[VPHYSICS_MAX_OBJECT_LIST_COUNT]; int count = pEntity->VPhysicsGetObjectList( pList, ARRAYSIZE(pList) ); m_flLoadWeight = 0; float damping = 10; float flFactor = count / 7.5f; if ( flFactor < 1.0f ) { flFactor = 1.0f; } for ( int i = 0; i < count; i++ ) { float mass = pList[i]->GetMass(); pList[i]->GetDamping( NULL, &m_savedRotDamping[i] ); m_flLoadWeight += mass; m_savedMass[i] = mass; // reduce the mass to prevent the player from adding crazy amounts of energy to the system pList[i]->SetMass( REDUCED_CARRY_MASS / flFactor ); pList[i]->SetDamping( NULL, &damping ); } // Give extra mass to the phys object we're actually picking up pPhys->SetMass( REDUCED_CARRY_MASS ); pPhys->EnableDrag( false ); m_errorTime = bIsMegaPhysCannon ? -1.5f : -1.0f; // 1 seconds until error starts accumulating m_error = 0; m_contactAmount = 0; m_attachedAnglesPlayerSpace = TransformAnglesToPlayerSpace( angles, pPlayer ); if ( m_angleAlignment != 0 ) { m_attachedAnglesPlayerSpace = AlignAngles( m_attachedAnglesPlayerSpace, m_angleAlignment ); } // Ragdolls don't offset this way if ( dynamic_cast<CRagdollProp*>(pEntity) ) { m_attachedPositionObjectSpace.Init(); } else { VectorITransform( pEntity->WorldSpaceCenter(), pEntity->EntityToWorldTransform(), m_attachedPositionObjectSpace ); } // If it's a prop, see if it has desired carry angles CPhysicsProp *pProp = dynamic_cast<CPhysicsProp *>(pEntity); if ( pProp ) { m_bHasPreferredCarryAngles = pProp->GetPropDataAngles( "preferred_carryangles", m_vecPreferredCarryAngles ); m_flDistanceOffset = pProp->GetCarryDistanceOffset(); } else { m_bHasPreferredCarryAngles = false; m_flDistanceOffset = 0; } m_bAllowObjectOverhead = IsObjectAllowedOverhead( pEntity ); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CGrabController::UpdateObject( CBasePlayer *pPlayer, float flError ) { CBaseEntity *pEntity = GetAttached(); if ( !pEntity || ComputeError() > flError || pPlayer->GetGroundEntity() == pEntity || !pEntity->VPhysicsGetObject() ) { return false; } //Adrian: Oops, our object became motion disabled, let go! IPhysicsObject *pPhys = pEntity->VPhysicsGetObject(); if ( pPhys && pPhys->IsMoveable() == false ) { return false; } Vector forward, right, up; QAngle playerAngles = pPlayer->EyeAngles(); AngleVectors( playerAngles, &forward, &right, &up ); float pitch = AngleDistance(playerAngles.x,0); if( !m_bAllowObjectOverhead ) { playerAngles.x = clamp( pitch, -75, 75 ); } else { playerAngles.x = clamp( pitch, -90, 75 ); } // Now clamp a sphere of object radius at end to the player's bbox Vector radial = physcollision->CollideGetExtent( pPhys->GetCollide(), vec3_origin, pEntity->GetAbsAngles(), -forward ); Vector player2d = pPlayer->CollisionProp()->OBBMaxs(); float playerRadius = player2d.Length2D(); float radius = playerRadius + fabs(DotProduct( forward, radial )); float distance = 24 + ( radius * 2.0f ); // Add the prop's distance offset distance += m_flDistanceOffset; Vector start = pPlayer->Weapon_ShootPosition(); Vector end = start + ( forward * distance ); trace_t tr; CTraceFilterSkipTwoEntities traceFilter( pPlayer, pEntity, COLLISION_GROUP_NONE ); Ray_t ray; ray.Init( start, end ); enginetrace->TraceRay( ray, MASK_SOLID_BRUSHONLY, &traceFilter, &tr ); if ( tr.fraction < 0.5 ) { end = start + forward * (radius*0.5f); } else if ( tr.fraction <= 1.0f ) { end = start + forward * ( distance - radius ); } Vector playerMins, playerMaxs, nearest; pPlayer->CollisionProp()->WorldSpaceAABB( &playerMins, &playerMaxs ); Vector playerLine = pPlayer->CollisionProp()->WorldSpaceCenter(); CalcClosestPointOnLine( end, playerLine+Vector(0,0,playerMins.z), playerLine+Vector(0,0,playerMaxs.z), nearest, NULL ); if( !m_bAllowObjectOverhead ) { Vector delta = end - nearest; float len = VectorNormalize(delta); if ( len < radius ) { end = nearest + radius * delta; } } //Show overlays of radius if ( g_debug_physcannon.GetBool() ) { NDebugOverlay::Box( end, -Vector( 2,2,2 ), Vector(2,2,2), 0, 255, 0, true, 0 ); NDebugOverlay::Box( GetAttached()->WorldSpaceCenter(), -Vector( radius, radius, radius), Vector( radius, radius, radius ), 255, 0, 0, true, 0.0f ); } QAngle angles = TransformAnglesFromPlayerSpace( m_attachedAnglesPlayerSpace, pPlayer ); // If it has a preferred orientation, update to ensure we're still oriented correctly. Pickup_GetPreferredCarryAngles( pEntity, pPlayer, pPlayer->EntityToWorldTransform(), angles ); // We may be holding a prop that has preferred carry angles if ( m_bHasPreferredCarryAngles ) { matrix3x4_t tmp; ComputePlayerMatrix( pPlayer, tmp ); angles = TransformAnglesToWorldSpace( m_vecPreferredCarryAngles, tmp ); } matrix3x4_t attachedToWorld; Vector offset; AngleMatrix( angles, attachedToWorld ); VectorRotate( m_attachedPositionObjectSpace, attachedToWorld, offset ); SetTargetPosition( end - offset, angles ); return true; }
void SeekObject::ArriveStartMoton(){ auto PtrArrive = GetComponent<ArriveSteering>(); PtrArrive->SetUpdateActive(true); PtrArrive->SetTargetPosition(GetPlayerPosition()); }
//モーションを実装する関数群 void SeekObject::SeekStartMoton(){ auto PtrSeek = GetComponent<SeekSteering>(); PtrSeek->SetUpdateActive(true); PtrSeek->SetTargetPosition(GetPlayerPosition()); }
/*! process command * * \return A value : braitenberg end mode * - 0 if success * - <0 if any error */ int process_command () { char Buffer[MAXBUFFERSIZE]; int narg; int out=0; string larg[MAX_ARG]; char *bptr; // receive and interpret commands (wait) if ( readLine(Buffer) >0 ) { #ifdef DEBUG printf("%c length %d |%s|",Buffer[0],strlen(Buffer),Buffer); #endif if (strlen(Buffer)>2) { /* Process all the args */ bptr = Buffer + 2; narg=getArgs(bptr,larg); } switch(Buffer[0]) { case 'A': out=braitenberg(narg,larg); break; case 'B': revisionOS(narg,larg); break; case 'C': configureOS(narg,larg); break; case 'D': SetSpeed(narg,larg); break; case 'E': GetSpeed(narg,larg); break; case 'F': SetTargetProfile(narg,larg); break; case 'G': GetUS(narg,larg); break; case 'H': ConfigPID(narg,larg); break; case 'I': SetEncPosition(narg,larg); break; case 'J': ConfigSpeedProfile(narg,larg); break; case 'K': SetLED(narg,larg); break; case 'L': SetSpeedOpenLoop(narg,larg); break; case 'M': InitMot(narg,larg); break; case 'N': ReadProxSensors(narg,larg); break; case 'O': ReadAmbSensors(narg,larg); break; case 'P': SetTargetPosition(narg,larg); break; case 'R': ReadPos(narg,larg); break; case 'V': batStatus(narg,larg); break; case 'X': BinaryRead(narg,larg); break; case 'Z': tstampRST(narg,larg); break; default: sprintf(Buffer,"%c\r\n",ERROR_CMD_CHAR); com_send(Buffer, strlen(Buffer)); } } return out; }