SLProject 4.0.000
SLLens Class Reference

SLLens creates a lens mesh based on SLRevolver. More...

#include <SLLens.h>

Inheritance diagram for SLLens:
[legend]

Public Member Functions

 SLLens (SLAssetManager *assetMgr, double sphere, double cylinder, SLfloat diameter, SLfloat thickness, SLuint stacks=32, SLuint slices=32, SLstring name="lens mesh", SLMaterial *mat=nullptr)
 Create a lens with given sphere, cylinder, diameter and thickness. More...
 
 SLLens (SLAssetManager *assetMgr, SLfloat radiusBot, SLfloat radiusTop, SLfloat diameter, SLfloat thickness, SLuint stacks=32, SLuint slices=32, SLstring name="lens mesh", SLMaterial *mat=nullptr)
 Create a lens with given radius, diameter and thickness. More...
 
- Public Member Functions inherited from SLRevolver
 SLRevolver (SLAssetManager *assetMgr, SLVVec3f revolvePoints, SLVec3f revolveAxis, SLuint slices=36, SLbool smoothFirst=false, SLbool smoothLast=false, SLstring name="revolver mesh", SLMaterial *mat=nullptr)
 ctor for generic revolver mesh More...
 
 SLRevolver (SLAssetManager *assetMgr, SLstring name)
 ctor for derived revolver shapes More...
 
void buildMesh (SLMaterial *mat=nullptr)
 
SLuint stacks ()
 
SLuint slices ()
 
