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


C++ AttributeIterator::at方法代码示例

本文整理汇总了C++中AttributeIterator::at方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeIterator::at方法的具体用法?C++ AttributeIterator::at怎么用?C++ AttributeIterator::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeIterator的用法示例。


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

示例1: frustumInit

bool FrustumPhysicsObject::frustumInit(unsigned int attributeIndex,short collisionFilterGroup)
{
	if(attributeIndex < 0)
	{
		return false;
	}
	attributeIndex_ = attributeIndex;
	collisionFilterGroup_ = collisionFilterGroup;
	AttributePtr<Attribute_Camera> ptr_camera = itrCamera_3.at(attributeIndex);
	btVector3 localInertia;
	localInertia.setZero();
	btCollisionShape* collisionShape = CollisionShapes::Instance()->getFrustumShape(attributeIndex_);
	btScalar mass = static_cast<btScalar>(1);
	setMassProps(mass, localInertia);
	setCollisionShape(collisionShape);
	btTransform world;
	
	AttributePtr<Attribute_Spatial> ptr_spatial = itrCamera_3.at(attributeIndex_)->ptr_spatial;
 	AttributePtr<Attribute_Position> ptr_position = ptr_spatial->ptr_position;
 	world.setOrigin(convert(ptr_position->position));
	world.setRotation(convert(ptr_spatial->rotation));
	setWorldTransform(world);
	setCollisionFlags(getCollisionFlags() | CF_NO_CONTACT_RESPONSE); 
	forceActivationState(DISABLE_DEACTIVATION);
	return true;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:26,代码来源:FrustumPhysicsObject.cpp

示例2: onUpdate

void FrustumPhysicsObject::onUpdate(float delta)
{
	btMatrix3x3 view = convert(itrCamera_3.at(attributeIndex_)->mat_view);
	btVector3 pos =  convert(itrCamera_3.at(attributeIndex_)->ptr_spatial->ptr_position->position);
	btQuaternion q;
	view.getRotation(q);
	btTransform world = getWorldTransform();
	world.setRotation(q);
	world.setOrigin(pos);
	setWorldTransform(world);
	
	setCollisionShape(CollisionShapes::Instance()->getFrustumShape(attributeIndex_));
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:13,代码来源:FrustumPhysicsObject.cpp

示例3: 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));
        }
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:59,代码来源:PlayerPhysicsObject.cpp

示例4: 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;
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:57,代码来源:PlayerPhysicsObject.cpp

示例5: subClassSpecificInitHook

bool PlayerPhysicsObject::subClassSpecificInitHook()
{
    forceActivationState(DISABLE_DEACTIVATION); //Prevent the player from getting stuck when standing still
    //setCollisionFlags(getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);

    Float4 q = itrPhysics_3.at(attributeIndex_)->ptr_spatial->rotation;
    yaw_ = -atan2(2*q.y*q.w-2*q.x*q.z , 1 - 2*q.y*q.y - 2*q.z*q.z);
    return true;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:9,代码来源:PlayerPhysicsObject.cpp

示例6: writeNonSynchronizedPhysicsObjectDataToPhysicsAttribute

void PhysicsObject::writeNonSynchronizedPhysicsObjectDataToPhysicsAttribute()
{
	AttributePtr<Attribute_Physics> ptr_physics = itrPhysics_.at(attributeIndex_);

	ptr_physics->angularVelocity = convert(&getAngularVelocity());
	ptr_physics->collisionFilterGroup = getCollisionFilterGroup();
	ptr_physics->collisionResponse = (getCollisionFlags() & btCollisionObject::CF_NO_CONTACT_RESPONSE) == 0;
	ptr_physics->gravity = convert(&getGravity());
	ptr_physics->linearVelocity = convert(&getLinearVelocity());
	//ptr_physics->collisionFilterMask = 
	//ptr_physics->mass = physicsObject->getInvMass(); //only mass inverse is stored in physics object
	//ptr_physics->meshID = //not stored in physics object
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:13,代码来源:physicsObject.cpp

示例7: 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;
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:23,代码来源:PlayerPhysicsObject.cpp

示例8: onUpdate

void PhysicsObject::onUpdate(float delta)
{	
	AttributePtr<Attribute_Physics> physicsAttribute = itrPhysics_.at(attributeIndex_);
	Float3 position = physicsAttribute->ptr_spatial->ptr_position->position;
	if(position.y < outOfBoundsIfYIsLowerThanThis)
	if(getWorldTransform().getOrigin().y() < outOfBoundsIfYIsLowerThanThis)
	{
		handleOutOfBounds();
	}

	//if(getWorldTransform().getOrigin().y() < outOfBoundsIfYIsLowerThanThis)
	//{
	//	handleOutOfBounds();
	//}
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:15,代码来源:physicsObject.cpp

示例9: 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);
        }
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:21,代码来源:PlayerPhysicsObject.cpp

示例10: 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]));
        }
    }
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:24,代码来源:PlayerPhysicsObject.cpp

