Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <osg/Geode>
- #include <osg/ShapeDrawable>
- #include <osgViewer/Viewer>
- #include <osgText/Font>
- #include <osgText/Text>
- #include <osg/Geometry>
- using namespace osg;
- using namespace osgViewer;
- using namespace osgText;
- void main(void)
- {
- Viewer *viewer=new Viewer();
- Group *root=new Group();
- //Make a center circle
- Geode *cgeode=new Geode();
- Sphere *csphere=new Sphere(Vec3(0,0,0),0.3);
- ShapeDrawable *cdraw=new ShapeDrawable(csphere);
- cdraw->setColor (Vec4(1,0,1,1));
- cgeode->addDrawable(cdraw);
- root->addChild(cgeode);
- //4 Pilon cylinders
- Geode *cygeode=new Geode();
- Cylinder *cycylinder=new Cylinder(Vec3(1.0f,1.0f,0.0f), 0.01, 2);
- ShapeDrawable *cydraw=new ShapeDrawable(cycylinder);
- cydraw->setColor (Vec4(1,0,0,1));
- cygeode->addDrawable(cydraw);
- cycylinder->setRotation(Quat(0,1,0,0));
- root->addChild(cygeode);
- Geode *cggeode=new Geode();
- Cylinder *cgcylinder=new Cylinder(Vec3(-1.0f,-1.0f,0.0f), 0.01, 2);
- ShapeDrawable *cgdraw=new ShapeDrawable(cgcylinder);
- cgdraw->setColor (Vec4(1,0,0,1));
- cggeode->addDrawable(cgdraw);
- cgcylinder->setRotation(Quat(0,1,0,0));
- root->addChild(cggeode);
- Geode *cgogeode=new Geode();
- Cylinder *cgocylinder=new Cylinder(Vec3(-1.0f,1.0f,0.0f), 0.01, 2);
- ShapeDrawable *cgodraw=new ShapeDrawable(cgocylinder);
- cgodraw->setColor (Vec4(1,0,0,1));
- cgogeode->addDrawable(cgodraw);
- cgocylinder->setRotation(Quat(0,1,0,0));
- root->addChild(cgogeode);
- Geode *crgeode=new Geode();
- Cylinder *crcylinder=new Cylinder(Vec3(1.0f,-1.0f,0.0f), 0.01, 2);
- ShapeDrawable *crdraw=new ShapeDrawable(crcylinder);
- crdraw->setColor (Vec4(1,0,0,1));
- crgeode->addDrawable(crdraw);
- crcylinder->setRotation(Quat(0,1,0,0));
- root->addChild(crgeode);
- //1 Axis FACE
- //Top cylinder
- Geode *cylgeode=new Geode();
- Cylinder *cylcylinder=new Cylinder(Vec3(0.0f,1.0f,1.0f), 0.01, 2);
- ShapeDrawable *cyldraw=new ShapeDrawable(cylcylinder);
- cyldraw->setColor (Vec4(1,0,0,1));
- cylgeode->addDrawable(cyldraw);
- cylcylinder->setRotation(Quat(1,1,1,1));
- root->addChild(cylgeode);
- //Bottom cylinder
- Geode *cylegeode=new Geode();
- Cylinder *cylecylinder=new Cylinder(Vec3(0.0f,-1.0f,1.0f), 0.01, 2);
- ShapeDrawable *cyledraw=new ShapeDrawable(cylecylinder);
- cyledraw->setColor (Vec4(1,0,0,1));
- cylegeode->addDrawable(cyledraw);
- cylecylinder->setRotation(Quat(1,1,1,1));
- root->addChild(cylegeode);
- //Left Side cylinder
- Geode *cylpgeode=new Geode();
- Cylinder *cylpcylinder=new Cylinder(Vec3(1.0f,0.0f,1.0f), 0.01, 2);
- ShapeDrawable *cylpdraw=new ShapeDrawable(cylpcylinder);
- cylpdraw->setColor (Vec4(1,0,0,1));
- cylpgeode->addDrawable(cylpdraw);
- cylpcylinder->setRotation(Quat(0,1,1,0));
- root->addChild(cylpgeode);
- //Right Side cylinder
- Geode *cylrgeode=new Geode();
- Cylinder *cylrcylinder=new Cylinder(Vec3(-1.0f,0.0f,1.0f), 0.01, 2);
- ShapeDrawable *cylrdraw=new ShapeDrawable(cylrcylinder);
- cylrdraw->setColor (Vec4(1,0,0,1));
- cylrgeode->addDrawable(cylrdraw);
- cylrcylinder->setRotation(Quat(0,1,1,0));
- root->addChild(cylrgeode);
- // -1 X AXIS FACE
- //Top cylinder
- Geode *cylsgeode=new Geode();
- Cylinder *cylscylinder=new Cylinder(Vec3(0.0f,1.0f,-1.0f), 0.01, 2);
- ShapeDrawable *cylsdraw=new ShapeDrawable(cylscylinder);
- cylsdraw->setColor (Vec4(1,0,0,1));
- cylsgeode->addDrawable(cylsdraw);
- cylscylinder->setRotation(Quat(1,1,1,1));
- root->addChild(cylsgeode);
- //Bottom cylinder
- Geode *cylfgeode=new Geode();
- Cylinder *cylfcylinder=new Cylinder(Vec3(0.0f,-1.0f,-1.0f), 0.01, 2);
- ShapeDrawable *cylfdraw=new ShapeDrawable(cylfcylinder);
- cylfdraw->setColor (Vec4(1,0,0,1));
- cylfgeode->addDrawable(cylfdraw);
- cylfcylinder->setRotation(Quat(1,1,1,1));
- root->addChild(cylfgeode);
- //Left Side cylinder
- Geode *cylhgeode=new Geode();
- Cylinder *cylhcylinder=new Cylinder(Vec3(1.0f,0.0f,-1.0f), 0.01, 2);
- ShapeDrawable *cylhdraw=new ShapeDrawable(cylhcylinder);
- cylhdraw->setColor (Vec4(1,0,0,1));
- cylhgeode->addDrawable(cylhdraw);
- cylhcylinder->setRotation(Quat(0,1,1,0));
- root->addChild(cylhgeode);
- //Right Side cylinder
- Geode *cylvgeode=new Geode();
- Cylinder *cylvcylinder=new Cylinder(Vec3(-1.0f,0.0f,-1.0f), 0.01, 2);
- ShapeDrawable *cylvdraw=new ShapeDrawable(cylvcylinder);
- cylvdraw->setColor (Vec4(1,0,0,1));
- cylvgeode->addDrawable(cylvdraw);
- cylvcylinder->setRotation(Quat(0,1,1,0));
- root->addChild(cylvgeode);
- // 1 x AXIS face
- //Make a 2nd circle
- Geode *tgeode=new Geode();
- Sphere *tsphere=new Sphere(Vec3(1,0,1),0.02);
- ShapeDrawable *tdraw=new ShapeDrawable(tsphere);
- tdraw->setColor (Vec4(1,0,1,1));
- tgeode->addDrawable(tdraw);
- root->addChild(tgeode);
- //Make a 3rd circle
- Geode *rgeode=new Geode();
- Sphere *rsphere=new Sphere(Vec3(-1,0,1),0.02);
- ShapeDrawable *rdraw=new ShapeDrawable(rsphere);
- rdraw->setColor (Vec4(1,0,1,1));
- rgeode->addDrawable(rdraw);
- root->addChild(rgeode);
- //Make a 4th circle
- Geode *dgeode=new Geode();
- Sphere *dsphere=new Sphere(Vec3(1,1,1),0.02);
- ShapeDrawable *ddraw=new ShapeDrawable(dsphere);
- ddraw->setColor (Vec4(1,0,1,1));
- dgeode->addDrawable(ddraw);
- root->addChild(dgeode);
- //Make a 5th circle
- Geode *ygeode=new Geode();
- Sphere *ysphere=new Sphere(Vec3(-1,1,1),0.02);
- ShapeDrawable *ydraw=new ShapeDrawable(ysphere);
- ydraw->setColor (Vec4(1,0,1,1));
- ygeode->addDrawable(ydraw);
- root->addChild(ygeode);
- //Make a 6th circle
- Geode *kgeode=new Geode();
- Sphere *ksphere=new Sphere(Vec3(1,-1,1),0.02);
- ShapeDrawable *kdraw=new ShapeDrawable(ksphere);
- kdraw->setColor (Vec4(1,0,1,1));
- kgeode->addDrawable(kdraw);
- root->addChild(kgeode);
- //Make a 7th circle
- Geode *egeode=new Geode();
- Sphere *esphere=new Sphere(Vec3(-1,-1,1),0.02);
- ShapeDrawable *edraw=new ShapeDrawable(esphere);
- edraw->setColor (Vec4(1,0,1,1));
- egeode->addDrawable(edraw);
- root->addChild(egeode);
- // -1 X axis face
- //Make a 2nd circle
- Geode *jgeode=new Geode();
- Sphere *jsphere=new Sphere(Vec3(1,0,-1),0.02);
- ShapeDrawable *jdraw=new ShapeDrawable(jsphere);
- jdraw->setColor (Vec4(1,0,1,1));
- jgeode->addDrawable(jdraw);
- root->addChild(jgeode);
- //Make a 3rd circle
- Geode *sgeode=new Geode();
- Sphere *ssphere=new Sphere(Vec3(-1,0,-1),0.02);
- ShapeDrawable *sdraw=new ShapeDrawable(ssphere);
- sdraw->setColor (Vec4(1,0,1,1));
- sgeode->addDrawable(sdraw);
- root->addChild(sgeode);
- //Make a 4th circle
- Geode *ogeode=new Geode();
- Sphere *osphere=new Sphere(Vec3(1,1,-1),0.02);
- ShapeDrawable *odraw=new ShapeDrawable(osphere);
- odraw->setColor (Vec4(1,0,1,1));
- ogeode->addDrawable(odraw);
- root->addChild(ogeode);
- //Make a 5th circle
- Geode *hgeode=new Geode();
- Sphere *hsphere=new Sphere(Vec3(-1,1,-1),0.02);
- ShapeDrawable *hdraw=new ShapeDrawable(hsphere);
- hdraw->setColor (Vec4(1,0,1,1));
- hgeode->addDrawable(hdraw);
- root->addChild(hgeode);
- //Make a 6th circle
- Geode *ugeode=new Geode();
- Sphere *usphere=new Sphere(Vec3(1,-1,-1),0.02);
- ShapeDrawable *udraw=new ShapeDrawable(usphere);
- udraw->setColor (Vec4(1,0,1,1));
- ugeode->addDrawable(udraw);
- root->addChild(ugeode);
- //Make a 7th circle
- Geode *mgeode=new Geode();
- Sphere *msphere=new Sphere(Vec3(-1,-1,-1),0.02);
- ShapeDrawable *mdraw=new ShapeDrawable(msphere);
- mdraw->setColor (Vec4(1,0,1,-1));
- mgeode->addDrawable(mdraw);
- root->addChild(mgeode);
- // Displaying the scene in a window of a given size
- viewer->setSceneData(root);
- viewer->setUpViewInWindow(100,100,512,512);
- viewer->run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement