![]() |
SLProject
4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
Scene node that visualises the horizon estimated from the device rotation. More...
#include <SLHorizonNode.h>
Public Member Functions | |
| SLHorizonNode (SLstring name, SLDeviceRotation *devRot, SLTexFont *font, SLstring shaderDir, int scrW, int scrH) | |
| Builds the horizon line and its text label. More... | |
| ~SLHorizonNode () | |
| Deletes the program, material and meshes created in the constructor. More... | |
| void | doUpdate () override |
| Re-aligns the horizon line and refreshes the angle label. More... | |
Public Member Functions inherited from SLNode | |
| SLNode (const SLstring &name="Node") | |
| Construct a new SLNode::SLNode object. More... | |
| SLNode (SLMesh *mesh, const SLstring &name="Node") | |
| SLNode (SLMesh *mesh, const SLVec3f &translation, const SLstring &name) | |
| ~SLNode () override | |
| virtual void | cull3DRec (SLSceneView *sv) |
| virtual void | cullChildren3D (SLSceneView *sv) |
| Initializer function to call SLNode::cull3DRec recursively. More... | |
| virtual void | cull2DRec (SLSceneView *sv) |
| virtual bool | hitRec (SLRay *ray) |
| virtual void | statsRec (SLNodeStats &stats) |
| virtual SLNode * | copyRec () |
| virtual SLAABBox & | updateAABBRec (SLbool updateAlsoAABBinOS) |
| virtual void | dumpRec () |
| void | setDrawBitsRec (SLuint bit, SLbool state) |
| void | setPrimitiveTypeRec (SLGLPrimitiveType primitiveType) |
| virtual void | addMesh (SLMesh *mesh) |
| virtual void | drawMesh (SLSceneView *sv) |
| Draws the single mesh. More... | |
| bool | removeMesh () |
| Returns true if a mesh was assigned and set it to nullptr. More... | |
| bool | removeMesh (SLMesh *mesh) |
| Returns true if the passed mesh was assigned and sets it to nullptr. More... | |
| SLint | numChildren () |
| void | addChild (SLNode *child) |
| bool | insertChild (SLNode *insertC, SLNode *afterC) |
| void | deleteChildren () |
| bool | deleteChild () |
| bool | deleteChild (SLNode *child) |
| bool | deleteChild (const SLstring &name) |
| bool | removeChild (SLNode *child) |
| remove child from vector of children. Removes false if not found, else true. More... | |
| template<typename T > | |
| T * | find (const SLstring &name="", SLbool findRecursive=true) |
| template<typename T > | |
| T * | findChild (const SLstring &name="", SLbool findRecursive=true) |
| template<typename T > | |
| deque< T * > | findChildren (const SLstring &name="", SLbool findRecursive=true, SLbool canContain=false) |
| deque< SLNode * > | findChildren (const SLMesh *mesh, SLbool findRecursive=true) |
| deque< SLNode * > | findChildren (SLuint drawbit, SLbool findRecursive=true) |
| SLVec3f | translationOS () const |
| SLVec3f | forwardOS () const |
| SLVec3f | rightOS () const |
| SLVec3f | upOS () const |
| SLVec3f | axisXOS () const |
| SLVec3f | axisYOS () const |
| SLVec3f | axisZOS () const |
| SLVec3f | translationWS () const |
| SLVec3f | forwardWS () const |
| SLVec3f | rightWS () const |
| SLVec3f | upWS () const |
| SLVec3f | axisXWS () const |
| SLVec3f | axisYWS () const |
| SLVec3f | axisZWS () const |
| void | translation (const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent) |
| void | translation (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_parent) |
| void | rotation (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_parent) |
| void | rotation (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_parent) |
| void | scaling (SLfloat s) |
| void | scaling (SLfloat x, SLfloat y, SLfloat z) |
| void | scaling (const SLVec3f &scaling) |
| void | lookAt (SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world) |
| void | lookAt (const SLVec3f &target, const SLVec3f &up=SLVec3f::AXISY, SLTransformSpace relativeTo=TS_world) |
| void | translate (const SLVec3f &vec, SLTransformSpace relativeTo=TS_object) |
| void | translate (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object) |
| void | rotate (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_object) |
| void | rotate (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_object) |
| void | rotate (SLfloat angleDeg, SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object) |
| void | rotateAround (const SLVec3f &point, SLVec3f &axis, SLfloat angleDeg, SLTransformSpace relativeTo=TS_world) |
| void | scale (SLfloat s) |
| void | scale (SLfloat x, SLfloat y, SLfloat z) |
| void | scale (const SLVec3f &scale) |
| void | scaleToCenter (SLfloat maxDim) |
| void | setInitialState () |
| void | resetToInitialState () |
| void | parent (SLNode *p) |
| void | entityID (SLint entityID) |
| void | om (const SLMat4f &mat) |
| void | animation (SLAnimation *a) |
| void | castsShadows (SLbool castsShadows) |
| virtual void | needUpdate () |
| void | needWMUpdate () |
| void | needAABBUpdate () |
| void | isSelected (bool isSelected) |
| void | minLodCoverage (SLfloat minLodCoverage) |
| void | levelForSM (SLubyte lfsm) |
| void | onUpdateCB (function< void()> callbackFunc) |
| SLNode * | parent () |
| SLint | depth () const |
| SLint | entityID () const |
| const SLMat4f & | om () |
| const SLMat4f & | initialOM () |
| const SLMat4f & | updateAndGetWM () const |
| const SLMat4f & | updateAndGetWMI () const |
| SLDrawBits * | drawBits () |
| SLbool | drawBit (SLuint bit) |
| SLAABBox * | aabb () |
| SLAnimation * | animation () |
| SLbool | castsShadows () |
| SLMesh * | mesh () |
| SLVNode & | children () |
| const SLAnimSkeleton * | skeleton () |
| Returns the first skeleton found in the meshes. More... | |
| void | updateRec () |
| bool | updateMeshSkins (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes) |
| Update all skinned meshes recursively. More... | |
| void | updateMeshAccelStructs () |
| void | updateMeshMat (std::function< void(SLMaterial *m)> setMat, bool recursive) |
| Updates the mesh material recursively with a material lambda. More... | |
| void | setMeshMat (SLMaterial *mat, bool recursive) |
| Set the mesh material recursively. More... | |
| bool | isSelected () |
| SLfloat | minLodCoverage () |
| SLubyte | levelForSM () |
Public Member Functions inherited from SLObject | |
| SLObject (const SLstring &Name="", const SLstring &url="") | |
| virtual | ~SLObject () |
| void | name (const SLstring &Name) |
| void | url (const SLstring &url) |
| const SLstring & | name () const |
| const SLstring & | url () const |
Public Member Functions inherited from SLEventHandler | |
| SLEventHandler () | |
| virtual | ~SLEventHandler () |
| virtual SLbool | onMouseDown (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod) |
| virtual SLbool | onMouseUp (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod) |
| virtual SLbool | onMouseMove (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod) |
| virtual SLbool | onDoubleClick (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod) |
| virtual SLbool | onMouseWheel (const SLint delta, const SLKey mod) |
| virtual SLbool | onTouch2Down (const SLint x1, const SLint y1, const SLint x2, const SLint y2) |
| virtual SLbool | onTouch2Move (const SLint x1, const SLint y1, const SLint x2, const SLint y2) |
| virtual SLbool | onTouch2Up (const SLint x1, const SLint y1, const SLint x2, const SLint y2) |
| virtual SLbool | onTouch3Down (const SLint x1, const SLint y1) |
| virtual SLbool | onTouch3Move (const SLint x1, const SLint y1) |
| virtual SLbool | onTouch3Up (const SLint x1, const SLint y1) |
| virtual SLbool | onKeyPress (const SLKey key, const SLKey mod) |
| virtual SLbool | onKeyRelease (const SLKey key, const SLKey mod) |
| virtual SLbool | onRotationPYR (const SLfloat pitchRAD, const SLfloat yawRAD, const SLfloat rollRAD) |
| void | mouseRotationFactor (SLfloat rf) |
| SLfloat | mouseRotationFactor () |
Private Attributes | |
| SLDeviceRotation * | _devRot = nullptr |
| Rotation sensor, not owned. More... | |
| SLTexFont * | _font = nullptr |
| Font of the angle label, not owned. More... | |
| SLstring | _shaderDir |
| Directory of the line shader. More... | |
| SLGLProgram * | _prog = nullptr |
| Program drawing the horizon line. More... | |
| SLMaterial * | _mat = nullptr |
| Material of the horizon line. More... | |
| SLPolyline * | _line = nullptr |
| Mesh of the horizon line. More... | |
| SLNode * | _horizonNode = nullptr |
| Child node carrying the line. More... | |
| SLNode * | _textNode = nullptr |
| Child node carrying the angle text. More... | |
| SLMat3f | _sRc |
| Sensor to camera rotation used by the horizon estimation. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from SLNode | |
| static SLuint | numWMUpdates = 0 |
| NO. of calls to updateWMRec per frame. More... | |
| static unsigned int | instanceIndex = 0 |
| ??? More... | |
Protected Attributes inherited from SLNode | |
| SLNode * | _parent |
| pointer to the parent node More... | |
| SLVNode | _children |
| vector of children nodes More... | |
| SLMesh * | _mesh |
| pointer to a single mesh More... | |
| SLint | _depth |
| depth of the node in a scene tree More... | |
| SLint | _entityID |
| ID in the SLVEntity graph for Data Oriented Design. More... | |
| SLMat4f | _om |
| object matrix for local transforms More... | |
| SLMat4f | _initialOM |
| the initial om state More... | |
| SLMat4f | _wm |
| world matrix for world transform More... | |
| SLMat4f | _wmI |
| inverse world matrix More... | |
| SLbool | _isWMUpToDate |
| is the WM of this node still valid More... | |
| SLbool | _isWMIUpToDate |
| is the inverse WM of this node still valid More... | |
| SLbool | _isAABBUpToDate |
| is the saved aabb still valid More... | |
| bool | _castsShadows |
| flag if meshes of node should cast shadows More... | |
| bool | _isSelected |
| flag if node and one or more of its meshes are selected More... | |
| SLDrawBits | _drawBits |
| node level drawing flags More... | |
| SLAABBox | _aabb |
| axis aligned bounding box More... | |
| SLAnimation * | _animation |
| animation of the node More... | |
| SLfloat | _minLodCoverage |
| Min. LOD coverage for visibility (0.0 < _minLodCoverage < 1.0) More... | |
| SLubyte | _levelForSM |
| Level of LOD to use for shadow mapping (0 = the visible one will be drawn) More... | |
| function< void()> | _onUpdateCB |
| Optional lambda callback once per update. More... | |
Protected Attributes inherited from SLObject | |
| SLstring | _name |
| name of an object More... | |
| SLstring | _url |
| uniform resource locator More... | |
Protected Attributes inherited from SLEventHandler | |
| SLfloat | _mouseRotationFactor |
| Mouse rotation sensibility. More... | |
| SLfloat | _keyboardDeltaPos |
| Delta dist. for keyboard translation. More... | |
Scene node that visualises the horizon estimated from the device rotation.
The node owns two children: a polyline drawn as the horizon itself and an SLText showing the roll angle in degrees. Every frame doUpdate() reads the averaged rotation from the SLDeviceRotation passed to the constructor, derives the horizon direction with SLAlgo::estimateHorizon and rotates the line to match. The displayed angle is negated, so it expresses the rotation of the device with respect to the horizon rather than the other way round.
Intended for AR scenes on mobile devices, where it gives the user a reference for how far the device is tilted.
Definition at line 32 of file SLHorizonNode.h.
| SLHorizonNode::SLHorizonNode | ( | SLstring | name, |
| SLDeviceRotation * | devRot, | ||
| SLTexFont * | font, | ||
| SLstring | shaderDir, | ||
| int | scrW, | ||
| int | scrH | ||
| ) |
Builds the horizon line and its text label.
Construct a new SLHorizonNode::SLHorizonNode object.
| name | Name of the node |
| devRot | Rotation sensor to read the orientation from, not owned |
| font | Font for the angle label; if nullptr no label is shown |
| shaderDir | Directory the line shader is loaded from |
| scrW | Screen width in pixels, used to size the line |
| scrH | Screen height in pixels, used to size the line |
| name | Name of the node |
| devRot | Device rotation object |
| font | Font for the text label |
| shaderDir | Path to the shader directory |
| scrW | Width of the screen in pixels |
| scrH | Height of the sceen in pixels |
Definition at line 30 of file SLHorizonNode.cpp.
| SLHorizonNode::~SLHorizonNode | ( | ) |
Deletes the program, material and meshes created in the constructor.
Definition at line 90 of file SLHorizonNode.cpp.
|
overridevirtual |
Re-aligns the horizon line and refreshes the angle label.
Called once per frame by the scene update. The text node is destroyed and rebuilt on every call because the label text changes.
Reimplemented from SLNode.
Definition at line 97 of file SLHorizonNode.cpp.
|
private |
Rotation sensor, not owned.
Definition at line 58 of file SLHorizonNode.h.
|
private |
Font of the angle label, not owned.
Definition at line 59 of file SLHorizonNode.h.
|
private |
Child node carrying the line.
Definition at line 65 of file SLHorizonNode.h.
|
private |
Mesh of the horizon line.
Definition at line 64 of file SLHorizonNode.h.
|
private |
Material of the horizon line.
Definition at line 63 of file SLHorizonNode.h.
|
private |
Program drawing the horizon line.
Definition at line 62 of file SLHorizonNode.h.
|
private |
Directory of the line shader.
Definition at line 60 of file SLHorizonNode.h.
|
private |
Sensor to camera rotation used by the horizon estimation.
Definition at line 68 of file SLHorizonNode.h.
|
private |
Child node carrying the angle text.
Definition at line 66 of file SLHorizonNode.h.