osgEarth目标选择

osgEarth目标拾取

        本文展示了一种目标选择的方法。通过将osg::Node注册到osgEarth的对象管理器中,利用osgEarth的RTTPicker类以及重写的RTTPicker::Callback类,实现目标的选中,最后利用osgEarth::VirtualProgram类,将拾取的对象高亮显示。

本文主要解决以下问题:

  1. osgEarth::RTTPicker实现目标拾取
  2. RTTPicker::Callback回调解析
  3. osgEarth::VirtualProgram目标高亮显示

目录

  • 1 前言
  • 2 osgEarth::RTTPicker与RTTPicker::Callback实现目标拾取
  • 3 osgEarth::VirtualProgram目标高亮显示

内容

  • 1 前言

        osgEarth中标注之类的鼠标拾取操作和普通的碰撞检测拾取不太一样,PlaceNode和其它的标注类型不是在通常的场景空间中渲染的,而是作为屏幕空间的叠加层来渲染的,不能通过碰撞检测获取求交的对象。

        osgEarth中有一个例子Sample osgearth_pick,演示了如何通过RTTPicker技术实现场景中对象的选取。加入到场景中的矢量和注记都能用鼠标拾取到,但对于普通的模型数据却获取不到。可以通过注册的方式,将加入到场景中的osg::Node进行注册,osgEarth中ObjectIndex类管理着对象的注册,其提供了接口用于加入到场景中的osg::Node进行注册。

  • 2 osgEarth::RTTPicker与RTTPicker::Callback实现目标拾取

        首先osgEarth解析.earth文件从而构建场景,场景中可以有地形、影像、矢量、模型等数据,而本篇文章主要实现对模型数据的拾取;接着将拾取的节点进行注册;然后由鼠标进行目标拾取。

        从外部earth文件导入节点:

<Map name="Demo: simple model layer">

    <Model name="Cow in the Hudson">
        <url>C:/Geoway/SVN/gwEarth/trunk/osgearth/data/streetlight.osgb.(0,0,3.14).trans.100.scale</url>
        <location lat="40.717" long="-74.018"/>
    </Model>

    <viewpoints>
        <viewpoint name="Test" heading="0" lat="40.717" long="-74.018" height="1500" pitch="-90" range="1500" />
    </viewpoints>
</Map>

        如上为.earth文件中的内容,包含两个部分:模型图层和视点图层。模型图层采用Model关键字,其中url字段表示模型的位置路径,location字段表示模型上球的位置和viewpoints图层;视点图层用viewpoints关键字来表示,其包含了 name、heading、lat、long、height、pitch和range七个参数,分别表示图层名称、方位角、位置纬度、经度、高度、俯仰角、范围。

ui::VBox* uiContainer = new ui::VBox();
    uiContainer->setAlign( ui::Control::ALIGN_LEFT, ui::Control::ALIGN_TOP );
    uiContainer->setAbsorbEvents( true );
    uiContainer->setBackColor(0,0,0,0.8);

    uiContainer->addControl( new ui::LabelControl("RTT Picker Test", osg::Vec4(1,1,0,1)) );
    uiContainer->addControl( new ui::ButtonControl("Toggle picker", new TogglePicker(app)) );
    app.fidLabel = new ui::LabelControl("---");
    uiContainer->addControl( app.fidLabel );
    app.nameLabel = uiContainer->addControl( new ui::LabelControl( "---" ) );

    // Load up the earth file.
    osg::Node* node = MapNodeHelper().load( arguments, &app.viewer, uiContainer );

        代码段2为从外部earth文件导入得到osg::Node的代码,得到的osg::Node包含两个子节点,分别为MapNode和Controls::ControlCanvas, ControlCanvas包含四个LabelControl和一个ButtonControl,用来控制对象拾取的开启与关闭,以及对象信息的展示。

        接下来是开启目标拾取功能,同时实现对象的注册:

