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


C++ Entity::GetPosition方法代码示例

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


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

示例1: OnMouseDown

    void OnMouseDown(UINT button, int x, int y)
    {
        XOrientation camOrient;
        cameraEntity->GetOrientation(&camOrient);

        if (button == 0)
            cameraControl = true;

        //shoot a cube
        else if (button == 1)
        {
            Entity* pCube = g_pScene->CreateEntity();
            g_pSelectedEntity = pCube;
            pCube->SetPosition(cameraEntity->GetPosition() + camOrient.z);
            pCube->SetVelocity(0.1f * camOrient.z);
            //pCube->SetMaxLifeTime(5.0f);

            MeshComponent* pMesh = new MeshComponent(pCube);
            pMesh->SetMeshResource("cube.nfm");

            BodyComponent* pBody = new BodyComponent(pCube);
            pBody->SetMass(10.0f);
            pBody->EnablePhysics((CollisionShape*)EngineGetResource(ResourceType::COLLISION_SHAPE,
                                 "shape_box"));


            OmniLightDesc lightDesc;
            lightDesc.radius = 4.0f;
            lightDesc.shadowFadeStart = 20.0;
            lightDesc.shadowFadeEnd = 30.0;

            Entity* pLightEntity = g_pScene->CreateEntity();
            pCube->Attach(pLightEntity);
            //pLightEntity->SetLocalPosition(Vector(0.0f, 1.0f, 0.0f));

            LightComponent* pLight = new LightComponent(pLightEntity);
            pLight->SetOmniLight(&lightDesc);
            pLight->SetColor(Float3(1.0f, 1.0f, 10.0f));
            pLight->SetShadowMap(0);

        }
        else
        {
            Entity* pBarrel = g_pScene->CreateEntity();
            g_pSelectedEntity = pBarrel;
            pBarrel->SetPosition(cameraEntity->GetPosition() + camOrient.z);
            pBarrel->SetVelocity(30.0f * camOrient.z);

            MeshComponent* pMesh = new MeshComponent(pBarrel);
            pMesh->SetMeshResource("barrel.nfm");

            BodyComponent* pBody = new BodyComponent(pBarrel);
            pBody->SetMass(20.0f);
            pBody->EnablePhysics((CollisionShape*)EngineGetResource(ResourceType::COLLISION_SHAPE,
                                 "shape_barrel"));

        }
    }
开发者ID:nfprojects,项目名称:nfengine,代码行数:58,代码来源:test.cpp

示例2: OnKeyPress

    void OnKeyPress(int key)
    {
        if (key == VK_F1)
        {
            BOOL fullscreen = getFullscreenMode();
            setFullscreenMode(!fullscreen);
        }

        XOrientation orient;

        //place spot light
        if (key == 'T')
        {
            Entity* pLightEntity = g_pScene->CreateEntity();
            cameraEntity->GetOrientation(&orient);
            pLightEntity->SetOrientation(&orient);
            pLightEntity->SetPosition(cameraEntity->GetPosition());

            LightComponent* pLight = new LightComponent(pLightEntity);
            SpotLightDesc lightDesc;
            lightDesc.nearDist = 0.1f;
            lightDesc.farDist = 500.0f;
            lightDesc.cutoff = NFE_MATH_PI / 4.0f;
            lightDesc.maxShadowDistance = 60.0;
            pLight->SetSpotLight(&lightDesc);
            pLight->SetColor(Float3(600, 200, 50));
            pLight->SetLightMap("flashlight.jpg");
            pLight->SetShadowMap(1024);

            g_pSelectedEntity = pLightEntity;
        }

        //place omni light
        if (key == 'O')
        {
            OmniLightDesc lightDesc;
            lightDesc.radius = 10.0f;
            lightDesc.shadowFadeStart = 20.0;
            lightDesc.shadowFadeEnd = 30.0;

            Entity* pLightEntity = g_pScene->CreateEntity();
            pLightEntity->SetPosition(cameraEntity->GetPosition());

            LightComponent* pLight = new LightComponent(pLightEntity);
            pLight->SetOmniLight(&lightDesc);
            pLight->SetColor(Float3(600, 600, 600));
            pLight->SetShadowMap(512);

            g_pSelectedEntity = pLightEntity;
        }
    }
