本文整理汇总了C++中AttributeIterator::ownerAt方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeIterator::ownerAt方法的具体用法?C++ AttributeIterator::ownerAt怎么用?C++ AttributeIterator::ownerAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeIterator
的用法示例。
在下文中一共展示了AttributeIterator::ownerAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleInput
void PlayerPhysicsObject::handleInput(float delta)
{
std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
if(playerAttributes.size() > 1)
{
ERROR_MESSAGEBOX("More than one controller for one player. Not tested.")
}
for(unsigned int i=0; i<playerAttributes.size(); i++)
{
AttributePtr<Attribute_Player> ptr_player = ptr_player = itrPlayer.at(playerAttributes.at(i));
AttributePtr<Attribute_Input> ptr_input = ptr_player->ptr_input;
AttributePtr<Attribute_Health> health = ptr_player->ptr_health;
if(health->health <= 0)
{
continue;
}
//--------------------------------------------------------------------------------------
//Look and move
//--------------------------------------------------------------------------------------
yaw_ += ptr_input->rotation.x;
btVector3 move = ptr_player->currentSpeed*btVector3(ptr_input->position.x, 0, ptr_input->position.y);
//lower player speed when recently damaged
if(ptr_player->timeSinceLastDamageTaken < 1.0f)
{
move *= 0.75f;
}
//Move player
move = move.rotate(btVector3(0,1,0),yaw_);
move = btVector3(move.x(), getLinearVelocity().y(), move.z());
setLinearVelocity(move);
//Rotate player
btTransform world;
world = getWorldTransform();
world.setRotation(btQuaternion(yaw_,0,0));
setWorldTransform(world);
//Jetpack
if(ptr_player->jetpack)
{
float jetpackPower = -getGravity().y()*1.5f;
world = getWorldTransform();
btVector3 velocity = getLinearVelocity();
if(world.getOrigin().y() < 18.0f)
{
setLinearVelocity(btVector3(move.x(), velocity.y()+jetpackPower*delta, move.z()));
}
}
else if(ptr_input->jump && ptr_player->hovering) //Jump
{
float jumpPower = 600.0f;
applyCentralImpulse(btVector3(0.0f, jumpPower, 0.0f));
//applyCentralForce(btVector3(0.0f, jumpPower, 0.0f));
}
}
}
示例2: hover
void PlayerPhysicsObject::hover(float delta, float hoverHeight)
{
float deltaHeightMaximum = 0.0f;
btVector3 offset[] = {btVector3( 0.15f, 0.0f, 0.15f),
btVector3( 0.15f, 0.0f, -0.15f),
btVector3(-0.15f, 0.0f, 0.15f),
btVector3(-0.15f, 0.0f, -0.15f)
};
for(unsigned int i=0; i<4; i++)
{
btVector3 from = btVector3(0.0f, 0.0f, 0.0f);
btVector3 to = (from - btVector3(0.0f,hoverHeight*2.0f,0.0f)) + offset[i];
from += offset[i];
from += getWorldTransform().getOrigin();
to += getWorldTransform().getOrigin();
btQuaternion btqt = getWorldTransform().getRotation();
btCollisionWorld::ClosestRayResultCallback ray(from,to);
ray.m_collisionFilterGroup = XKILL_Enums::PhysicsAttributeType::RAY;
ray.m_collisionFilterMask = XKILL_Enums::PhysicsAttributeType::WORLD;
dynamicsWorld_->rayTest(from,to,ray); //cast ray from player position straight down
if(ray.hasHit())
{
btVector3 point = from.lerp(to,ray.m_closestHitFraction);
float length = (point - from).length();
float deltaHeight = hoverHeight-length;
if(deltaHeight > deltaHeightMaximum)
{
deltaHeightMaximum = deltaHeight;
}
}
debugDrawer_->drawLine(from, to, btVector3(0.2f, 1.0f, 0.2f));
}
bool isHovering = false;
if(deltaHeightMaximum > 0.0f)
{
btTransform worldTransform;
worldTransform = getWorldTransform();
worldTransform.setOrigin(worldTransform.getOrigin() + btVector3(0.0f,deltaHeightMaximum,0.0f)*delta/0.25f);
setWorldTransform(worldTransform);
setLinearVelocity(getLinearVelocity()+btVector3(0.0f,-getLinearVelocity().y(),0.0f));
isHovering = true;
}
std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
for(unsigned int i=0; i<playerAttributes.size(); i++)
{
AttributePtr<Attribute_Player> ptr_player = itrPlayer.at(playerAttributes.at(i));
ptr_player->hovering = isHovering;
}
}
示例3: onUpdate
void PlayerPhysicsObject::onUpdate(float delta)
{
PhysicsObject::onUpdate(delta);
std::vector<int> playerAttributes = itrPhysics_3.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_PLAYER);
for(unsigned int i=0; i<playerAttributes.size(); i++)
{
AttributePtr<Attribute_Player> ptr_player = itrPlayer.at(playerAttributes.at(i));
if(!ptr_player->detectedAsDead)
{
handleInput(delta);
}
if( !(ptr_player->jetpack) && !(ptr_player->detectedAsDead) && !(ptr_player->ptr_input->jump))
{
float height = 1.5;
hover(delta, height);
}
}
}
示例4: subClassCalculateLocalInertiaHook
btVector3 PlayerPhysicsObject::subClassCalculateLocalInertiaHook(btScalar mass)
{
Entity* playerEntity = itrPhysics_3.ownerAt(attributeIndex_);
std::vector<int> playerId = playerEntity->getAttributes(ATTRIBUTE_PLAYER);
bool detectedAsDead = false;
for(unsigned int i = 0; i < playerId.size(); i++)
{
detectedAsDead = itrPlayer.at(playerId.at(i))->detectedAsDead;
}
btVector3 localInertia;
if(detectedAsDead)
{
localInertia = localInertiaBasedOnCollisionShapeAndMass(itrPhysics_3.at(attributeIndex_)->mass);
}
else
{
localInertia = zeroLocalInertia();
}
return localInertia;
}
示例5: handleOutOfBounds
void PlayerPhysicsObject::handleOutOfBounds()
{
setGravity(btVector3(0.0f, 0.0f, 0.0f));
setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f));
int playerEntityIndex = itrPhysics_3.ownerIdAt(attributeIndex_);
Entity* playerEntity = itrPhysics_3.ownerAt(attributeIndex_);
std::vector<int> playerAttributeIndices = playerEntity->getAttributes(ATTRIBUTE_PLAYER);
for(unsigned int i = 0; i < playerAttributeIndices.size(); i++)
{
AttributePtr<Attribute_Player> ptr_player = itrPlayer.at(playerAttributeIndices.at(i));
AttributePtr<Attribute_Health> playerHealthAttribute = ptr_player->ptr_health;
if(!ptr_player->detectedAsDead)
{
if(!SETTINGS->isNullprocessExecuting)
{
ptr_player->priority--; //punish players for falling outside of the level, if the null process is not running
}
DEBUGPRINT("Player entity " << playerEntityIndex << " was out of bounds");
SEND_EVENT(&Event_PlayerDeath(playerAttributeIndices[i]));
}
}
}
示例6: removePhysicsAttributeCorrespondingToThisPhysicsObject
void PhysicsObject::removePhysicsAttributeCorrespondingToThisPhysicsObject()
{
Entity* ownerEntityOfPhysicsAttribute = itrPhysics_.ownerAt(attributeIndex_);
int entityOwnerId = ownerEntityOfPhysicsAttribute->getID();
SEND_EVENT(&Event_RemoveEntity(entityOwnerId));
}