2021年继续进行osg/osgEarth视频教程和书,例子,源码

按照原计划,调试完osg最长的一帧,是转ue4的最低要求。

琢磨了几天,决定继续搞osg/osgearth,原因是:伤其十指不如断其一指。

在公司的代码中,有osgearth的使用,我以为很新鲜,是独门绝技,或者请的外援。结果是osgearth的自带例子,这就尴尬了。说明差的还远。

 

所以要看看视频教程和书籍(osgearth看三维地球引擎设计,focus on 3d terrain和dx9地形),源码也要抄抄最低版本。那些自带例子也要调试下。

最后再调试下osgearth的源码,看看流程。

 

不要慌,步步为营,走深度路线。

 

顺序:

1,osgEarth视频教程+osg/osgearth源码抄写+三维地球引擎设计调试

2,osg视频教程+osg/osgearth源码抄写+三维地球引擎设计调试

3,osg书籍例子+osg/osgearth源码抄写+osgEarth源码调试

4,osg引擎中附带的例子+osg/osgearth源码抄写+osgEarth源码调试

5,osgearth自带例子+osg/osgearth源码抄写+osgEarth源码调试

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一份使用OpenSceneGraph实现Bezier曲线的示例代码: ```cpp #include <osg/Geode> #include <osg/Geometry> #include <osgViewer/Viewer> osg::Vec3Array* createBezierCurve(osg::Vec3Array* points, int numSteps) { osg::Vec3Array* curvePoints = new osg::Vec3Array; for (int i = 0; i < numSteps; i++) { float t = (float)i / (float)(numSteps - 1); // Calculate blending functions float b0 = (1.0f - t) * (1.0f - t) * (1.0f - t); float b1 = 3.0f * t * (1.0f - t) * (1.0f - t); float b2 = 3.0f * t * t * (1.0f - t); float b3 = t * t * t; // Calculate point on curve osg::Vec3 p = b0 * (*points)[0] + b1 * (*points)[1] + b2 * (*points)[2] + b3 * (*points)[3]; curvePoints->push_back(p); } return curvePoints; } int main(int argc, char** argv) { // Set up points for Bezier curve osg::Vec3Array* points = new osg::Vec3Array; points->push_back(osg::Vec3(-1.0f, 0.0f, 0.0f)); points->push_back(osg::Vec3(-0.5f, 1.0f, 0.0f)); points->push_back(osg::Vec3(0.5f, -1.0f, 0.0f)); points->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); // Create geometry for curve osg::Geometry* curveGeom = new osg::Geometry; curveGeom->setVertexArray(createBezierCurve(points, 20)); // Set up color array for curve osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f)); curveGeom->setColorArray(colors); curveGeom->setColorBinding(osg::Geometry::BIND_OVERALL); // Create line primitive for curve curveGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0, 20)); // Create geode for curve geometry osg::Geode* curveGeode = new osg::Geode; curveGeode->addDrawable(curveGeom); // Create viewer and add curve geode to scene osgViewer::Viewer viewer; viewer.setSceneData(curveGeode); return viewer.run(); } ``` 这个示例代码定义了一个名为createBezierCurve的函数,它接收一个osg::Vec3Array类型的点数组和一个整数,用于指定在曲线上生成多少个点。该函数返回一个osg::Vec3Array类型的数组,包含生成的曲线上的点。 主函数中,我们使用createBezierCurve函数创建了一个Bezier曲线,并将其添加到一个osg::Geometry对象中。我们还定义了一个osg::Vec4Array类型的颜色数组,用于指定曲线的颜色。最后,我们创建一个osg::Geode对象,并将曲线的osg::Geometry对象添加到其中。我们将osg::Geode对象作为场景数据传递给osgViewer::Viewer对象,这样就可以在窗口中显示曲线了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值