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


C++ IScene::IntersectRayWithTerrain方法代码示例

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


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

示例1: MouseDrag

bool TwoAxisTraslationGizmo::MouseDrag(const int &x0, const int &y0, const int &x1, const int &y1, const cpw::MouseButtonsState &mbs)
{
  IScene *scene = cpw::ApplicationScene::GetInstance()->GetScene();
  EntityRegistry *entity_reg =EntityRegistry::GetInstance();
  const float dist_mult = 0.0025f;
  float increment = 0.0f;
  float increment_x, increment_y;
  int traslation=0;
	

  increment_y = increment_x = 0.0f;

  if ((GetEntityTarget() == NULL) || (scene == NULL))
    return false;

  Element *entity = (Element *) GetEntityTarget();

  float new_x = entity->GetUtm(0); 
  float new_y = entity->GetUtm(1); 
  float new_z = entity->GetUtm(2);

  cpw::Point3d<double> camera_view = GetCameraView();

  int traslation_x = x1 - x0;
  int traslation_y = y1 - y0;

  if ((traslation_x == 0) && (traslation_y == 0))
    return false;
	
  float distance = cpw::Math::DistanceBetweenTwoPoints(cpw::Point3d<double>(new_x, new_y, new_z), GetCameraPos());

  cpw::Point3d<float> ip;

  GetNavigatorManager()->GetFocusedOrFirstNavigator()->SetKeepMouseInsideCanvas(false);

  //if (!GetNavigatorManager()->GetFocusedOrFirstNavigator()->IntersectMouseWithScene(x1, y1, ix, iy, iz))
  if (entity->GetAdjustToTerrainHeight())
    {
      if (!GetNavigatorManager()->GetFocusedOrFirstNavigator()->IntersectMouseWithScene2(x1, y1, ip))
	{
	  /*std::stringstream cc;
	    cc << "collision failed " << x1 << ", " << y1;
	    if (cpw::ApplicationLog::GetInstance()->GetLogger() != NULL)
	    cpw::ApplicationLog::GetInstance()->GetLogger()->NewLogMessage(cc.str());*/
	
	  return false;
	}
    }
  else
    {
      if (!GetNavigatorManager()->GetFocusedOrFirstNavigator()->IntersectMouseWithHorizontalPlane(x1, y1, ip, entity->GetUtm(2)))
	return false;
    }

  new_x = ip.x;
  new_y = ip.y;
  //new_x = ix;
  //new_y = iy;
	
  //check if we should intersect against the terrain
  if (entity->GetAdjustToTerrainHeight() || entity->GetAllowUnderTerrain())
    {
      cpw::Point3d<float> i_point;
      if (scene->IntersectRayWithTerrain(cpw::Point3d<float>(new_x, new_y, 10000.0f),
					 cpw::Point3d<float>(new_x, new_y, -10000.0f),
					 i_point, true))
	{
	  if (entity->GetAllowUnderTerrain())
	    {
	      if (new_z < i_point.z)
		new_z = i_point.z;
	    }

	  if (entity->GetAdjustToTerrainHeight())
	    new_z = i_point.z;
	}
    }
	
  entity->SetUtm(new_x, new_y, new_z);
	
  entity->GraphicUpdate();
	
  IHandler::AdaptHandlerAndBrothersToModel();	
	
  return true;
}
开发者ID:BackupTheBerlios,项目名称:rvzware,代码行数:86,代码来源:TwoAxisTraslationGizmo.cpp


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