struct App
{
    App(osg::ArgumentParser& args) : viewer(args), mainView(NULL), 
       mapNode(NULL), picker(NULL), fidLabel(NULL), 
       nameLabel(NULL), highlightUniform(NULL) 
    { }

    osgViewer::CompositeViewer viewer;
    osgViewer::View* mainView;
    osgEarth::MapNode* mapNode;
    osgEarth::Util::RTTPicker* picker;

    ui::LabelControl* fidLabel;
    ui::LabelControl* nameLabel;
    osg::Uniform*     highlightUniform;
};
void startPicker(App& app)
{
    // Note! Must stop and restart threading when removing the picker
    // because it changes the OSG View/Slave configuration.
    app.viewer.stopThreading();

    app.picker = new RTTPicker();
    app.mainView->addEventHandler(app.picker);

	ResistryNodeVisitor rn;
	app.mapNode->accept(rn);

    // add the graph that will be picked.
    app.picker->addChild(app.mapNode);

    // install a callback that controls the picker and listens for hits.
    app.picker->setDefaultCallback(new MyPickCallback(app));

    app.viewer.startThreading();
}

        代码段1为一结构体,主要包含一视图、主视图、MapNode以及Util::RTTPicker;代码段2为开启节点拾取功能,RTTPicker继承自osgGA::GUIEventHandler,可将其作为事件直接加入到视图中;ResistryNodeVisitor为一访问器,实现节点的注册,其核心代码为:osgEarth::Registry::objectIndex()->tagNode(&node, &node); tageNode的英文解释为:

/**
         * Inserts the object into the index, and tags the Node with a uniform containing
         * the object id. Returns the Object ID.
         */

        即将一对象(第二个参数)插入到index表中,同时将 一osg::Uniform对象写入到节点中(第一个参数)。

        最后设置RTTPicker的CallBack。RTTPicker类继承自osgGA::GUIEventHandler,其重写了handle函数,handle函数中调用了runPicks函数,runPicks调用了checkForPickResult函数,checkForPickResult函数调用了RTTPlicker::CallBack中的onHit函数,本文通过重写RTTPicker::CallBack中的onHit()函数实现拾取对象的获取:

struct MyPickCallback : public RTTPicker::Callback
{
    App& _app;
    MyPickCallback(App& app) : _app(app) { }

    void onHit(ObjectID id)
    {
        // First see whether it's a feature:
        FeatureIndex* index = Registry::objectIndex()->get<FeatureIndex>(id).get();
        Feature* feature = index ? index->getFeature( id ) : 0L;

        if ( feature )
        {
            _app.fidLabel->setText( Stringify() << "Feature ID = " << feature->getFID() << " (oid = " << id << ")" );
            _app.nameLabel->setText( Stringify() << "Name = " << feature->getString("name") );
        }

        else
        {
            // Check whether it's an annotation:
            AnnotationNode* anno = Registry::objectIndex()->get<AnnotationNode>(id).get();
            if ( anno )
            {
                _app.fidLabel->setText( Stringify() << "ObjectID = " << id );
                _app.nameLabel->setName( Stringify() << "Name = " << anno->getName() );
            }

            // None of the above.. clear.
            else
            {
                _app.fidLabel->setText( Stringify() << "unknown oid = " << id );
                _app.nameLabel->setText( " " );
            }
        }

        _app.highlightUniform->set( id );
    }

    void onMiss()
    {
        _app.fidLabel->setText( "No pick." );
        _app.nameLabel->setText( " " );
        _app.highlightUniform->set( 0u );
    }

    // pick whenever the mouse moves.
    bool accept(const osgGA::GUIEventAdapter& ea, const osgGA::GUIActionAdapter& aa)
    {
        return ea.getEventType() == ea.PUSH;
    }
};

        其中onHit函数通过objectId获取对应的节点,最后将高亮显示的节点设置为对应的id(_app.highlightUniform->set( id ))。

  • 3 osgEarth::VirtualProgram目标高亮显示