示例11: subClassSpecificCollisionShape

btCollisionShape* PhysicsObject::subClassSpecificCollisionShape()
{
	AttributePtr<Attribute_Physics> ptr_physics = itrPhysics_.at(attributeIndex_);
	btCollisionShape* collisionShape = CollisionShapes::Instance()->getCollisionShape(ptr_physics->meshID);
	return collisionShape;
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:6,代码来源:physicsObject.cpp

示例12: init

bool PhysicsObject::init(unsigned int attributeIndex, short collisionFilterGroup)
{
	if(attributeIndex < 0)
	{
		return false;
	}
	attributeIndex_ = attributeIndex;
	collisionFilterGroup_ = collisionFilterGroup;

	//Get the init data from a physics attribute
	AttributePtr<Attribute_Physics> ptr_physics = itrPhysics_.at(attributeIndex);
	btScalar mass = static_cast<btScalar>(ptr_physics->mass);

	//Resolve mass, local inertia of the collision shape, and also the collision shape itself.
	btCollisionShape* collisionShape = subClassSpecificCollisionShape();
	if(collisionShape != nullptr)
	{
		setCollisionShape(collisionShape);
	}
	else
	{
		ERROR_MESSAGEBOX("Error in PhysicsObject::init. Expected collision shape pointer unexpectedly set to nullptr. Using default shape instead.");
		setCollisionShape(CollisionShapes::Instance()->getDefaultShape());
	}
	
	btVector3 localInertia = subClassCalculateLocalInertiaHook(mass);
	setMassProps(mass, localInertia); //Set inverse mass and inverse local inertia
	updateInertiaTensor();
	if((getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT))
	{
		btTransform world;

		AttributePtr<Attribute_Spatial> ptr_spatial = itrPhysics_.at(attributeIndex_)->ptr_spatial;
		AttributePtr<Attribute_Position> ptr_position = ptr_spatial->ptr_position;
 		world.setOrigin(convert(ptr_position->position));
		world.setRotation(convert(ptr_spatial->rotation));
		setWorldTransform(world);  //Static physics objects: transform once
	}
	else
	{
		//Non-static physics objects: let a derived btMotionState handle transforms.
		MotionState* customMotionState = new MotionState(attributeIndex);
		setMotionState(customMotionState);

		setAngularVelocity(btVector3(ptr_physics->angularVelocity.x,
										ptr_physics->angularVelocity.y,
										ptr_physics->angularVelocity.z));
		setLinearVelocity(btVector3(ptr_physics->linearVelocity.x,
										ptr_physics->linearVelocity.y,
										ptr_physics->linearVelocity.z));
		//Gravity is set after "addRigidBody" for non-static physics objects
	}

	if(ptr_physics->collisionResponse)
	{
		setCollisionFlags(getCollisionFlags() & ~CF_NO_CONTACT_RESPONSE); //Activate collision response
	}
	else
	{
		setCollisionFlags(getCollisionFlags() | CF_NO_CONTACT_RESPONSE); //Deactivate collision response
	}
	
	return subClassSpecificInitHook();
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:64,代码来源:physicsObject.cpp


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