SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLCoordAxisArrow Class Reference

Single arrow for coordinate axis. More...

#include <SLCoordAxisArrow.h>

Inheritance diagram for SLCoordAxisArrow:
[legend]

Public Member Functions

 SLCoordAxisArrow (SLAssetManager *assetMgr, SLMaterial *material=nullptr, SLfloat arrowThickness=0.05f, SLfloat arrowHeadLenght=0.2f, SLfloat arrowHeadWidth=0.1f)
 
void buildMesh (SLMaterial *material=nullptr)
 
- Public Member Functions inherited from SLMesh
 SLMesh (SLAssetManager *assetMgr, const SLstring &name="Mesh")
 Construct a new SLMesh::SLMesh object. More...
 
 ~SLMesh () override
 The destructor deletes everything by calling deleteData. More...
 
virtual void init (SLNode *node)
 SLMesh::shapeInit sets the transparency flag of the AABB. More...
 
virtual void draw (SLSceneView *sv, SLNode *node, SLuint intances=0)
 
void drawIntoDepthBuffer (SLSceneView *sv, SLNode *node, SLMaterial *depthMat)
 Simplified drawing method for shadow map creation. More...
 
void addStats (SLNodeStats &stats)
 
virtual void buildAABB (SLAABBox &aabb, const SLMat4f &wmNode)
 
void updateAccelStruct ()
 
SLbool hit (SLRay *ray, SLNode *node)
 
virtual void preShade (SLRay *ray)
 
virtual void deleteData ()
 SLMesh::deleteData deletes all mesh data and vbo's. More...
 
virtual void deleteDataGpu ()
 
void deleteSelected (SLNode *node)
 Deletes the rectangle selected vertices and the dependent triangles. More...
 
void deleteUnused ()
 Deletes unused vertices (= vertices that are not indexed in I16 or I32) More...
 
virtual void calcMinMax ()
 
virtual void calcNormals ()
 SLMesh::calcNormals recalculates vertex normals for triangle meshes. More...
 
void calcCenterRad (SLVec3f &center, SLfloat &radius)
 
SLbool hitTriangleOS (SLRay *ray, SLNode *node, SLuint iT)
 
virtual void generateVAO (SLGLVertexArray &vao)
 Generate the Vertex Array Object for a specific shader program. More...
 
void computeHardEdgesIndices (float angleRAD, float epsilon)
 computes the hard edges and stores the vertex indexes separately More...
 
