OsgRepresentation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_OSGREPRESENTATION_H
#define SURGSIM_GRAPHICS_OSGREPRESENTATION_H
#include <memory>
#include <osg/ref_ptr>
#include "SurgSim/Graphics/Representation.h"
#include "SurgSim/Graphics/OsgUniform.h"
namespace osg
{
class Group;
class Node;
class PositionAttitudeTransform;
class Switch;
}
namespace SurgSim
{
namespace Graphics
{
class OsgMaterial;
class TangentSpaceGenerator;
class UniformBase;
static const int TANGENT_VERTEX_ATTRIBUTE_ID = 6;
static const int BITANGENT_VERTEX_ATTRIBUTE_ID = 7;
static const int DIFFUSE_TEXTURE_UNIT = 0;
static const int NORMAL_TEXTURE_UNIT = 1;
static const int SHADOW_TEXTURE_UNIT = 8;
class OsgRepresentation : public virtual Representation
{
public:
explicit OsgRepresentation(const std::string& name);
virtual ~OsgRepresentation();
osg::ref_ptr<osg::Node> getOsgNode() const;
bool setMaterial(std::shared_ptr<SurgSim::Framework::Component> material) override;
std::shared_ptr<Material> getMaterial() const override;
void clearMaterial() override;
void setDrawAsWireFrame(bool val) override;
bool getDrawAsWireFrame() const override;
void setGenerateTangents(bool value) override;
bool isGeneratingTangents() const override;
void update(double dt) override;
void addUniform(std::shared_ptr<SurgSim::Graphics::UniformBase> uniform);
void addUniform(const std::string& type, const std::string& name, const boost::any& value);
protected:
virtual void doUpdate(double dt);
void setVisible(bool val);
void updateTangents();
osg::ref_ptr<osg::Switch> m_switch;
osg::ref_ptr<osg::PositionAttitudeTransform> m_transform;
osg::ref_ptr<osg::Group> m_materialProxy;
std::shared_ptr<OsgMaterial> m_material;
osg::ref_ptr<TangentSpaceGenerator> m_tangentGenerator;
bool m_drawAsWireFrame;
std::shared_ptr<OsgUniform<SurgSim::Math::Matrix44f>> m_modelMatrixUniform;
};
}; // Graphics
}; // SurgSim
#endif // SURGSIM_GRAPHICS_OSGREPRESENTATION_H
SurgSim::Graphics::OsgRepresentation::m_drawAsWireFrame
bool m_drawAsWireFrame
Indicates if the representation is rendered as a wireframe.
Definition: OsgRepresentation.h:136
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgRepresentation::m_materialProxy
osg::ref_ptr< osg::Group > m_materialProxy
Holder for attributes coming from OsgMaterial.
Definition: OsgRepresentation.h:127
SurgSim::Graphics::OsgRepresentation::m_switch
osg::ref_ptr< osg::Switch > m_switch
Switch used to toggle the visibility of the representation.
Definition: OsgRepresentation.h:121
SurgSim::Graphics::OsgRepresentation::m_transform
osg::ref_ptr< osg::PositionAttitudeTransform > m_transform
Transform used to pose the representation.
Definition: OsgRepresentation.h:124
SurgSim::Graphics::OsgRepresentation::m_modelMatrixUniform
std::shared_ptr< OsgUniform< SurgSim::Math::Matrix44f > > m_modelMatrixUniform
Definition: OsgRepresentation.h:138
Representation.h
OsgUniform.h
SurgSim::Graphics::OsgRepresentation::m_tangentGenerator
osg::ref_ptr< TangentSpaceGenerator > m_tangentGenerator
Visitor to generate tangents.
Definition: OsgRepresentation.h:133
SurgSim::Graphics::Representation
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
osg
Definition: OculusView.h:25
SurgSim::Graphics::OsgRepresentation::m_material
std::shared_ptr< OsgMaterial > m_material
Material defining the visual appearance of the representation.
Definition: OsgRepresentation.h:130
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55