本文整理汇总了C++中GetVelocity函数的典型用法代码示例。如果您正苦于以下问题:C++ GetVelocity函数的具体用法?C++ GetVelocity怎么用?C++ GetVelocity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetVelocity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetModel
void Ship::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform)
{
if (IsDead()) return;
//angthrust negated, for some reason
GetModel()->SetThrust(vector3f(m_thrusters), -vector3f(m_angThrusters));
matrix3x3f mt;
matrix3x3dtof(viewTransform.Inverse().GetOrient(), mt);
s_heatGradientParams.heatingMatrix = mt;
s_heatGradientParams.heatingNormal = vector3f(GetVelocity().Normalized());
s_heatGradientParams.heatingAmount = Clamp(GetHullTemperature(),0.0,1.0);
// This has to be done per-model with a shield and just before it's rendered
const bool shieldsVisible = m_shieldCooldown > 0.01f && m_stats.shield_mass_left > (m_stats.shield_mass / 100.0f);
GetShields()->SetEnabled(shieldsVisible);
GetShields()->Update(m_shieldCooldown, 0.01f*GetPercentShields());
//strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText));
RenderModel(renderer, camera, viewCoords, viewTransform);
m_navLights->Render(renderer);
renderer->GetStats().AddToStatCount(Graphics::Stats::STAT_SHIPS, 1);
if (m_ecmRecharge > 0.0f) {
// ECM effect: a cloud of particles for a sparkly effect
vector3f v[100];
for (int i=0; i<100; i++) {
const double r1 = Pi::rng.Double()-0.5;
const double r2 = Pi::rng.Double()-0.5;
const double r3 = Pi::rng.Double()-0.5;
v[i] = vector3f(GetPhysRadius()*vector3d(r1, r2, r3).NormalizedSafe());
}
Color c(128,128,255,255);
float totalRechargeTime = GetECMRechargeTime();
if (totalRechargeTime >= 0.0f) {
c.a = (m_ecmRecharge / totalRechargeTime) * 255;
}
SfxManager::ecmParticle->diffuse = c;
matrix4x4f t;
for (int i=0; i<12; i++) t[i] = float(viewTransform[i]);
t[12] = viewCoords.x;
t[13] = viewCoords.y;
t[14] = viewCoords.z;
t[15] = 1.0f;
renderer->SetTransform(t);
renderer->DrawPointSprites(100, v, SfxManager::additiveAlphaState, SfxManager::ecmParticle.get(), 50.f);
}
}
示例2: Update
void Encoder::Update(const common::UpdateInfo &info) {
msgs::Float64 pos_msg, vel_msg;
if (stopped) {
pos_msg.set_data(stop_value);
pos_pub->Publish(pos_msg);
vel_msg.set_data(0);
vel_pub->Publish(vel_msg);
} else {
pos_msg.set_data(GetAngle() - zero);
pos_pub->Publish(pos_msg);
vel_msg.set_data(GetVelocity());
vel_pub->Publish(vel_msg);
}
}
示例3: GetVelocity
int CprojectileIGC::Export(void* data)
{
if (data)
{
DataProjectileIGC* dataProjectile = (DataProjectileIGC*)data;
dataProjectile->projectileTypeID = m_projectileType->GetObjectID();
dataProjectile->velocity = GetVelocity();
dataProjectile->forward = GetOrientation().GetForward();
}
return sizeof(DataProjectileIGC);
}
示例4: GetVelocity
bool ODERigidObject::WriteState(File& f) const
{
//TODO: use body quaternion
Vector3 w,v;
const dReal* pos=dBodyGetPosition(bodyID);
const dReal* q=dBodyGetQuaternion(bodyID);
GetVelocity(w,v);
if(!WriteArrayFile(f,pos,3)) return false;
if(!WriteArrayFile(f,q,4)) return false;
if(!WriteFile(f,w)) return false;
if(!WriteFile(f,v)) return false;
return true;
}
示例5: Missile
Missile * Ship::SpawnMissile(ShipType::Id missile_type, int power) {
if (GetFlightState() != FLYING)
return 0;
Missile *missile = new Missile(missile_type, this, power);
missile->SetOrient(GetOrient());
missile->SetFrame(GetFrame());
// XXX DODGY! need to put it in a sensible location
vector3d dir = -GetOrient().VectorZ();
missile->SetPosition(GetPosition()+50.0*dir);
missile->SetVelocity(GetVelocity());
Pi::game->GetSpace()->AddBody(missile);
return missile;
}
示例6: Properties
bool Ship::OnCollision(Object *b, Uint32 flags, double relVel)
{
// hitting space station docking surfaces shouldn't do damage
if (b->IsType(Object::SPACESTATION) && (flags & 0x10)) {
return true;
}
// hitting cargo scoop surface shouldn't do damage
int cargoscoop_cap = 0;
Properties().Get("cargo_scoop_cap", cargoscoop_cap);
if (cargoscoop_cap > 0 && b->IsType(Object::CARGOBODY) && !dynamic_cast<Body*>(b)->IsDead()) {
LuaRef item = dynamic_cast<CargoBody*>(b)->GetCargoType();
if (LuaObject<Ship>::CallMethod<int>(this, "AddEquip", item) > 0) { // try to add it to the ship cargo.
Pi::game->GetSpace()->KillBody(dynamic_cast<Body*>(b));
if (this->IsType(Object::PLAYER))
Pi::game->log->Add(stringf(Lang::CARGO_SCOOP_ACTIVE_1_TONNE_X_COLLECTED, formatarg("item", ScopedTable(item).CallMethod<std::string>("GetName"))));
// XXX SfxManager::Add(this, TYPE_SCOOP);
UpdateEquipStats();
return true;
}
if (this->IsType(Object::PLAYER))
Pi::game->log->Add(Lang::CARGO_SCOOP_ATTEMPTED);
}
if (b->IsType(Object::PLANET)) {
// geoms still enabled when landed
if (m_flightState != FLYING) return false;
else {
if (GetVelocity().Length() < MAX_LANDING_SPEED) {
m_testLanded = true;
return true;
}
}
}
if (
b->IsType(Object::CITYONPLANET) ||
b->IsType(Object::SHIP) ||
b->IsType(Object::PLAYER) ||
b->IsType(Object::SPACESTATION) ||
b->IsType(Object::PLANET) ||
b->IsType(Object::STAR) ||
b->IsType(Object::CARGOBODY))
{
LuaEvent::Queue("onShipCollided", this,
b->IsType(Object::CITYONPLANET) ? dynamic_cast<CityOnPlanet*>(b)->GetPlanet() : dynamic_cast<Body*>(b));
}
return DynamicBody::OnCollision(b, flags, relVel);
}
示例7: Missile
Missile * Ship::SpawnMissile(ShipType::Id missile_type, int power) {
if (GetFlightState() != FLYING)
return 0;
Missile *missile = new Missile(missile_type, this, power);
missile->SetOrient(GetOrient());
missile->SetFrame(GetFrame());
const vector3d pos = GetOrient() * vector3d(0, GetAabb().min.y - 10, GetAabb().min.z);
const vector3d vel = -40.0 * GetOrient().VectorZ();
missile->SetPosition(GetPosition()+pos);
missile->SetVelocity(GetVelocity()+vel);
Pi::game->GetSpace()->AddBody(missile);
return missile;
}
示例8: UTIL_Remove
//-----------------------------------------------------------------------------
// Purpose: Plays the engine sound.
//-----------------------------------------------------------------------------
void CNPC_Houndeye::NPCThink(void)
{
if (m_pEnergyWave)
{
if (gpGlobals->curtime > m_flEndEnergyWaveTime)
{
UTIL_Remove(m_pEnergyWave);
m_pEnergyWave = NULL;
}
}
// -----------------------------------------------------
// Update collision group
// While I'm running I'm allowed to penetrate
// other houndeyes
// -----------------------------------------------------
Vector vVelocity;
GetVelocity( &vVelocity, NULL );
if (vVelocity.Length() > 10)
{
SetCollisionGroup( HL2COLLISION_GROUP_HOUNDEYE );
}
else
{
// Don't go solid if resting in another houndeye
trace_t tr;
AI_TraceHull( GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,1),
GetHullMins(), GetHullMaxs(),
MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr );
if (!tr.startsolid)
{
SetCollisionGroup( COLLISION_GROUP_NONE );
}
else
{
SetCollisionGroup( HL2COLLISION_GROUP_HOUNDEYE );
}
}
/*
if (GetCollisionGroup() == HL2COLLISION_GROUP_HOUNDEYE)
{
NDebugOverlay::Box(GetAbsOrigin(), GetHullMins(), GetHullMaxs(), 0, 255, 0, 0, 0);
}
else
{
NDebugOverlay::Box(GetAbsOrigin(), GetHullMins(), GetHullMaxs(), 255, 0, 0, 0, 0);
}
*/
BaseClass::NPCThink();
}
示例9: GetVelocity
void Ship::TestLanded()
{
m_testLanded = false;
if (m_launchLockTimeout > 0.0f) return;
if (m_wheelState < 1.0f) return;
if (GetFrame()->GetBodyFor()->IsType(Object::PLANET)) {
double speed = GetVelocity().Length();
vector3d up = GetPosition().Normalized();
const double planetRadius = static_cast<Planet*>(GetFrame()->GetBodyFor())->GetTerrainHeight(up);
if (speed < MAX_LANDING_SPEED) {
// orient the damn thing right
// Q: i'm totally lost. why is the inverse of the body rot matrix being used?
// A: NFI. it just works this way
matrix4x4d rot;
GetRotMatrix(rot);
matrix4x4d invRot = rot.InverseOf();
// check player is sortof sensibly oriented for landing
const double dot = vector3d(invRot[1], invRot[5], invRot[9]).Normalized().Dot(up);
if (dot > 0.99) {
Aabb aabb;
GetAabb(aabb);
// position at zero altitude
SetPosition(up * (planetRadius - aabb.min.y));
vector3d forward = rot * vector3d(0,0,1);
vector3d other = up.Cross(forward).Normalized();
forward = other.Cross(up);
rot = matrix4x4d::MakeRotMatrix(other, up, forward);
rot = rot.InverseOf();
SetRotMatrix(rot);
SetVelocity(vector3d(0, 0, 0));
SetAngVelocity(vector3d(0, 0, 0));
SetForce(vector3d(0, 0, 0));
SetTorque(vector3d(0, 0, 0));
// we don't use DynamicBody::Disable because that also disables the geom, and that must still get collisions
DisableBodyOnly();
ClearThrusterState();
m_flightState = LANDED;
Sound::PlaySfx("Rough_Landing", 1.0f, 1.0f, 0);
Pi::luaOnShipLanded->Queue(this, GetFrame()->GetBodyFor());
}
}
}
}
示例10: GetOrient
void Missile::StaticUpdate(const float timeStep)
{
// Note: direct call to AI->TimeStepUpdate
if (m_curAICmd!=nullptr) m_curAICmd->TimeStepUpdate();
//Add smoke trails for missiles on thruster state
static double s_timeAccum = 0.0;
s_timeAccum += timeStep;
if (!is_equal_exact(GetThrusterState().LengthSqr(), 0.0) && (s_timeAccum > 4 || 0.1*Pi::rng.Double() < timeStep)) {
s_timeAccum = 0.0;
const vector3d pos = GetOrient() * vector3d(0, 0 , 5);
const float speed = std::min(10.0*GetVelocity().Length()*std::max(1.0,fabs(GetThrusterState().z)),100.0);
SfxManager::AddThrustSmoke(this, speed, pos);
}
}
示例11: GetPosition
void FastProjectile::OnTrigger(tbc::PhysicsManager::BodyID trigger_id, ContextObject* other_object, tbc::PhysicsManager::BodyID body_id, const vec3& position, const vec3& normal) {
(void)trigger_id;
(void)body_id;
(void)position;
if (++tick_count_ < 10 && other_object->GetInstanceId() == GetOwnerInstanceId()) { // Disallow self-hit during the first few frames.
return;
}
if (explosive_energy_) {
ProjectileUtil::Detonate(this, &is_detonated_, launcher_, GetPosition(), GetVelocity(), normal, explosive_energy_, 0);
} else {
ProjectileUtil::OnBulletHit(this, &is_detonated_, launcher_, other_object);
}
}
示例12: GetVelocity
void ADefyingGravityCharacter::UpdateAnimation()
{
const FVector PlayerVelocity = GetVelocity();
const float PlayerSpeed = PlayerVelocity.Size();
// Are we moving or standing still?
UPaperFlipbook* DesiredAnimation = (PlayerSpeed > 0.0f) ? catWalkAnimation : idleCatAnimation;
if (GetCharacterMovement()->IsFalling())
{
DesiredAnimation = JumpCatAnimation;
}
if( GetSprite()->GetFlipbook() != DesiredAnimation )
{
GetSprite()->SetFlipbook(DesiredAnimation);
}
}
示例13: GetVelocity
int Smoke::Update()
{
D3DXVECTOR3 v = GetVelocity();
v.x *= 0.75f;
if (v.y>0) v.y -= 0.125f;
SetVelocity(v);
if (iLifeTimer >= 50)
vScale.x = vScale.y = (60-iLifeTimer)/10.f;
else
fAlpha = min(iLifeTimer/40.f, 1);
if (iLifeTimer == 0)
erase();
iLifeTimer -= 1;
return GameObj::Update();
}
示例14: JumpVec
//Aボタンでジャンプする瞬間の処理
void Player::JumpMotion(){
auto PtrTrans = GetComponent<Transform>();
//重力
auto PtrGravity = GetComponent<Gravity>();
//ジャンプスタート
Vector3 JumpVec(0.0f, 4.0f, 0);
if (PtrTrans->GetParent()){
//親がいたら、アクションコンポーネントの移動アクションを探す
//移動ボックスに乗っている場合、その慣性をジャンプに加算する
auto ActionPtr = PtrTrans->GetParent()->GetComponent<Action>(false);
if (ActionPtr){
JumpVec += ActionPtr->GetVelocity();
}
}
PtrGravity->StartJump(JumpVec);
}
示例15: DefaultBehavior
bool Enemy::DefaultBehavior() {
auto PtrRigid = GetComponent<Rigidbody>();
auto Velo = PtrRigid->GetVelocity();
Velo *= 0.95f;
PtrRigid->SetVelocity(Velo);
auto MapPtr = m_CelMap.lock();
if (MapPtr) {
auto PlayerPtr = GetStage()->GetSharedGameObject<Player>(L"Player");
auto PlayerPos = PlayerPtr->GetComponent<Transform>()->GetPosition();
CellIndex PlayerCell;
if (MapPtr->FindCell(PlayerPos, PlayerCell)) {
return false;
}
}
return true;
}