void transformSkin (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
 Transforms the vertex positions and normals with by joint weights. More...
 
void deselectPartialSelection ()
 
SLMaterialmat () const
 
SLMaterialmatOut () const
 
SLGLPrimitiveType primitive () const
 
const SLAnimSkeletonskeleton () const
 
SLuint numI () const
 
SLGLVertexArrayvao ()
 
SLbool isSelected () const
 
SLfloat edgeAngleDEG () const
 
SLfloat edgeWidth () const
 
SLCol4f edgeColor () const
 
SLVec3f finalP (SLuint i)
 
SLVec3f finalN (SLuint i)
 
SLbool accelStructIsOutOfDate ()
 
void mat (SLMaterial *m)
 
void matOut (SLMaterial *m)
 
void primitive (SLGLPrimitiveType pt)
 
void skeleton (SLAnimSkeleton *skel)
 
void isSelected (bool isSelected)
 
void edgeWidth (SLfloat ew)
 
void edgeAngleDEG (SLfloat ea)
 
void edgeColor (const SLCol4f &ec)
 
void vertexPosEpsilon (SLfloat eps)
 
- 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 SLstringname () const
 
const SLstringurl () const
 

Private Attributes

SLfloat _arrowThickness
 Thickness of the arrow. More...
 
SLfloat _arrowHeadLength
 Lenght of the arrow head. More...
 
SLfloat _arrowHeadWidth
 Width of the arrow head. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SLMesh
static void calcTex3DMatrix (SLNode *node)
 
- Public Attributes inherited from SLMesh
SLVVec3f P
 Vector for vertex positions layout (location = 0) More...
 
SLVVec3f N
 Vector for vertex normals (opt.) layout (location = 1) More...
 
SLVVec2f UV [2]
 Array of 2 Vectors for tex. coords. (opt.) layout (location = 2) More...
 
SLVCol4f C
 Vector of vertex colors (opt.) layout (location = 4) More...
 
SLVVec4f T
 Vector of vertex tangents (opt.) layout (location = 5) More...
 
SLVVuchar Ji
 2D Vector of per vertex joint ids (opt.) layout (location = 6) More...
 
SLVVfloat Jw
 2D Vector of per vertex joint weights (opt.) layout (location = 7) More...
 
SLVVec3f skinnedP
 temp. vector for CPU skinned vertex positions More...
 
SLVVec3f skinnedN
 temp. vector for CPU skinned vertex normals More...
 
SLVushort I16
 Vector of vertex indices 16 bit. More...
 
SLVuint I32
 Vector of vertex indices 32 bit. More...
 
SLVuint IS32
 Vector of rectangle selected vertex indices 32 bit. More...
 
SLVushort IE16
 Vector of hard edges vertex indices 16 bit (see computeHardEdgesIndices) More...
 
SLVuint IE32
 Vector of hard edges vertex indices 32 bit (see computeHardEdgesIndices) More...
 
SLVec3f minP
 min. vertex in OS More...
 
SLVec3f maxP
 max. vertex in OS More...
 
- Protected Attributes inherited from SLMesh
SLGLPrimitiveType _primitive
 Primitive type (default triangles) More...
 
SLMaterial_mat
 Pointer to the inside material. More...
 
SLMaterial_matOut
 Pointer to the outside material. More...
 
SLGLVertexArray _vao
 Main OpenGL Vertex Array Object for drawing. More...
 
SLGLVertexArrayExt _vaoN
 OpenGL VAO for optional normal drawing. More...
 
SLGLVertexArrayExt _vaoT
 OpenGL VAO for optional tangent drawing. More...
 
SLGLVertexArrayExt _vaoS
 OpenGL VAO for optional selection drawing. More...
 
SLbool _isSelected
 Flag if mesh is partially of fully selected. More...
 
SLfloat _edgeAngleDEG
 Edge crease angle in degrees between face normals (30 deg. default) More...
 
SLfloat _edgeWidth
 Line width for hard edge drawing. More...
 
SLCol4f _edgeColor
 Color for hard edge drawing. More...
 
SLfloat _vertexPosEpsilon
 Vertex position epsilon used in computeHardEdgesIndices. More...
 
SLbool _isVolume
 Flag for RT if mesh is a closed volume. More...
 
SLAccelStruct_accelStruct
 KD-tree or uniform grid. More...
 
SLbool _accelStructIsOutOfDate
 Flag if accel. struct needs update. More...
 
SLAnimSkeleton_skeleton
 The skeleton this mesh is bound to. More...
 
SLVMat4f _jointMatrices
 Joint matrix vector for this mesh. More...
 
SLbool _isCPUSkinned
 Flag if mesh has been skinned on CPU during update. More...
 
SLVVec3f_finalP
 Pointer to final vertex position vector. More...
 
SLVVec3f_finalN
 pointer to final vertex normal vector More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Single arrow for coordinate axis.

Remarks
It is important that during instantiation NO OpenGL functions (gl*) get called because this constructor will be most probably called in a parallel thread from within an SLScene::registerAssetsToLoad or SLScene::assemble function. All objects that get rendered have to do their OpenGL initialization when they are used the first time during rendering in the main thread. For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP, _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.

Definition at line 26 of file SLCoordAxisArrow.h.

Constructor & Destructor Documentation

◆ SLCoordAxisArrow()

SLCoordAxisArrow::SLCoordAxisArrow ( SLAssetManager assetMgr,
SLMaterial material = nullptr,
SLfloat  arrowThickness = 0.05f,
SLfloat  arrowHeadLenght = 0.2f,
SLfloat  arrowHeadWidth = 0.1f 
)
explicit

Definition at line 13 of file SLCoordAxisArrow.cpp.

18  : SLMesh(assetMgr, "Coord-Axis-Arrow Mesh")
19 {
20  _arrowThickness = arrowThickness;
21  _arrowHeadLength = arrowHeadLenght;
22  _arrowHeadWidth = arrowHeadWidth;
23  buildMesh(material);
24 }
void buildMesh(SLMaterial *material=nullptr)
SLfloat _arrowHeadWidth
Width of the arrow head.
SLfloat _arrowHeadLength
Lenght of the arrow head.
SLfloat _arrowThickness
Thickness of the arrow.
SLMesh(SLAssetManager *assetMgr, const SLstring &name="Mesh")
Construct a new SLMesh::SLMesh object.
Definition: SLMesh.cpp:51

Member Function Documentation

◆ buildMesh()

void SLCoordAxisArrow::buildMesh ( SLMaterial material = nullptr)

Definition at line 26 of file SLCoordAxisArrow.cpp.

27 {
28  // allocate new vectors of SLMesh
29  P.clear();
30  N.clear();
31  C.clear();
32  UV[0].clear();
33  UV[1].clear();
34  I16.clear();
35  I32.clear();
36 
37  mat(material);
38 
39  SLushort i = 0, v1 = 0, v2 = 0, v3 = 0, v4 = 0;
40  SLfloat t = _arrowThickness * 0.5f;
42  SLfloat w = _arrowHeadWidth * 0.5f;
43 
44  // clang-format off
45  P.push_back(SLVec3f( t, t, t)); v1=i; i++;
46  P.push_back(SLVec3f( t,1-h, t)); v2=i; i++;
47  P.push_back(SLVec3f( t,1-h,-t)); v3=i; i++;
48  P.push_back(SLVec3f( t, t,-t)); v4=i; i++;
49  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
50  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
51 
52  P.push_back(SLVec3f(-t, t, t)); v1=i; i++;
53  P.push_back(SLVec3f(-t,1-h, t)); v2=i; i++;
54  P.push_back(SLVec3f( t,1-h, t)); v3=i; i++;
55  P.push_back(SLVec3f( t, t, t)); v4=i; i++;
56  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
57  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
58 
59  P.push_back(SLVec3f(-t, t,-t)); v1=i; i++;
60  P.push_back(SLVec3f(-t,1-h,-t)); v2=i; i++;
61  P.push_back(SLVec3f(-t,1-h, t)); v3=i; i++;
62  P.push_back(SLVec3f(-t, t, t)); v4=i; i++;
63  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
64  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
65 
66  P.push_back(SLVec3f( t, t,-t)); v1=i; i++;
67  P.push_back(SLVec3f( t,1-h,-t)); v2=i; i++;
68  P.push_back(SLVec3f(-t,1-h,-t)); v3=i; i++;
69  P.push_back(SLVec3f(-t, t,-t)); v4=i; i++;
70  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
71  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
72 
73  P.push_back(SLVec3f( w,1-h, w)); v1=i; i++;
74  P.push_back(SLVec3f( 0, 1, 0)); v2=i; i++;
75  P.push_back(SLVec3f( w,1-h,-w)); v3=i; i++;
76  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
77 
78  P.push_back(SLVec3f( w,1-h, w)); v1=i; i++;
79  P.push_back(SLVec3f(-w,1-h, w)); v2=i; i++;
80  P.push_back(SLVec3f( 0, 1, 0)); v3=i; i++;
81  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
82  P.push_back(SLVec3f(-w,1-h, w)); v1=i; i++;
83  P.push_back(SLVec3f(-w,1-h,-w)); v2=i; i++;
84  P.push_back(SLVec3f( 0, 1, 0)); v3=i; i++;
85  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
86 
87  P.push_back(SLVec3f(-w,1-h,-w)); v1=i; i++;
88  P.push_back(SLVec3f( w,1-h,-w)); v2=i; i++;
89  P.push_back(SLVec3f( 0, 1, 0)); v3=i; i++;
90  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
91 
92  P.push_back(SLVec3f( w,1-h, w)); v1=i; i++;
93  P.push_back(SLVec3f( w,1-h,-w)); v2=i; i++;
94  P.push_back(SLVec3f(-w,1-h,-w)); v3=i; i++;
95  P.push_back(SLVec3f(-w,1-h, w)); v4=i; i++;
96  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
97  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
98 
99  P.push_back(SLVec3f( t, -t, t)); v1=i; i++;
100  P.push_back(SLVec3f( t, -t,-t)); v2=i; i++;
101  P.push_back(SLVec3f(-t, -t,-t)); v3=i; i++;
102  P.push_back(SLVec3f(-t, -t, t)); v4=i; i++;
103  I16.push_back(v1); I16.push_back(v3); I16.push_back(v2);
104  I16.push_back(v1); I16.push_back(v4); I16.push_back(v3);
105 }
float SLfloat
Definition: SL.h:173
unsigned short SLushort
Definition: SL.h:169
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
SLVuint I32
Vector of vertex indices 32 bit.
Definition: SLMesh.h:215
SLVushort I16
Vector of vertex indices 16 bit.
Definition: SLMesh.h:214
SLVCol4f C
Vector of vertex colors (opt.) layout (location = 4)
Definition: SLMesh.h:206
SLVVec3f N
Vector for vertex normals (opt.) layout (location = 1)
Definition: SLMesh.h:204
SLVVec2f UV[2]
Array of 2 Vectors for tex. coords. (opt.) layout (location = 2)
Definition: SLMesh.h:205
SLVVec3f P
Vector for vertex positions layout (location = 0)
Definition: SLMesh.h:203
SLMaterial * mat() const
Definition: SLMesh.h:177
V3 v3(float x, float y, float z)
Definition: WAIMath.h:38

Member Data Documentation

◆ _arrowHeadLength

SLfloat SLCoordAxisArrow::_arrowHeadLength
private

Lenght of the arrow head.

Definition at line 39 of file SLCoordAxisArrow.h.

◆ _arrowHeadWidth

SLfloat SLCoordAxisArrow::_arrowHeadWidth
private

Width of the arrow head.

Definition at line 40 of file SLCoordAxisArrow.h.

◆ _arrowThickness

SLfloat SLCoordAxisArrow::_arrowThickness
private

Thickness of the arrow.

Definition at line 38 of file SLCoordAxisArrow.h.


The documentation for this class was generated from the following files: