OsgUnitCylinder.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_OSGUNITCYLINDER_H
17 #define SURGSIM_GRAPHICS_OSGUNITCYLINDER_H
18 
19 #include <osg/Geode>
20 #include <osg/Shape>
21 #include <osg/ShapeDrawable>
22 
23 namespace SurgSim
24 {
25 
26 namespace Graphics
27 {
28 
33 {
34 public:
37  m_geode(new osg::Geode())
38  {
39  osg::ref_ptr<osg::Cylinder> unitCylinder = new osg::Cylinder(osg::Vec3(0.0, 0.0, 0.0), 1.0, 1.0);
40  osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(unitCylinder);
41  m_geode->addDrawable(drawable);
42  m_geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
43  }
44 
46  osg::ref_ptr<osg::Node> getNode() const
47  {
48  return m_geode;
49  }
50 
51 private:
53  osg::ref_ptr<osg::Geode> m_geode;
54 };
55 
56 }; // namespace Graphics
57 
58 }; // namespace SurgSim
59 
60 #endif // SURGSIM_GRAPHICS_OSGUNITCYLINDER_H
SurgSim::Graphics::OsgUnitCylinder::getNode
osg::ref_ptr< osg::Node > getNode() const
Returns the root OSG node for the plane to be inserted into the scene-graph.
Definition: OsgUnitCylinder.h:46
osg
Definition: OculusView.h:25
SurgSim::Graphics::OsgUnitCylinder::OsgUnitCylinder
OsgUnitCylinder()
Constructor.
Definition: OsgUnitCylinder.h:36
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgUnitCylinder
OSG unit cylinder geode to be used as a primitive shape The cylinder is located at (0,...
Definition: OsgUnitCylinder.h:32
SurgSim::Graphics::OsgUnitCylinder::m_geode
osg::ref_ptr< osg::Geode > m_geode
Root OSG node of the cylinder.
Definition: OsgUnitCylinder.h:53