This tutorial was implemented with OpenSuse 42.2, Netbean IDE 8.2 C++, OpenSceneGraph-3.0.1
Before start this tutorial, you need to compile the OSG source or install the binaries.
If you want to know on how to compile it, you can follow this guidance
for Linux OpenSuse 42.2 compile with CodeBlocks
for Windows 10 compile with Visual Studio 2010
Let's start
Please open your Netbean IDE for C++ and create New Project (Ctrl+Shift+N)
Select Categories: C/C++ and Projects: C/C++ Application then click Next.
Enter your Project Name: HelloWorld then click Finish.
Please copy paste this code into your main.cpp file
#include <cstdlib>
#include <iostream>
#include <osgViewer/Viewer>
#include <osg/ShapeDrawable>
using namespace std;
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> root (new osg::Group);
osg::ref_ptr<osg::Geode> myshapegeode (new osg::Geode);
osg::ref_ptr<osg::Capsule> myCapsule (new osg::Capsule(osg::Vec3f(),1,2));
osg::ref_ptr<osg::ShapeDrawable> capsuledrawable (new
osg::ShapeDrawable(myCapsule.get()));
myshapegeode->addDrawable(capsuledrawable.get());
root->addChild(myshapegeode.get());
viewer.setSceneData( root.get() );
return (viewer.run());
}
Next step, we need to configure the project properties by right click the project and select properties.
Under Categories: C++ compiler, please add Include Directories: ../../osg/osgBuild/include
in my case, I have built in /home/osg/osgBuild/include then click Apply. Please refer to picture as below:
Under Categories: Linker, please add
Additional Library Directories: ../../osg/osgBuild/lib In my case, I have built in /home/osg/osgBuild/lib
Libraries: Open Threads, osg, osgDB, osgGA, osgUtil, osgViewer then click OK --> click OK
Result as shown as picture below
Then run project by pressing F6 and if you are successfully, you will get capsule picture shown as below
That's all and Hope you enjoy this tutorial. Thank you.
Other Topics:
How to build NGINX RTMP module, Setup Live Streaming with NGINX RTMP module, Publishing Stream with Open Broadcaster Software (OBS), Create Adaptive Streaming with NGINX RTMP, Implementing Filtergraph in Streaming with NGINX RTMP, How to Implement Running Text in Streaming with NGINX RTMP, How to build OpenSceneGraph with Code::Blocks, How to build OpenSceneGraph with Visual Studio 2010, Building Geometry Model, How to run OpenSceneGraph with Netbean IDE 8.2 C++, Rendering Basic Shapes, Using OSG Node to Load 3D Object Model, Rendering 3D Simulator with OpenSceneGraph, How to compile wxWidgets with Visual Studio 2010
No comments:
Post a Comment