OsgScreenSpaceQuadRepresentation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, 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_OSGSCREENSPACEQUADREPRESENTATION_H
#define SURGSIM_GRAPHICS_OSGSCREENSPACEQUADREPRESENTATION_H
#include "SurgSim/DataStructures/OptionalValue.h"
#include "SurgSim/Graphics/OsgRepresentation.h"
#include "SurgSim/Graphics/OsgUniform.h"
#include "SurgSim/Graphics/Representation.h"
#include "SurgSim/Graphics/ScreenSpaceQuadRepresentation.h"
#include <array>
#include <osg/Vec3>
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4250)
#endif
namespace osg
{
class Projection;
class Geode;
class Geometry;
}
namespace SurgSim
{
namespace Graphics
{
class UniformBase;
class Texture;
class OsgTexture2d;
class OsgTextureRectangle;
class OsgScreenSpaceQuadRepresentation : public OsgRepresentation, public ScreenSpaceQuadRepresentation
{
public:
explicit OsgScreenSpaceQuadRepresentation(const std::string& name);
~OsgScreenSpaceQuadRepresentation();
virtual void setLocation(double x, double y);
virtual void getLocation(double* x, double* y);
void setSize(double width, double height) override;
void getSize(double* width, double* height) const override;
bool setTexture(std::shared_ptr<Texture> texture) override;
bool setTexture(std::shared_ptr<OsgTexture2d> texture);
bool setTexture(std::shared_ptr<OsgTextureRectangle> texture);
void setTransparent(bool value);
bool isTransparent();
protected:
void doUpdate(double dt) override;
bool doInitialize() override;
private:
osg::ref_ptr<osg::Geode> m_geode;
osg::ref_ptr<osg::Geometry> m_geometry;
osg::ref_ptr<osg::Projection> m_projection;
osg::Vec3 m_scale;
int m_displayWidth;
int m_displayHeight;
void setTextureCoordinates(float left, float bottom, float right, float top);
bool replaceUniform(const std::string& name, std::shared_ptr<SurgSim::Graphics::UniformBase> newUniform);
std::shared_ptr<OsgUniform<std::shared_ptr<OsgTexture2d>>> m_textureUniform;
std::shared_ptr<OsgUniform<std::shared_ptr<OsgTextureRectangle>>> m_rectangleTextureUniform;
SurgSim::DataStructures::OptionalValue<int> m_texureType;
};
}; // Graphics
}; // SurgSim
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_displayHeight
int m_displayHeight
Definition: OsgScreenSpaceQuadRepresentation.h:130
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_scale
osg::Vec3 m_scale
Size of the quad.
Definition: OsgScreenSpaceQuadRepresentation.h:125
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_texureType
SurgSim::DataStructures::OptionalValue< int > m_texureType
Indicate which type of texture is currently being used.
Definition: OsgScreenSpaceQuadRepresentation.h:150
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_geometry
osg::ref_ptr< osg::Geometry > m_geometry
Local geometry pointer.
Definition: OsgScreenSpaceQuadRepresentation.h:119
SurgSim::DataStructures::OptionalValue< int >
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_displayWidth
int m_displayWidth
Definition: OsgScreenSpaceQuadRepresentation.h:129
ScreenSpaceQuadRepresentation.h
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_textureUniform
std::shared_ptr< OsgUniform< std::shared_ptr< OsgTexture2d > > > m_textureUniform
Uniform to carry the power of two texture, "texture".
Definition: OsgScreenSpaceQuadRepresentation.h:144
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_projection
osg::ref_ptr< osg::Projection > m_projection
Projection matrix, needs to be updated when the view is changed.
Definition: OsgScreenSpaceQuadRepresentation.h:122
Representation.h
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_rectangleTextureUniform
std::shared_ptr< OsgUniform< std::shared_ptr< OsgTextureRectangle > > > m_rectangleTextureUniform
Uniform to carry the rectangle texture "texture".
Definition: OsgScreenSpaceQuadRepresentation.h:147
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation::m_geode
osg::ref_ptr< osg::Geode > m_geode
Local geode to contain geometry.
Definition: OsgScreenSpaceQuadRepresentation.h:116
OsgUniform.h
SurgSim::Graphics::ScreenSpaceQuadRepresentation
A quad to display on the screen in screen space coordinates, use setPose() to set the position but x...
Definition: ScreenSpaceQuadRepresentation.h:36
osg
Definition: OculusView.h:25
OptionalValue.h
OsgRepresentation.h
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
SurgSim::Graphics::OsgScreenSpaceQuadRepresentation
Implements the ScreenSpaceQuadRepresentation, provides the uniform &#39;texture&#39; for the texture that it ...
Definition: OsgScreenSpaceQuadRepresentation.h:53