const char* highlightVert =
    "#version " GLSL_VERSION_STR "\n"
    "uniform uint objectid_to_highlight; \n"
    "uint oe_index_objectid;      // Stage global containing object id \n"
    "flat out int selected; \n"
    "void checkForHighlight(inout vec4 vertex) \n"
    "{ \n"
    "    selected = (objectid_to_highlight > 1u && objectid_to_highlight == oe_index_objectid) ? 1 : 0; \n"
    "} \n";

const char* highlightFrag =
    "#version " GLSL_VERSION_STR "\n"
    "flat in int selected; \n"
    "void highlightFragment(inout vec4 color) \n"
    "{ \n"
    "    if ( selected == 1 ) \n"
    "        color.rgb = mix(color.rgb, clamp(vec3(0.5,2.0,2.0)*(1.0-color.rgb), 0.0, 1.0), 0.5); \n"
    "} \n";

void installHighlighter(App& app)
{
    osg::StateSet* stateSet = app.mapNode->getOrCreateStateSet();
    int attrLocation = Registry::objectIndex()->getObjectIDAttribLocation();

    // This shader program will highlight the selected object.
    VirtualProgram* vp = VirtualProgram::getOrCreate(stateSet);
    vp->setFunction( "checkForHighlight",  highlightVert, ShaderComp::LOCATION_VERTEX_CLIP );
    vp->setFunction( "highlightFragment",  highlightFrag, ShaderComp::LOCATION_FRAGMENT_COLORING );

    // Since we're accessing object IDs, we need to load the indexing shader as well:
    Registry::objectIndex()->loadShaders( vp );

    // A uniform that will tell the shader which object to highlight:
    app.highlightUniform = new osg::Uniform("objectid_to_highlight", 0u);
    stateSet->addUniform(app.highlightUniform );
}

        通过VirtualProgram设置节点着色器和片元着色器,实现对特定ID的节点,高亮显示。

        最后完整代码如下:

/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
* Copyright 2020 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

#include <osgEarth/Registry>
#include <osgEarth/ShaderGenerator>
#include <osgEarth/ObjectIndex>
#include <osgEarth/GLUtils>
#include <osgEarth/EarthManipulator>
#include <osgEarth/ExampleResources>
#include <osgEarth/Controls>
#include <osgEarth/RTTPicker>
#include <osgEarth/Feature>
#include <osgEarth/FeatureIndex>
#include <osgEarth/AnnotationNode>

#include <osgEarth/IntersectionPicker>

#include <osgViewer/CompositeViewer>
#include <osgGA/TrackballManipulator>
#include <osg/BlendFunc>

#define LC "[rttpicker] "

using namespace osgEarth;
using namespace osgEarth::Util;

namespace ui = osgEarth::Util::Controls;

//-----------------------------------------------------------------------

//! Application-wide data.
struct App
{
    App(osg::ArgumentParser& args) : viewer(args), mainView(NULL), 
       mapNode(NULL), picker(NULL), fidLabel(NULL), 
       nameLabel(NULL), highlightUniform(NULL) 
    { }

    osgViewer::CompositeViewer viewer;
    osgViewer::View* mainView;
    osgEarth::MapNode* mapNode;
    osgEarth::Util::RTTPicker* picker;

    ui::LabelControl* fidLabel;
    ui::LabelControl* nameLabel;
    osg::Uniform*     highlightUniform;
};


//! Callback that you install on the RTTPicker.
struct MyPickCallback : public RTTPicker::Callback
{
    App& _app;
    MyPickCallback(App& app) : _app(app) { }

