51 shaderDir +
"ColorUniformPoint.vert",
52 shaderDir +
"Color.frag");
58 int refLen = std::min(scrW, scrH);
68 cs = (float)refLen * 0.01f;
70 float l = (float)refLen * 0.35f;
104 float horizonAngle = std::atan2(horizon.
y, horizon.
x) *
RAD2DEG;
117 ss << std::fixed << std::setprecision(1) << -horizonAngle;
float SLfloat
analog to GLfloat
string SLstring
Redefinition of standard types for platform independence.
Container for general algorithm functions.
Scene node that draws the device's horizon line and tilt angle.
vector< SLVec3f > SLVVec3f
SLVec3< SLfloat > SLVec3f
Encapsulation of a mobile device rotation set by the device's IMU sensor.
SLMat3f rotationAveraged()
void isUsed(SLbool isUsed)
Setter that turns on the device rotation sensor.
Generic Shader Program class inherited from SLGLProgram.
void addUniform1f(SLGLUniform1f *u)
add float uniform
SLGLProgram * _prog
Program drawing the horizon line.
SLTexFont * _font
Font of the angle label, not owned.
void doUpdate() override
Re-aligns the horizon line and refreshes the angle label.
~SLHorizonNode()
Deletes the program, material and meshes created in the constructor.
SLNode * _horizonNode
Child node carrying the line.
SLHorizonNode(SLstring name, SLDeviceRotation *devRot, SLTexFont *font, SLstring shaderDir, int scrW, int scrH)
Builds the horizon line and its text label.
SLMat3f _sRc
Sensor to camera rotation used by the horizon estimation.
SLPolyline * _line
Mesh of the horizon line.
SLDeviceRotation * _devRot
Rotation sensor, not owned.
SLMaterial * _mat
Material of the horizon line.
SLNode * _textNode
Child node carrying the angle text.
void rotation(const T angleDEG, const SLVec3< T > &axis)
Sets the rotation components
Defines a standard CG material with textures and a shader program.
SLNode represents a node in a hierarchical scene graph.
void rotation(const SLQuat4f &rot, SLTransformSpace relativeTo=TS_parent)
void addChild(SLNode *child)
SLNode(const SLstring &name="Node")
Construct a new SLNode::SLNode object.
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
SLPolyline creates a polyline object.
Texture Font class inherits SLGLTexture for alpha blended font rendering.
SLVec2f calcTextSize(const SLstring &text, SLfloat maxWidth=0.0f, SLfloat lineHeightFactor=1.5f)
SLText creates a mesh using a textured font from SLTexFont.
bool estimateHorizon(const SLMat3f &enuRs, const SLMat3f &sRc, SLVec3f &horizon)
static const float RAD2DEG