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


C++ Viewpoint类代码示例

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


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

示例1: IsVisible

/*
 * Returns true if the given point is visible from the given viewpoint.
 *
 * A point is visible if it will be on screen, and if it is not occluded by
 * other objects.
 *
 * Input:
 *   point: The point whose visibility we want to check.
 *   viewpoint: The viewpoint to check from.
 *
 * Returns: True if the point is visible from the viewpoint.
 */
bool VisibilityChecker::IsVisible(const Ogre::Vector3& point,
                                  const Viewpoint& viewpoint) {
  float screen_x;
  float screen_y;
  auto old_position = camera_->getPosition();
  auto old_direction = camera_->getDirection();
  camera_->setPosition(viewpoint.position());
  camera_->lookAt(viewpoint.focus());
  GetScreenPosition(point, &screen_x, &screen_y);
  bool result = false;
  if (IsOnScreen(screen_x, screen_y)) {
    Ogre::Ray ray;
    camera_->getCameraToViewportRay(screen_x, screen_y, &ray);
    Ogre::Vector3 hit;
    if (RaycastAABB(ray, &hit)) {
      auto dist = point.distance(hit);
      if (dist < kOcclusionThreshold) {
        result = true;
      } else { // Hit something, but too far away from the target.
        result = false;
      }
    } else {
      // No hits. The ray should hit the target, but if it doesn't, that usually
      // indicates visibility. This is because if the target is occluded, the
      // ray is likely to have hit the occluding object.
      result = true;
    }
  } else { // Not on screen
    result= false;
  }
  camera_->setPosition(old_position);
  camera_->setDirection(old_direction);
  return result;
}
开发者ID:jstnhuang,项目名称:autocp,代码行数:46,代码来源:visibility.cpp

示例2: setScale

void RGLView::setScale(double* src)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    viewpoint->setScale(src);

    View::update();
}
开发者ID:jefferis,项目名称:rgl,代码行数:8,代码来源:rglview.cpp

示例3: setUserMatrix

void RGLView::setUserMatrix(double* src)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    viewpoint->setUserMatrix(src);

    View::update();
}
开发者ID:jefferis,项目名称:rgl,代码行数:8,代码来源:rglview.cpp

示例4: polarBegin

void RGLView::polarBegin(int mouseX, int mouseY)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    camBase = viewpoint->getPosition();

    dragBase = screenToPolar(width,height,mouseX,height-mouseY);

}
开发者ID:jefferis,项目名称:rgl,代码行数:9,代码来源:rglview.cpp

示例5: find_map_rect

SDL_Rect find_map_rect(Idevice& input, Viewpoint& camera)
{
    SDL_Rect tilerect;
    int tilex, tiley;
    tilex = (input.get_x() + camera.get_x()) / TILEW;
    tiley = (input.get_y() + camera.get_y()) / TILEH;
    tilerect.x = tilex * TILEW; tilerect.y = tiley * TILEH;
    tilerect.w = TILEW; tilerect.h = TILEH;
    return tilerect;
}
开发者ID:calebsmith,项目名称:Dungeon-Epic,代码行数:10,代码来源:logic.cpp

示例6: buttonPress

void RGLView::buttonPress(int button, int mouseX, int mouseY)
{
    Viewpoint* viewpoint = scene->getViewpoint();
    if ( viewpoint->isInteractive() ) {
        if (!drag) {
            drag = button;
            windowImpl->captureMouse(this);
            (this->*ButtonBeginFunc[button-1])(mouseX,mouseY);
        }
    }
}
开发者ID:jefferis,项目名称:rgl,代码行数:11,代码来源:rglview.cpp

示例7: oneAxisUpdate

void RGLView::oneAxisUpdate(int mouseX, int mouseY)
{
	Viewpoint* viewpoint = scene->getViewpoint();

  	rotCurrent = screenToVector(width,height,mouseX,height/2);

	windowImpl->beginGL();
	viewpoint->mouseOneAxis(rotBase,rotCurrent,axis[drag-1]);
	windowImpl->endGL();

	View::update();
}
开发者ID:jefferis,项目名称:rgl,代码行数:12,代码来源:rglview.cpp

示例8: trackballUpdate

void RGLView::trackballUpdate(int mouseX, int mouseY)
{
	Viewpoint* viewpoint = scene->getViewpoint();

  	rotCurrent = screenToVector(width,height,mouseX,height-mouseY);

	windowImpl->beginGL();
	viewpoint->updateMouseMatrix(rotBase,rotCurrent);
	windowImpl->endGL();

	View::update();
}
开发者ID:jefferis,项目名称:rgl,代码行数:12,代码来源:rglview.cpp

示例9: getValue