    void onHit(ObjectID id)
    {
        // First see whether it's a feature:
        FeatureIndex* index = Registry::objectIndex()->get<FeatureIndex>(id).get();
        Feature* feature = index ? index->getFeature( id ) : 0L;

        if ( feature )
        {
            _app.fidLabel->setText( Stringify() << "Feature ID = " << feature->getFID() << " (oid = " << id << ")" );
            _app.nameLabel->setText( Stringify() << "Name = " << feature->getString("name") );
        }

        else
        {
            // Check whether it's an annotation:
            AnnotationNode* anno = Registry::objectIndex()->get<AnnotationNode>(id).get();
            if ( anno )
            {
                _app.fidLabel->setText( Stringify() << "ObjectID = " << id );
                _app.nameLabel->setName( Stringify() << "Name = " << anno->getName() );
            }

            // None of the above.. clear.
            else
            {
                _app.fidLabel->setText( Stringify() << "unknown oid = " << id );
                _app.nameLabel->setText( " " );
            }
        }

        _app.highlightUniform->set( id );
    }

    void onMiss()
    {
        _app.fidLabel->setText( "No pick." );
        _app.nameLabel->setText( " " );
        _app.highlightUniform->set( 0u );
    }

    // pick whenever the mouse moves.
    bool accept(const osgGA::GUIEventAdapter& ea, const osgGA::GUIActionAdapter& aa)
    {
        return ea.getEventType() == ea.PUSH;
    }
};

//-----------------------------------------------------------------------

// Shaders that will highlight the currently "picked" feature.

const char* highlightVert =
    "#version " GLSL_VERSION_STR "\n"
    "uniform uint objectid_to_highlight; \n"
    "uint oe_index_objectid;      // Stage global containing object id \n"
    "flat out int selected; \n"
    "void checkForHighlight(inout vec4 vertex) \n"
    "{ \n"
    "    selected = (objectid_to_highlight > 1u && objectid_to_highlight == oe_index_objectid) ? 1 : 0; \n"
    "} \n";

const char* highlightFrag =
    "#version " GLSL_VERSION_STR "\n"
    "flat in int selected; \n"
    "void highlightFragment(inout vec4 color) \n"
    "{ \n"
    "    if ( selected == 1 ) \n"
    "        color.rgb = mix(color.rgb, clamp(vec3(0.5,2.0,2.0)*(1.0-color.rgb), 0.0, 1.0), 0.5); \n"
    "} \n";

void installHighlighter(App& app)
{
    osg::StateSet* stateSet = app.mapNode->getOrCreateStateSet();
    int attrLocation = Registry::objectIndex()->getObjectIDAttribLocation();

    // This shader program will highlight the selected object.
    VirtualProgram* vp = VirtualProgram::getOrCreate(stateSet);
    vp->setFunction( "checkForHighlight",  highlightVert, ShaderComp::LOCATION_VERTEX_CLIP );
    vp->setFunction( "highlightFragment",  highlightFrag, ShaderComp::LOCATION_FRAGMENT_COLORING );

    // Since we're accessing object IDs, we need to load the indexing shader as well:
    Registry::objectIndex()->loadShaders( vp );

    // A uniform that will tell the shader which object to highlight:
    app.highlightUniform = new osg::Uniform("objectid_to_highlight", 0u);
    stateSet->addUniform(app.highlightUniform );
}


class ResistryNodeVisitor : public osg::NodeVisitor
{
public:
	ResistryNodeVisitor()
		: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
	{
	}

	~ResistryNodeVisitor()
	{
	}

	void apply(osg::Geometry& node)
	{
		osgEarth::Registry::objectIndex()->tagNode(&node, &node);
		//_geometries.push_back(&node);
		traverse(node);
	}


public:
	/*const std::vector<osg::ref_ptr<osg::PagedLOD> >& pagedlods()
	{
		return _pagedlods;
	}

	const std::vector<osg::ref_ptr<osg::Geometry> >& geometries()
	{
		return _geometries;
	}

	void clear()
	{
		_geometries.clear();
		_pagedlods.clear();
	}*/

private:
	/*std::vector<osg::ref_ptr<osg::Geometry> > _geometries;
	std::vector<osg::ref_ptr<osg::PagedLOD> > _pagedlods;*/
};

//------------------------------------------------------------------------