- Public Member Functions inherited from SLMesh
 SLMesh (SLAssetManager *assetMgr, const SLstring &name="Mesh")
 
 ~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)
 
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 (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 Member Functions

void initLens (SLfloat diopterBot, SLfloat diopterTop, SLfloat diameter, SLfloat thickness, SLuint stacks, SLuint slices, SLMaterial *mat)
 Initialize the lens. More...
 
void generateLens (SLfloat radiusBot, SLfloat radiusTop, SLMaterial *mat)
 Generate the lens with given front and back radius. More...
 
SLfloat generateLensBot (SLfloat radius)
 Generate the bottom (front) part of the lens. More...
 
SLfloat generateLensTop (SLfloat radius)
 Generate the top (back) part of the lens. More...
 
SLfloat calcSagitta (SLfloat radius)
 Calculate the sagitta (s) for a given radius (r) and diameter (l+l) where l is half of the lens diameter See also: http://en.wikipedia.org/wiki/Sagitta_%28geometry%29. More...
 

Private Attributes

SLfloat _diameter
 The diameter of the lens. More...
 
SLfloat _thickness
 The space between the primary planes of lens sides. More...
 
SLfloat _radiusBot
 The radius of the bot (front) side of the lens. More...
 
SLfloat _radiusTop
 The radius of the top (back) side of the lens. More...
 
SLbool _pointOutput
 debug helper 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 SLRevolver
SLVVec3f _revPoints
 Array revolving points. More...
 
SLVec3f _revAxis
 axis of revolution More...
 
SLuint _stacks
 No. of stacks (mostly used) More...
 
SLuint _slices
 NO. of slices. More...
 
SLbool _smoothFirst
 flag if the normal of the first point is eqaual to -revAxis More...
 
SLbool _smoothLast
 flag if the normal of the last point is eqaual to revAxis 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 id accel.struct needs update. More...
 
SLAnimSkeleton_skeleton
 The skeleton this mesh is bound to. More...
 
SLVMat4f _jointMatrices
 Joint matrix vector for this mesh. 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

SLLens creates a lens mesh based on SLRevolver.

SLLens creates a lens mesh based on SLRevolver. Different constructors allow to either create the lens from the values written in the eyeglass prescription card or from the radius of the lens.

Lens types:

Myopia ( http://en.wikipedia.org/wiki/Myopia )
The eye is too long for its optical power.
To correct myopic (short-sightedness) a diverging lens is needed.

Hypermetropia ( http://en.wikipedia.org/wiki/Hyperopia )
The eye is too short for its optical power.
To correct presbyopic (far-sightedness) a converging lens is needed.

Constructor & Destructor Documentation

◆ SLLens() [1/2]

SLLens::SLLens ( SLAssetManager assetMgr,
double  sphere,
double  cylinder,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks = 32,
SLuint  slices = 32,
SLstring  name = "lens mesh",
SLMaterial mat = nullptr 
)

Create a lens with given sphere, cylinder, diameter and thickness.

SLLens::SLLens ctor for lens revolution object around the y-axis.
Create the lens with the eye prescription card.

The first values in the prescription card is called Sphere. It is also the diopter of the front side of the lens.
The second value from the prescription card is called Cylinder. The sum from the spere and the cylinder is the diopter of the back side of the lens.
The diopter is the inverse of the focal distance (f) of the lens.
To correct myopic, negative diopters are used.
To correct presbyopic, positive diopters are used.

Parameters
assetMgrPointer to the asset manager
sphereSLfloat taken from the eyeglass passport.
cylinderSLfloat taken from the eyeglass passport.
diameterSLfloat The diameter (h) of the lens
thicknessSLfloat The space between the primary planes of lens sides (d)
stacksSLint
slicesSLint
nameSLstring of the SLRevolver Mesh
matSLMaterial* The Material of the lens

The diopter of the front side is equal to the sphere.
The diopter of the backside is the sum of the spehere and the cylinder.
From the diopter, the radius (R1, R2) can be calculated:
radiusFront = (LensMaterial - OutsideMaterial) / FrontDiopter) * diameter;
radiusBack = (OutsideMaterial - LensMaterial) / BackDiopter) * diameter;

◆ SLLens() [2/2]

SLLens::SLLens ( SLAssetManager assetMgr,
SLfloat  radiusBot,
SLfloat  radiusTop,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks = 32,
SLuint  slices = 32,
SLstring  name = "lens mesh",
SLMaterial mat = nullptr 
)

Create a lens with given radius, diameter and thickness.

SLLens::SLLens ctor for lens revolution object around the y-axis.
Create the lens with radius.
To correct presbyopic (far-sightedness) a converging lens is needed. To correct myopic (short-sightedness) a diverging lens is needed.

Parameters
assetMgrPointer to the asset manager
radiusBotThe radius of the front side of the lens
radiusTopThe radius of the back side of the lens
diameterThe diameter (h) of the lens
thicknessThe space between the primary planes of lens sides (d)
stacksNo. of stacks of the lens
slicesNo. of slices in the lens
nameName of the SLRevolver Mesh
matPointer to the Material of the lens

Positive radius creates a convex lens side.
Negative radius creates a concave lens side.
Setting the radius to 0 creates a plane.
Combine the two radius to get the required lens.

Member Function Documentation

◆ calcSagitta()

SLfloat SLLens::calcSagitta ( SLfloat  radius)
private

Calculate the sagitta (s) for a given radius (r) and diameter (l+l) where l is half of the lens diameter See also: http://en.wikipedia.org/wiki/Sagitta_%28geometry%29.

Parameters
radiusr of the lens
Returns
sagitta s of the lens

◆ generateLens()

void SLLens::generateLens ( SLfloat  radiusBot,
SLfloat  radiusTop,
SLMaterial mat 
)
private

Generate the lens with given front and back radius.

Parameters
radiusBotradius of the lens front side
radiusTopradius of the lens back side
matthe material pointer that is passed to SLRevolver

◆ generateLensBot()

SLfloat SLLens::generateLensBot ( SLfloat  radius)
private

Generate the bottom (front) part of the lens.

Parameters
radiusof the lens
Returns
x the x coordinate of the last point of the bulge

◆ generateLensTop()

SLfloat SLLens::generateLensTop ( SLfloat  radius)
private

Generate the top (back) part of the lens.

Parameters
radiusof the lens
Returns
x the x coordinate of the last point of the bulge

◆ initLens()

void SLLens::initLens ( SLfloat  diopterBot,
SLfloat  diopterTop,
SLfloat  diameter,
SLfloat  thickness,
SLuint  stacks,
SLuint  slices,
SLMaterial mat 
)
private

Initialize the lens.

Parameters
diopterBotSLfloat The diopter of the bot (front) part of the lens
diopterTopSLfloat The diopter of the top (back) part of the lens
diameterSLfloat The diameter of the lens
thicknessSLfloat d The space between the primary planes of lens sides
stacksSLint
slicesSLint
matSLMaterial* The Material of the lens

Member Data Documentation

◆ _diameter

SLfloat SLLens::_diameter
private

The diameter of the lens.

◆ _pointOutput

SLbool SLLens::_pointOutput
private

debug helper

◆ _radiusBot

SLfloat SLLens::_radiusBot
private

The radius of the bot (front) side of the lens.

◆ _radiusTop

SLfloat SLLens::_radiusTop
private

The radius of the top (back) side of the lens.

◆ _thickness

SLfloat SLLens::_thickness
private

The space between the primary planes of lens sides.


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