开发者ID:nfprojects,项目名称:nfengine,代码行数:51,代码来源:test.cpp

示例3: CreatePlatform

void PhysicsComponent::CreatePlatform()
{
	btCollisionShape* boxShape = new btBoxShape(btVector3(0.5,0.5,0.5));
	
	Entity* entOwner = GetOwner();
	EVector3f pos = entOwner->GetPosition();

	btDefaultMotionState* fallMotionState =
                new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(pos.x, pos.y, pos.z)));

	
	btScalar mass = 1;
        btVector3 fallInertia(0, 0, 0);
        boxShape->calculateLocalInertia(mass, fallInertia);

	btRigidBody::btRigidBodyConstructionInfo
                boxRigidBodyCI(mass, fallMotionState, boxShape,fallInertia);

    btRigidBody* boxRigidBody = new btRigidBody(boxRigidBodyCI);

	m_rigidBody = boxRigidBody;
	m_rigidBody->setUserPointer(this);
	//add physicsbody to world
		PhysicsManager::GetInstance()->AddPhysicsComponent(this);
}
开发者ID:yongedevil,项目名称:PhysicsAssignment2,代码行数:25,代码来源:PhysicsComponent.cpp

示例4: Execute

Status EvadeBehavior::Execute(void)
{
	// get target
	const TargetData &targetdata = Database::targetdata.Get(mId);

	// get target entity
	Entity *targetEntity = Database::entity.Get(targetdata.mTarget);
	if (!targetEntity)
		return runningTask;

	// get owner entity
	Entity *entity = Database::entity.Get(mId);

	// get evade behavior template
	const EvadeBehaviorTemplate &evade = Database::evadebehaviortemplate.Get(mId);

	// target entity transform
	const Transform2 &targetTransform = targetEntity->GetTransform();

	// evade target's front vector
	Vector2 local(targetTransform.Untransform(entity->GetPosition()));
	if (local.y > 0)
	{
		local *= InvSqrt(local.LengthSq());
		float dir = local.x > 0 ? 1.0f : -1.0f;
		mController->mMove += evade.mStrength * dir * local.y * local.y * local.y * targetTransform.Rotate(Vector2(local.y, -local.x));
	}

	return runningTask;
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:30,代码来源:EvadeBehavior.cpp

示例5: IsEntityWalkable

	bool Engine::IsEntityWalkable(size_t x, size_t y)
	{
		bool is_walkable = true;

		float center_x, center_y = 0.f;
		m_world->GetBlockToPixel(x, y, center_x, center_y);

		// found entity present
		float entity_x, entity_y = 0.f;
		for(entities_t::iterator it = m_entities.begin(); it != m_entities.end(); ++it)
		{
			Entity* entity = (*it);
			entity->GetPosition(entity_x, entity_y);

			if(entity_x == center_x && entity_y == center_y)
			{
				// found an entity in the block
				is_walkable = entity->IsWalkable();

				break;
			}
		}

		return is_walkable;
	}
开发者ID:AnthonyAvet,项目名称:TpUbisoft,代码行数:25,代码来源:engine.cpp

示例6: Remove

// TODO: Test remove function
bool Octree::Remove( const Entity& e )
{
	e.GetPosition();
	u32 id = e.GetId();
	for ( auto& ent : objects )
	{
		if ( ent->GetId() == id)
		{
			delete ent;
			ent = nullptr;
			return true;
		}
	}
	if ( children[0] != nullptr )
	{
		for ( Octree* o : children )
		{
			if( o->Remove(e) )
			{
				return true;
			}
		}
	}
	return false;
}
开发者ID:Ryokin,项目名称:CodeStudies,代码行数:26,代码来源:octree.cpp

示例7: AddSceneEntity

// 添加场景实体 
void SceneRegionManager::AddSceneEntity(Entity& rEntity)
{
	if (SceneRegion* pInRegion = GetBelongRegion(rEntity.GetPosition()))
	{
		// 添加到所在区域 
		pInRegion->AddEntity(rEntity);
	
		// 注册相关区域监听 
		// 计算相交区域 
		set<SceneRegion*> collisionRegions;
		GetCollisionRegion(rEntity.InViewRange(), collisionRegions);

		if (rEntity.IsListen())
		{
			set<SceneRegion*>::iterator it = collisionRegions.begin();
			set<SceneRegion*>::iterator itEnd = collisionRegions.end();
			for (; it != itEnd; ++it)
			{
				(*it)->RegistReceiveChannels(rEntity);
			}
		}

		// 添加管理信息 
		m_umapEntityRegions.insert(make_pair(&rEntity, pair<SceneRegion*, set<SceneRegion*> >(pInRegion, collisionRegions)));
	}
}
开发者ID:skyformat99,项目名称:HMX-Server,代码行数:27,代码来源:SceneRegion.cpp

示例8: OnCollide

void Unit::OnCollide(Entity& entity, const sf::FloatRect& overlap)
{
	if (IsDying() || entity.IsDying())
	{
		return;
	}
	switch (entity.GetCollideEffect())
	{
		case FX_REJECTION:
			// repoussement horizontal ?
			if (overlap.GetHeight() < overlap.GetWidth())
			{
				// vers le haut ou le bas
				knocked_dir_ = entity.GetPosition().y > GetPosition().y ? UP : DOWN;
			}
			else // vertical
			{
				// vers la gauche ou la droite
				knocked_dir_ = entity.GetPosition().x > GetPosition().x ? LEFT : RIGHT;
			}
			knocked_start_ = Game::GetInstance().GetElapsedTime();
			knocked_speed_ = KNOCK_INITIAL_SPEED;
			is_knocked_ = true;
			break;

		case FX_STOP:
			{
				Direction dir;
				float dist;
				if (overlap.GetHeight() < overlap.GetWidth())
				{
					dir = entity.GetPosition().y > GetPosition().y ? UP : DOWN;
					dist = overlap.GetHeight();
				}
				else
				{
					dir = entity.GetPosition().x > GetPosition().x ? LEFT : RIGHT;
					dist = overlap.GetWidth();
				}
				Move(dir, dist);
			}
			break;
		case FX_NOTING:
			break;
	}
}
开发者ID:charafsalmi,项目名称:ppd-paris-descartes,代码行数:46,代码来源:Unit.cpp

示例9: Updatable

// Gunner Constructor
Gunner::Gunner(const GunnerTemplate &aTemplate, unsigned int aId)
: Updatable(aId)
{
	SetAction(Action(this, &Gunner::Update));

	Entity *entity = Database::entity.Get(mId);
#ifdef GUNNER_TRACK_DEQUE
	mTrackPos.push_back(entity->GetPosition());
	mTrackPos.push_back(entity->GetPosition());
#else
	mTrackCount = xs_CeilToInt(aTemplate.mFollowLength/GUNNER_TRACK_GRANULARITY) + 1;
	mTrackPos = new Vector2[mTrackCount];
	mTrackFirst = mTrackLast = 0;
	mTrackPos[0] = entity->GetPosition();
#endif
	mTrackLength = 0.0f;
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:18,代码来源:Gunner.cpp

示例10: Updatable

	TetherBurn(unsigned int aId, unsigned int aSourceId, unsigned int aOwnerId, float aDamage, int aCombo)
		: Updatable(aId), mOwnerId(aOwnerId), mDamage(aDamage), mCombo(aCombo)
	{
		DebugPrint("%s <- %s\n", Database::name.Get(aId).c_str(), Database::name.Get(aSourceId).c_str());

		Renderable::mId = aId;

		Updatable::SetAction(Updatable::Action(this, &TetherBurn::Update));
		Updatable::Activate();

		Renderable::SetAction(Renderable::Action(this, &TetherBurn::Render));
		Renderable::Show();

		Entity *entity = Database::entity.Get(aId);
		Entity *source = Database::entity.Get(aSourceId);

		mSourcePos = source->GetPosition();
		mEnd = mStart + int(entity->GetPosition().Dist(mSourcePos) * sim_rate / 240.0f);
	}
开发者ID:Fissuras,项目名称:videoventure,代码行数:19,代码来源:Cancelable.cpp

示例11: Execute

Status RangeBehavior::Execute(void)
{
	// get target
	const TargetData &targetdata = Database::targetdata.Get(mId);

	// get target entity
	Entity *targetEntity = Database::entity.Get(targetdata.mTarget);
	if (!targetEntity)
		return runningTask;

	// get owner entity
	Entity *entity = Database::entity.Get(mId);

	// get range behavior templates
	const CloseBehaviorTemplate &closebehavior = Database::closebehaviortemplate.Get(mId);
	const FarBehaviorTemplate &farbehavior = Database::farbehaviortemplate.Get(mId);

	// get direction and distance to target
	Vector2 dir = targetEntity->GetPosition() - entity->GetPosition();
	float dist = dir.Length();
	dir /= dist;

	// get target relative speed
	Vector2 vel = targetEntity->GetVelocity() - entity->GetVelocity();
	float speed = vel.Dot(dir);

	// apply close-repel force
	float repel = (dist - closebehavior.mRange) * closebehavior.mScaleDist + speed * closebehavior.mScaleSpeed;
	if (repel < 0.0f)
	{
		mController->mMove += dir * repel;
	}

	// apply far-attract force
	float attract = (dist - farbehavior.mRange) * farbehavior.mScaleDist + speed * farbehavior.mScaleSpeed;
	if (attract > 0.0f)
	{
		mController->mMove += dir * attract;
	}

	return runningTask;
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:42,代码来源:RangeBehavior.cpp

示例12: entity_GetDistance

// .GetDistance(ent, ent) - Returns distance between GetPosition() points of both entities. Error if either entity is invalid.
int entity_GetDistance(lua_State* ls)
{
	DEBUGOUT("entity_GetDistance");
	luaCountArgs(ls, 2);

	Entity* e = _getReferencedEntity(ls);
	Entity* e2 = _getReferencedEntity(ls, 2);

	lua_pushnumber( ls, getDistance(e->GetPosition(), e2->GetPosition()) );

	return 1;
}
开发者ID:McManning,项目名称:fro_client,代码行数:13,代码来源:EntityLib.cpp

示例13: entity_GetPosition

// x, y = .GetPosition(entity)
int entity_GetPosition(lua_State* ls)
{
	DEBUGOUT("entity_GetPosition");
	luaCountArgs(ls, 1);

	Entity* e = _getReferencedEntity(ls);

	point2d p = e->GetPosition();
	lua_pushnumber(ls, p.x);
	lua_pushnumber(ls, p.y);

	return 2;
}
开发者ID:McManning,项目名称:fro_client,代码行数:14,代码来源:EntityLib.cpp

示例14: AddEntity

//Adds an entity to the level from its XML file.
void Level::AddEntity(rapidxml::xml_node<>* root)
{
	if(!root)
		throw "Entity XML missing";

	Entity* entity = new Entity(root, textureManager);
	int x = entity->GetPosition().x;
	int y = entity->GetPosition().y;
	Tile* occupied = map[x][y];

	if(!occupied)
		throw "Entity placed on non-tile";

	occupied->SetOccupant(entity);
	entities.resize(++entCount);
	entities[entCount - 1] = entity;
}
开发者ID:pixley,项目名称:2DExperiment,代码行数:18,代码来源:level.cpp

示例15: Collides

bool Octree::Collides( const Entity &e ) const
{
	glm::vec3 p = e.GetPosition();
	const Octree* node = GetNodeContaining( p.x, p.y, p.z);
	for( auto& obj : node->objects )
	{
		return obj->Collide( e );
	}
	/*
	Entity* obj = node->FindNearest(p.x, p.y, p.z);
	if (obj != nullptr)
	{
		return obj->collider->Collide( ( const Collider & ) e.collider );
	}
	 */
	return false;
}
开发者ID:Ryokin,项目名称:CodeStudies,代码行数:17,代码来源:octree.cpp


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