// Configures a window that lets you see what the RTT camera sees.
//void
//setupRTTView(osgViewer::View* view, osg::Texture* rttTex)
//{
//    view->setCameraManipulator(0L);
//    view->getCamera()->setName( "osgearth_pick RTT view" );
//    view->getCamera()->setViewport(0,0,256,256);
//    view->getCamera()->setClearColor(osg::Vec4(1,1,1,1));
//    view->getCamera()->setProjectionMatrixAsOrtho2D(-.5,.5,-.5,.5);
//    view->getCamera()->setViewMatrixAsLookAt(osg::Vec3d(0,-1,0), osg::Vec3d(0,0,0), osg::Vec3d(0,0,1));
//    view->getCamera()->setProjectionResizePolicy(osg::Camera::FIXED);
//
//    osg::Vec3Array* v = new osg::Vec3Array(6);
//    (*v)[0].set(-.5,0,-.5); (*v)[1].set(.5,0,-.5); (*v)[2].set(.5,0,.5); (*v)[3].set((*v)[2]); (*v)[4].set(-.5,0,.5);(*v)[5].set((*v)[0]);
//
//    osg::Vec2Array* t = new osg::Vec2Array(6);
//    (*t)[0].set(0,0); (*t)[1].set(1,0); (*t)[2].set(1,1); (*t)[3].set((*t)[2]); (*t)[4].set(0,1); (*t)[5].set((*t)[0]);
//
//    osg::Geometry* g = new osg::Geometry();
//    g->setUseVertexBufferObjects(true);
//    g->setUseDisplayList(false);
//    g->setVertexArray( v );
//    g->setTexCoordArray( 0, t );
//    g->addPrimitiveSet( new osg::DrawArrays(GL_TRIANGLES, 0, 6) );
//
//    osg::Geode* geode = new osg::Geode();
//    geode->addDrawable( g );
//
//    osg::StateSet* stateSet = geode->getOrCreateStateSet();
//    stateSet->setDataVariance(osg::Object::DYNAMIC);
//
//    stateSet->setTextureAttributeAndModes(0, rttTex, 1);
//    rttTex->setUnRefImageDataAfterApply( false );
//    rttTex->setResizeNonPowerOfTwoHint(false);
//
//    GLUtils::setLighting(stateSet, 0);
//    stateSet->setMode(GL_CULL_FACE, 0);
//    stateSet->setAttributeAndModes(new osg::BlendFunc(GL_ONE, GL_ZERO), 1);
//    
//    const char* fs =
//    "#version " GLSL_VERSION_STR "\n"
//    "void swap(inout vec4 c) { c.rgba = c==vec4(0)? vec4(1) : vec4(vec3((c.r+c.g+c.b+c.a)/4.0),1); }\n";
//    osgEarth::Registry::shaderGenerator().run(geode);
//    VirtualProgram::getOrCreate(geode->getOrCreateStateSet())->setFunction("swap", fs, ShaderComp::LOCATION_FRAGMENT_COLORING);
//
//    view->setSceneData( geode );
//}

void startPicker(App& app)
{
    // Note! Must stop and restart threading when removing the picker
    // because it changes the OSG View/Slave configuration.
    app.viewer.stopThreading();

    app.picker = new RTTPicker();
    app.mainView->addEventHandler(app.picker);

	ResistryNodeVisitor rn;
	app.mapNode->accept(rn);

    // add the graph that will be picked.
    app.picker->addChild(app.mapNode);

    // install a callback that controls the picker and listens for hits.
    app.picker->setDefaultCallback(new MyPickCallback(app));

    // Make a view that lets us see what the picker sees.
   /* if (app.rttView == NULL)
    {
        app.rttView = new osgViewer::View();
        app.rttView->getCamera()->setGraphicsContext(app.mainView->getCamera()->getGraphicsContext());
        app.rttView->getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
        app.viewer.addView(app.rttView);    
    }
    setupRTTView(app.rttView, app.picker->getOrCreateTexture(app.mainView));
    app.rttView->getCamera()->setNodeMask(~0);*/

    app.viewer.startThreading();
}