void
KML_Feature::build( xml_node<>* node, KMLContext& cx, osg::Node* working )
{
    KML_Object::build(node, cx, working);

    // subclass feature is built; now add feature level data if available
    if ( working )
    {
        // parse the visibility to show/hide the item by default:
		std::string visibility = getValue(node, "visibility");
        if ( !visibility.empty() )
            working->setNodeMask( as<int>(visibility, 1) == 1 ? ~0 : 0 );

        // parse a "LookAt" element (stores a viewpoint)
        AnnotationData* anno = getOrCreateAnnotationData(working);
        
        anno->setName( getValue(node, "name") );
        anno->setDescription( getValue(node, "description") );

        xml_node<>* lookat = node->first_node("lookat", 0, false);
        if ( lookat )
        {
            Viewpoint vp;

            vp.focalPoint() = GeoPoint(
                cx._srs.get(),
				as<double>(getValue(lookat, "longitude"), 0.0),
				as<double>(getValue(lookat, "latitude"), 0.0),
				as<double>(getValue(lookat, "altitude"), 0.0),
                ALTMODE_ABSOLUTE );

            vp.heading() =  as<double>(getValue(lookat, "heading"), 0.0);
            vp.pitch()   = -as<double>(getValue(lookat, "tilt"), 45.0),
            vp.range()   =  as<double>(getValue(lookat, "range"), 10000.0);

            anno->setViewpoint( vp );
        }

        xml_node<>* extdata = node->first_node("extendeddata", 0, false);
        if ( extdata )
        {
            xml_node<>* data = extdata->first_node("data", 0, false);
            if ( data )
            {
			    for (xml_node<>* n = data->first_node(); n; n = n->next_sibling())
			    {
    				working->setUserValue(getValue(n, "name"), getValue(n, "value"));
			    }
            }
        }
    }
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:52,代码来源:KML_Feature.cpp

示例10: polarUpdate

void RGLView::polarUpdate(int mouseX, int mouseY)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    dragCurrent = screenToPolar(width,height,mouseX,height-mouseY);

    PolarCoord newpos = camBase - ( dragCurrent - dragBase );

    newpos.phi = clamp( newpos.phi, -90.0f, 90.0f );

    viewpoint->setPosition( newpos );
    View::update();
}
开发者ID:jefferis,项目名称:rgl,代码行数:13,代码来源:rglview.cpp

示例11: adjustZoomUpdate

void RGLView::adjustZoomUpdate(int mouseX, int mouseY)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    int dy = mouseY - zoomBaseY;

    float zoom = clamp ( viewpoint->getZoom() * exp(-dy*ZOOM_PIXELLOGSTEP), ZOOM_MIN, ZOOM_MAX);
    viewpoint->setZoom(zoom);

    View::update();

    zoomBaseY = mouseY;
}
开发者ID:jefferis,项目名称:rgl,代码行数:13,代码来源:rglview.cpp

示例12: adjustFOVUpdate

void RGLView::adjustFOVUpdate(int mouseX, int mouseY)
{
    Viewpoint* viewpoint = scene->getViewpoint();

    int dy = mouseY - fovBaseY;

    float py = ((float)dy/(float)height) * 180.0f;

    viewpoint->setFOV( viewpoint->getFOV() + py );

    View::update();

    fovBaseY = mouseY;
}
开发者ID:jefferis,项目名称:rgl,代码行数:14,代码来源:rglview.cpp

示例13: vp0

void ViewpointProvider::flyTo()
{
	if ( m_refManipulator == NULL )
	{
		return;
	}

	Viewpoint currentVP = m_refManipulator->getViewpoint();
	osgEarth::GeoPoint vp0( currentVP.getSRS(), currentVP.getFocalPoint(), osgEarth::ALTMODE_ABSOLUTE );
	osgEarth::GeoPoint vp1( this->getSRS(), this->getFocalPoint(), osgEarth::ALTMODE_ABSOLUTE );
	double distance = vp0.distanceTo( vp1 );
	double duration = osg::clampBetween( distance / VP_METERS_PER_SECOND, VP_MIN_DURATION, VP_MAX_DURATION );
	m_refManipulator->setViewpoint( *this, duration );
}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:14,代码来源:ViewpointProvider.cpp

示例14: rgl_getFOV

void rgl_getFOV(int* successptr, double* fov)
{
  int success = RGL_FAIL;
  Device* device = deviceManager->getAnyDevice();

  if ( device ) {
    RGLView* rglview = device->getRGLView();
    Scene* scene = rglview->getScene();
    Viewpoint* viewpoint = scene->getViewpoint();
    *fov = viewpoint->getFOV();
    success = RGL_SUCCESS;
  }
  *successptr = success;
}
开发者ID:jefferis,项目名称:rgl,代码行数:14,代码来源:api.cpp

示例15: rgl_getZoom

void rgl_getZoom(int* successptr, double* zoom)
{
  int success = RGL_FAIL;
  Device* device;

  if (deviceManager && (device = deviceManager->getAnyDevice())) {

    RGLView* rglview = device->getRGLView();
    Scene* scene = rglview->getScene();
    Viewpoint* viewpoint = scene->getViewpoint();
    *zoom = viewpoint->getZoom();
    success = RGL_SUCCESS;
  }
  *successptr = success;
}
开发者ID:jefferis,项目名称:rgl,代码行数:15,代码来源:api.cpp


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