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


C++ Point::GetNormalizedPoint方法代码示例

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


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

示例1: RecalculatePath

void MovingObjectModel::RecalculatePath()
{
	//Only do stuff if the path contains elements.
	if(m_Path != NULL && !m_Path->empty())
	{
		auto next = m_Path->at(0);

		Point tempDirection = next - GetPosition();
		float distance = tempDirection.GetLength();
		tempDirection = tempDirection.GetNormalizedPoint();

		Point oppositDirection = m_Direction.GetNegatedPoint();
		oppositDirection = oppositDirection.GetNormalizedPoint();

		//If direction got negated, we overshot our target or if we have reached our next goal
		if(tempDirection == &oppositDirection || distance < 0.01f)
		{
			m_Path->erase(m_Path->begin());

			if(m_Path->empty())
			{
				m_MovementSpeed = 0;
			}
			else
			{
				next = m_Path->at(0);
				auto pos = GetPosition();

				Point newDirection = next - pos;
				newDirection = newDirection.GetNormalizedPoint();

				if(m_Owner != NULL)
				{
					m_Owner->setLookAt2D(newDirection.X, newDirection.Y);
				}
				else
				{
					SetDirection(newDirection.X, newDirection.Y);
				}
			}

		}
	}
}
开发者ID:gnub,项目名称:itugameengine,代码行数:44,代码来源:PhysicsModel.cpp

示例2: calcDirection

void MovingObjectModel::calcDirection()
{
	if(m_Path != NULL && !m_Path->empty())
	{
		auto next = m_Path->at(0);

		auto pos = GetPosition();

		Point tempDirection = next - pos;

		tempDirection = tempDirection.GetNormalizedPoint(); 
		if(m_Owner != NULL)
		{
			m_Owner->setLookAt2D(tempDirection.X, tempDirection.Y);
		}
		else
		{
			SetDirection(tempDirection.X, tempDirection.Y);
		}
	}
}
开发者ID:gnub,项目名称:itugameengine,代码行数:21,代码来源:PhysicsModel.cpp

示例3: physicsBox


//.........这里部分代码省略.........
	tempStaticObject = new StaticObjectModel(RECTANGULARSHAPE);
	box1->model =  SINGLETONINSTANCE( MediaManager )->boxModel;
	box1->physicsModel = tempStaticObject;
	box1->physicsModel->InitializeAsRectangle(physicsBox);
	SINGLETONINSTANCE(PhysicsSystem)->AddStaticObject(tempStaticObject);
	box1->SetPos2D(20.0f, 40.0f);
	box1->SetScale(40.0f, 1.0f, 3.0f);

	auto box2 = new Object();
	box2->Name = "Box2";
	box2->model =  SINGLETONINSTANCE( MediaManager )->boxModel;
	tempStaticObject = new StaticObjectModel(RECTANGULARSHAPE);
	box2->physicsModel = tempStaticObject;
	box2->physicsModel->InitializeAsRectangle(physicsBox);
	SINGLETONINSTANCE(PhysicsSystem)->AddStaticObject(tempStaticObject);
	box2->SetPos2D(0.0f, 20.0f);
	box2->SetScale(1.0f, 40.0f, 3.0f);

	auto box3 = new Object();
	box3->Name = "Box3";
	box3->model =  SINGLETONINSTANCE( MediaManager )->boxModel;
	tempStaticObject = new StaticObjectModel(RECTANGULARSHAPE);
	box3->physicsModel = tempStaticObject;
	box3->physicsModel->InitializeAsRectangle(physicsBox);
	SINGLETONINSTANCE(PhysicsSystem)->AddStaticObject(tempStaticObject);
	box3->SetPos2D(40.0f, 20.0f);
	box3->SetScale(1.0f, 40.0f, 3.0f);

	auto box4 = new Object();
	box4->Name = "Box4";
	box4->model =  SINGLETONINSTANCE( MediaManager )->boxModel;
	tempStaticObject = new StaticObjectModel(RECTANGULARSHAPE);
	box4->physicsModel = tempStaticObject;
	box4->physicsModel->InitializeAsRectangle(physicsBox);
	SINGLETONINSTANCE(PhysicsSystem)->AddStaticObject(tempStaticObject);
	box4->SetPos2D(27.0f, 15.0f);
	box4->SetScale(1.0f, 30.0f, 3.0f);

	auto box5 = new Object();
	box5->Name = "Box5";
	box5->model =  SINGLETONINSTANCE( MediaManager )->boxModel;
	tempStaticObject = new StaticObjectModel(RECTANGULARSHAPE);
	box5->physicsModel = tempStaticObject;
	box5->physicsModel->InitializeAsRectangle(physicsBox);
	SINGLETONINSTANCE(PhysicsSystem)->AddStaticObject(tempStaticObject);
	box5->SetPos2D(13.0f, 25.0f);
	box5->SetScale(1.0f, 30.0f, 3.0f);
	

	root->children->push_back(*underground);
	root->children->push_back(*ground);
	
	root->children->push_back(*box);
	root->children->push_back(*box1);
	root->children->push_back(*box2);
	root->children->push_back(*box3);
	root->children->push_back(*box4);
	root->children->push_back(*box5);

	SINGLETONINSTANCE(PhysicsSystem)->SetStaticPathMap();

	Point forward;
	forward.X = 0;
	forward.Y = -1;
	forward = forward.GetNormalizedPoint();

	auto player = new Object();
	SINGLETONINSTANCE(PlayerInteraction)->StartUp(player);

	player->Name = "Player";
	player->model =  SINGLETONINSTANCE( MediaManager )->crazyModel;
	MovingObjectModel* tempMovingObject = new MovingObjectModel(CIRCULARSHAPE, PLAYERTYPE, forward, player);
	player->physicsModel = tempMovingObject;
	Circle circle(Point(0.0f,0.0f),0.5f);
	player->physicsModel->InitializeAsCircle(circle);
	SINGLETONINSTANCE(PhysicsSystem)->AddMovingObject(tempMovingObject);
	player->SetPos2D(15,20);
	player->Rotate(90.0f, 1.0f, 0.0f, 0.0f);
	player->SetForward(0.0f, 1.0f);
	player->setLookAt2D(forward.X,forward.Y);
	
	root->children->push_back(*player);

	player->physicsModel->SetTargetPosition(new Point(50,5));

	auto camera = new Camera();
	camera->Position.SetX(20);
	camera->Position.SetY(5);
	camera->Position.SetZ(50);
	camera->LookAt.SetX(20);
	camera->LookAt.SetY(20);
	camera->LookAt.SetZ(-1);
	camera->Up.SetX(0);
	camera->Up.SetY(1);
	camera->Up.SetZ(0);

	SceneGraphManager *sceneGraph = new SceneGraphManager(camera, root);

	return sceneGraph;
}
开发者ID:gnub,项目名称:itugameengine,代码行数:101,代码来源:SceneData.cpp


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