void stopPicker(App& app)
{
    // Note! Must stop and restart threading when removing the picker
    // because it changes the OSG View/Slave configuration.
    app.viewer.stopThreading();

    //app.viewer.removeView(app.rttView);
    //app.rttView->getCamera()->setNodeMask(0);
    app.mainView->removeEventHandler(app.picker);
    app.picker = 0L;

    app.viewer.startThreading();
}

struct TogglePicker : public ui::ControlEventHandler
{
    App& _app;
    TogglePicker(App& app) : _app(app) { }
    void onClick(Control* button)
    {
        if (_app.picker == 0L)
            startPicker(_app);
        else
            stopPicker(_app);
    }
};

//-----------------------------------------------------------------------

int
usage(const char* name)
{
    OE_NOTICE 
        << "\nUsage: " << name << " file.earth" << std::endl
        << MapNodeHelper().usage() << std::endl;
    return 0;
}

int
main(int argc, char** argv)
{
    osg::ArgumentParser arguments(&argc,argv);
    if ( arguments.read("--help") )
        return usage(argv[0]);

    App app(arguments);

    app.mainView = new osgViewer::View();
    app.mainView->setUpViewInWindow(30, 30, 1024, 1024, 0);
    app.mainView->getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
    
    app.viewer.addView(app.mainView);

    app.mainView->getDatabasePager()->setUnrefImageDataAfterApplyPolicy( false, false );
    app.mainView->setCameraManipulator( new EarthManipulator() );    

    // Made some UI components:
    ui::VBox* uiContainer = new ui::VBox();
    uiContainer->setAlign( ui::Control::ALIGN_LEFT, ui::Control::ALIGN_TOP );
    uiContainer->setAbsorbEvents( true );
    uiContainer->setBackColor(0,0,0,0.8);

    uiContainer->addControl( new ui::LabelControl("RTT Picker Test", osg::Vec4(1,1,0,1)) );
    uiContainer->addControl( new ui::ButtonControl("Toggle picker", new TogglePicker(app)) );
    app.fidLabel = new ui::LabelControl("---");
    uiContainer->addControl( app.fidLabel );
    app.nameLabel = uiContainer->addControl( new ui::LabelControl( "---" ) );

    // Load up the earth file.
    osg::Node* node = MapNodeHelper().load( arguments, &app.viewer, uiContainer );
	
    if ( node )
    {
        app.mainView->setSceneData( node );

        app.mapNode = MapNode::get(node);

        // start with a picker running
        startPicker(app);

        // Highlight features as we pick'em.
        installHighlighter(app);

        app.mainView->getCamera()->setName( "Main view" );

        return app.viewer.run();
    }
    else
    {
        return usage(argv[0]);
    }
}

        运行的结果如下:


总结:

       本文介绍了osgEarth中目标拾取的用法,通过重写RTTPicker::CallBack,获取拾取的对象,然后借用shader将拾取的对象高亮。本文只介绍了osgEarth目标拾取的用法,接下来会进一步分析其原理,研究RTTPicker类及osgEarth的注册系统。

osgEarth示例分析——osgearth_imageoverlay osgearth覆盖图示例分析 阅读详情

相关推荐

osgEarth的Rex引擎原理分析(四十二)osgEarth::SpatialReference和osgEarth::Profile的关系

目标:(三十六)中的问题102 osgEarth::Profile关注空间范围、初始LOD数目等信息。GeoExtent中有SpatialReference信息,因此通过Profile能获取到SpatialReference信息。每一个高程、影像层都有自己的Profile。 osgEarth/Profile class OSGEARTH_EXPORT Profile : public...

hankern的专栏 1705

osgEarth的Rex引擎原理分析(四十三)osgEarth的Geographic、Geodetic、Geocentric和Project的关系

