OsgPlane.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_OSGPLANE_H
17 #define SURGSIM_GRAPHICS_OSGPLANE_H
18 
19 #include <osg/Geode>
20 #include <osg/Geometry>
21 
22 namespace SurgSim
23 {
24 
25 namespace Graphics
26 {
27 
33 class OsgPlane
34 {
35 public:
39  explicit OsgPlane(float length = 1000.0f, float width = 1000.0f) :
40  m_geode(new osg::Geode())
41  {
42  osg::ref_ptr<osg::Geometry> plane = osg::createTexturedQuadGeometry(
43  osg::Vec3(- length / 2.0f, 0.0f, width / 2.0f),
44  osg::Vec3(length, 0.0f, 0.0f),
45  osg::Vec3(0.0f, 0.0f, - width));
47  m_geode->addDrawable(plane);
48  }
49 
51  osg::ref_ptr<osg::Node> getNode() const
52  {
53  return m_geode;
54  }
55 
56 private:
58  osg::ref_ptr<osg::Geode> m_geode;
59 };
60 
61 }; // namespace Graphics
62 
63 }; // namespace SurgSim
64 
65 #endif // SURGSIM_GRAPHICS_OSGPLANE_H
Definition: CompoundShapeToGraphics.cpp:29
osg::ref_ptr< osg::Geode > m_geode
Root OSG node of the plane.
Definition: OsgPlane.h:58
osg::ref_ptr< osg::Node > getNode() const
Returns the root OSG node for the plane to be inserted into the scene-graph.
Definition: OsgPlane.h:51
OsgPlane(float length=1000.0f, float width=1000.0f)
Constructor.
Definition: OsgPlane.h:39
OSG plane geode to be used as a primitive shape The plane is the XZ plane, with normal +Y...
Definition: OsgPlane.h:33
Definition: OculusView.h:25