目标:(三十六)中的103 Geographic采用经纬高,高度是平均海平面高(需要有垂直水准面辅助) Geodetic采用经纬高,高度是相对椭球体的法线高 ECEF(也即Geocentric)采用地心直角坐标系XYZ Project采用投影坐标系 osgEarth/SpatialReference class OSGEARTH_EXPORT SpatialRefere...

hankern的专栏 1987

osgEarth的Rex引擎原理分析(十三)选择信息的作用

目标:(十二)中的问题28 在rex引擎创建时,会创建选择信息结构体SelectionInfo _selectionInfo;该结构体包含了lod切换的距离设置的参数信息,在判断TileNode瓦片是否还能细分时会用到该变量。 osgEarthDrivers/engine_rex/TileNode.cpp bool TileNode::shouldSubDivide(TerrainCulle...

hankern的专栏 1076

由编译osgEarth源码引发的一系列问题(三)利用vcpkg安装osg与OSGEarth

梯子、访问外网服务器、osg编译、osgearth编译

010米粉010的博客 1027

osgEarth的Rex引擎原理分析(一二一)osgEarth::TileRasterizer功能详解

目标:(五十二)中的问题123 本质是一个相机,用于将下面的节点渲染到纹理中。 src\osgEarth\TileRasterizer class OSGEARTH_EXPORT TileRasterizer : public osg::Camera { } rex引擎用到了该节点 src\osgEarthDrivers\engine_rex\RexTerrainEngineNode.cpp void RexTerrainEngineNode::setMap(const Map* map,.

hankern的专栏 563

osgEarth的Rex引擎原理分析(三十八)MapFram和MapInfo的关系

目标:(三十)中的问题89 osgEarth::MapInfo主要用于记录Map的参数配置信息、投影信息(大地、正交、立方体)和高程插值信息。一般从Map生成MapInfo mapInfo(context-&gt;getMap()); osgEarth/MapInfo class OSGEARTH_EXPORT MapInfo { osg::ref_ptr&l...

hankern的专栏 521

OSGEARTH3 实战:SHP矢量文件加载与样式定制全解析

本文全面解析了如何在OSGEARTH3三维地球引擎中加载与定制SHP矢量文件。详细对比了通过.earth配置文件声明式加载与C++代码动态加载两种核心方法,深入探讨了样式定制、贴地渲染、性能优化及常见问题排查,为开发者提供了从入门到实战的完整指南。

cicd6pipeline的博客 900

osgEarth的Rex引擎原理分析(一零四)rex如何在地球上绘制一张图片

目标:(一零三)中的问题186 借鉴例子osgearth_annotation.cpp,这不是直接在瓦片上绘制的,因为它压住了瓦片上的边界线。应当是rex球渲染完成后在渲染的。和绘制一个几何图形,设置几何图形的问题没有什么区别。 osgEarth::Annotation::ImageOverlay* imageOverlay = 0L; osg::ref_ptr<osg...

hankern的专栏 1324

osg、osgearth简介及学习环境准备(一)

OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns 为了对滑翔机的飞行进行模拟,对openGL的库进行了封装,osg的雏形就这样诞生了,1998年Don burns 遇到了同样喜欢滑翔机和计算机图形学的Robert Osfield ,从此Robert Osfield加入了osg小组的开发并一直担任开发小组的组长。OSG广泛应用于飞行仿真等领域,包括Flightgear,及美国军方投资的仿真项目Delta3d等。三维场景图渲染与调度引擎。

抬头做人低头做事 3117

OsgEarth中IntersectionPicker

osg碰撞检测进阶 osgUtil封装了RayIntersector、LineSegmentIntersector、PlaneIntersector求交器,分别用于三维空间射线、线段、平面与场景osg::Node的求交,本文主要分析三种求交器应用的代码、进而分析其内部实现的代码结构,同时分析其求交的特点及应用场景,并实现一种针对点云的碰撞检测求交器。 目录 1 平面求交器的应用及分析 2 osg实现点云的碰撞检测 内容 1 平面求交器的应用及分析 osg中求交...

CPWWHSU的博客 5056

Claude Code vs Codex

Claude Code 提供了一个生产就绪(production-ready)的实现,包含良好的错误处理、优雅的关闭逻辑、详细注释和文档,以及内置测试。Claude Code 输出了一个可运行的 Next.js + TypeScript 前端,但错过了一些设计里的黄色主题元素;Codex 则生成自己的版本,没有导出设计中的图片,也没严格遵照设计主题。Codex 完成同样功能,但更简洁直接,文档和注释少一些但功能达标。任务都用同样的提示,使用 TypeScript 实现,并在一天内完成。

weixin_49869937的博客 2403

华为/H3C/锐捷交换机配置命令对比表:一张图搞定VLAN划分与端口设置

本文详细对比了华为、H3C、锐捷三大品牌交换机在VLAN划分与端口设置中的配置命令差异,提供从基础配置到高级功能的横向对比表,帮助网络工程师快速掌握多品牌设备混用环境下的配置技巧,提升工作效率。

rust6ferris的博客 709

从3dB定向耦合器到双圆极化天线:在HFSS里玩转相位差90°的馈电艺术

本文详细介绍了在HFSS中设计3dB定向耦合器与双圆极化天线的关键技术,重点解析了90°相位差生成原理及馈电网络设计。通过HFSS仿真工具,实现从定向耦合器到完整天线系统的集成,优化阵列天线性能,适用于卫星通信和雷达系统。

weixin_33717117的博客 561

Type-C连接中的CC引脚:Rp与Rd电阻的识别与供电模式选择

本文深入解析Type-C接口中CC引脚的核心功能,包括Rp与Rd电阻的识别原理及供电模式选择机制。通过详细的分压计算和实战案例,揭示Type-C设备如何通过CC引脚实现方向检测、角色识别和供电协商,为硬件设计提供关键指导。

weixin_30616969的博客 348

QT项目实战:如何在正点原子Linux开发板上集成CVR-100UC身份证阅读器(附完整代码)

本文详细介绍了在正点原子Linux开发板上集成CVR-100UC身份证阅读器的完整实战流程。内容涵盖驱动适配、库文件部署、QT项目框架搭建、核心功能封装以及界面集成,并提供了完整的代码示例,帮助开发者快速实现嵌入式环境下的身份证信息读取功能。

yyy34的博客 266

完美解决Iframe嵌入帆软报表出现跨域cookie写不进去的问题

那报表后续的请求如何加上这个fine_auth_token,通过观察,我们发现,如果给报表url上加上fine_auth_token,后续的请求中的Refer也会有这个fine_auth_token。我们可以这样想,如果帆软内部获取token,如果从cookie中获取不到,就从url上获取,如果url上也获取不到,那么就从请求Refer请求头中获取也可以拿到这个token了。从上面看到,如果从cookie中没有获取到,就从请求头中获取,还是没有就从paramter中获取。

帆软爱好者的专栏 4073

手把手教你学Simulink--电机控制架构与算法实现​场景示例:基于Simulink的电机速度环PID调节仿真

本文带你完成了电机速度环PID参数的科学整定,实现了:✅ 理解了速度环的级联系统特性与关键参数影响工程整定法(理论初值)系统辨识法(参数未知时)✅ PID Tuner自动调参(推荐!自动调参兼具快速性与鲁棒性✅ 学会了前馈补偿抗饱和等工程实用技巧。

MHD0815的博客 655

C/C++李峋同款跳动的爱心代码(完整代码)

C++语言实现出李峋同款跳动的爱心的完整代码。

AIGC 10万+

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

上一篇: osgconv 工具使用
下一篇: osg碰撞检测进阶
CHPCWWHSU
博客等级 码龄12年 555粉丝 95原创
评论 6
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CHPCWWHSU

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值