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

Class for texture filtering scene. More...

#include <AppDemoSceneTextureFilter.h>

Inheritance diagram for AppDemoSceneTextureFilter:
[legend]

Public Member Functions

 AppDemoSceneTextureFilter ()
 
void registerAssetsToLoad (SLAssetLoader &al) override
 All scene specific assets have to be registered for async loading in here. More...
 
void assemble (SLAssetManager *am, SLSceneView *sv) override
 After parallel loading of the assets the scene gets assembled in here. More...
 
- Public Member Functions inherited from SLScene
 SLScene (const SLstring &name)
 
 ~SLScene () override
 
void initOculus (SLstring shaderDir)
 
void root3D (SLNode *root3D)
 
void root2D (SLNode *root2D)
 
void skybox (SLSkybox *skybox)
 
void stopAnimations (SLbool stop)
 
void info (SLstring i)
 
void loadTimeMS (SLfloat loadTimeMS)
 
SLAnimManageranimManager ()
 
SLAssetManagerassetManager ()
 
SLNoderoot3D ()
 
SLNoderoot2D ()
 
SLSkyboxskybox ()
 
SLstringinfo ()
 
SLfloat elapsedTimeMS () const
 
SLfloat elapsedTimeSec () const
 
SLVEventHandlereventHandlers ()
 
SLfloat loadTimeMS () const
 
SLVLightlights ()
 
SLfloat fps () const
 
AvgFloatframeTimesMS ()
 
AvgFloatupdateTimesMS ()
 
AvgFloatupdateAnimTimesMS ()
 
AvgFloatupdateAABBTimesMS ()
 
AvgFloatupdateDODTimesMS ()
 
SLNodesingleNodeSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLMeshsingleMeshFullSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLVNodeselectedNodes ()
 
SLVMeshselectedMeshes ()
 
SLbool stopAnimations () const
 
SLint numSceneCameras ()
 Returns the number of camera nodes in the scene. More...
 
SLCameranextCameraInScene (SLCamera *activeSVCam)
 Returns the next camera in the scene if there is one. More...
 
bool onUpdate (bool renderTypeIsRT, bool voxelsAreShown, bool forceCPUSkinning)
 Updates animations and AABBs. More...
 
void init (SLAssetManager *am)
 
virtual void unInit ()
 
void selectNodeMesh (SLNode *nodeToSelect, SLMesh *meshToSelect)
 Handles the full mesh selection from double-clicks. More...
 
void deselectAllNodesAndMeshes ()
 Deselects all nodes and its meshes. More...
 
SLGLOculusoculus ()
 
- 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

SLGLTexture_texB
 
SLGLTexture_texL
 
SLGLTexture_texT
 
SLGLTexture_texR
 
SLGLTexture_tex3D
 
SLGLProgram_spr3D
 

Additional Inherited Members

- Protected Attributes inherited from SLScene
SLVLight _lights
 Vector of all lights. More...
 
SLVEventHandler _eventHandlers
 Vector of all event handler. More...
 
SLAnimManager _animManager
 Animation manager instance. More...
 
SLAssetManager_assetManager
 Pointer to the external assetManager. More...
 
SLNode_root3D
 Root node for 3D scene. More...
 
SLNode_root2D
 Root node for 2D scene displayed in ortho projection. More...
 
SLSkybox_skybox
 pointer to skybox More...
 
SLstring _info
 scene info string More...
 
SLVNode _selectedNodes
 Vector of selected nodes. See SLMesh::selectNodeMesh. More...
 
SLVMesh _selectedMeshes
 Vector of selected meshes. See SLMesh::selectNodeMesh. More...
 
SLfloat _loadTimeMS
 time to load scene in ms More...
 
SLfloat _frameTimeMS
 Last frame time in ms. More...
 
SLfloat _lastUpdateTimeMS
 Last time after update in ms. More...
 
SLfloat _fps
 Averaged no. of frames per second. More...
 
AvgFloat _frameTimesMS
 Averaged total time per frame in ms. More...
 
AvgFloat _updateTimesMS
 Averaged time for update in ms. More...
 
AvgFloat _updateAABBTimesMS
 Averaged time for update the nodes AABB in ms. More...
 
AvgFloat _updateAnimTimesMS
 Averaged time for update the animations in ms. More...
 
AvgFloat _updateDODTimesMS
 Averaged time for update the SLEntities graph. More...
 
SLbool _stopAnimations
 Global flag for stopping all animations. More...
 
std::unique_ptr< SLGLOculus_oculus
 Oculus Rift interface. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Class for texture filtering scene.

Definition at line 20 of file AppDemoSceneTextureFilter.h.

Constructor & Destructor Documentation

◆ AppDemoSceneTextureFilter()

AppDemoSceneTextureFilter::AppDemoSceneTextureFilter ( )

Definition at line 21 of file AppDemoSceneTextureFilter.cpp.

21  : SLScene("Texture Filter Test")
22 {
23  info("Texture minification filters: "
24  "Bottom: nearest, left: linear, top: linear mipmap, right: anisotropic. "
25  "The center sphere uses a 3D texture with linear filtering.");
26 }
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneTextureFilter::assemble ( SLAssetManager am,
SLSceneView sv 
)
overridevirtual

After parallel loading of the assets the scene gets assembled in here.

Remarks
All scene-specific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread. It is important that all object instantiations within SLScene::assemble do NOT call any OpenGL functions (gl*) because they happen in a parallel thread. All objects that get rendered have to do their initialization when they are used the first time during rendering in the main thread.

Reimplemented from SLScene.

Definition at line 61 of file AppDemoSceneTextureFilter.cpp.

62 {
63  // define materials with textureOnly shader, no light needed
64  SLMaterial* matB = new SLMaterial(am,
65  "matB",
66  _texB,
67  nullptr,
68  nullptr,
69  nullptr,
71  SLMaterial* matL = new SLMaterial(am,
72  "matL",
73  _texL,
74  nullptr,
75  nullptr,
76  nullptr,
78  SLMaterial* matT = new SLMaterial(am,
79  "matT",
80  _texT,
81  nullptr,
82  nullptr,
83  nullptr,
85  SLMaterial* matR = new SLMaterial(am,
86  "matR",
87  _texR,
88  nullptr,
89  nullptr,
90  nullptr,
92 
93  // build polygons for bottom, left, top & right side
94  SLVVec3f VB;
95  VB.push_back(SLVec3f(-0.5f, -0.5f, 1.0f));
96  VB.push_back(SLVec3f(0.5f, -0.5f, 1.0f));
97  VB.push_back(SLVec3f(0.5f, -0.5f, -2.0f));
98  VB.push_back(SLVec3f(-0.5f, -0.5f, -2.0f));
99  SLVVec2f T;
100  T.push_back(SLVec2f(0.0f, 2.0f));
101  T.push_back(SLVec2f(0.0f, 0.0f));
102  T.push_back(SLVec2f(6.0f, 0.0f));
103  T.push_back(SLVec2f(6.0f, 2.0f));
104  SLNode* polyB = new SLNode(new SLPolygon(am, VB, T, "PolygonB", matB));
105 
106  SLVVec3f VL;
107  VL.push_back(SLVec3f(-0.5f, 0.5f, 1.0f));
108  VL.push_back(SLVec3f(-0.5f, -0.5f, 1.0f));
109  VL.push_back(SLVec3f(-0.5f, -0.5f, -2.0f));
110  VL.push_back(SLVec3f(-0.5f, 0.5f, -2.0f));
111  SLNode* polyL = new SLNode(new SLPolygon(am, VL, T, "PolygonL", matL));
112 
113  SLVVec3f VT;
114  VT.push_back(SLVec3f(0.5f, 0.5f, 1.0f));
115  VT.push_back(SLVec3f(-0.5f, 0.5f, 1.0f));
116  VT.push_back(SLVec3f(-0.5f, 0.5f, -2.0f));
117  VT.push_back(SLVec3f(0.5f, 0.5f, -2.0f));
118  SLNode* polyT = new SLNode(new SLPolygon(am, VT, T, "PolygonT", matT));
119 
120  SLVVec3f VR;
121  VR.push_back(SLVec3f(0.5f, -0.5f, 1.0f));
122  VR.push_back(SLVec3f(0.5f, 0.5f, 1.0f));
123  VR.push_back(SLVec3f(0.5f, 0.5f, -2.0f));
124  VR.push_back(SLVec3f(0.5f, -0.5f, -2.0f));
125  SLNode* polyR = new SLNode(new SLPolygon(am, VR, T, "PolygonR", matR));
126 
127  // 3D Texture Mapping on a pyramid
128  SLMaterial* mat3D = new SLMaterial(am,
129  "mat3D",
130  _tex3D,
131  nullptr,
132  nullptr,
133  nullptr,
134  _spr3D);
135 
136  // Create 3D textured pyramid mesh and node
137  SLMesh* pyramid = new SLMesh(am, "Pyramid");
138  pyramid->mat(mat3D);
139  pyramid->P = {{-1, -1, 1},
140  {1, -1, 1},
141  {1, -1, -1},
142  {-1, -1, -1},
143  {0, 2, 0}};
144  pyramid->I16 = {0, 3, 1, 1, 3, 2, 4, 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0};
145  SLNode* pyramidNode = new SLNode(pyramid, "Pyramid");
146  pyramidNode->scale(0.2f);
147  pyramidNode->translate(0, 0, -3);
148 
149  // Create 3D textured sphere mesh and node
150  SLNode* sphere = new SLNode(new SLSphere(am,
151  0.2f,
152  16,
153  16,
154  "Sphere",
155  mat3D));
156  SLCamera* cam1 = new SLCamera("Camera 1");
157  cam1->translation(0, 0, 2.6f);
158  cam1->lookAt(0, 0, 0);
159  cam1->focalDist(2.2f);
160  cam1->background().colors(SLCol4f(0.2f, 0.2f, 0.2f));
161  cam1->setInitialState();
163 
164  SLNode* scene = new SLNode();
165  this->root3D(scene);
166  scene->addChild(polyB);
167  scene->addChild(polyL);
168  scene->addChild(polyT);
169  scene->addChild(polyR);
170  scene->addChild(sphere);
171  scene->addChild(cam1);
172  sv->camera(cam1);
173 }
@ SP_textureOnly
vector< SLVec2f > SLVVec2f
Definition: SLVec2.h:143
SLVec2< SLfloat > SLVec2f
Definition: SLVec2.h:141
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
static SLDeviceRotation devRot
Mobile device rotation from IMU.
Definition: AppCommon.h:64
static SLDeviceLocation devLoc
Mobile device location from GPS.
Definition: AppCommon.h:65
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
Active or visible camera node class.
Definition: SLCamera.h:54
void devRotLoc(SLDeviceRotation *devRot, SLDeviceLocation *devLoc)
Definition: SLCamera.h:120
void focalDist(const SLfloat f)
Definition: SLCamera.h:116
SLBackground & background()
Definition: SLCamera.h:165
static SLGLProgramGeneric * get(SLStdShaderProg id)
Get program reference for given id.
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLVushort I16
Vector of vertex indices 16 bit.
Definition: SLMesh.h:214
SLVVec3f P
Vector for vertex positions layout (location = 0)
Definition: SLMesh.h:203
SLMaterial * mat() const
Definition: SLMesh.h:177
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
void addChild(SLNode *child)
Definition: SLNode.cpp:207
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
Definition: SLNode.cpp:828
void scale(SLfloat s)
Definition: SLNode.h:640
void setInitialState()
Definition: SLNode.cpp:1084
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
Definition: SLNode.h:652
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
Definition: SLNode.cpp:906
SLPolygon creates a convex polyon mesh.
Definition: SLPolygon.h:29
SLNode * root3D()
Definition: SLScene.h:99
friend class SLNode
Definition: SLScene.h:48
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
SLSphere creates a sphere mesh based on SLSpheric w. 180 deg polar angle.
Definition: SLSphere.h:33

◆ registerAssetsToLoad()

void AppDemoSceneTextureFilter::registerAssetsToLoad ( SLAssetLoader al)
overridevirtual

All scene specific assets have to be registered for async loading in here.

All assets the should be loaded in parallel must be registered in here.

Remarks
All scene sspecific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread.

Reimplemented from SLScene.

Definition at line 29 of file AppDemoSceneTextureFilter.cpp.

30 {
33  "brick0512_C.png",
34  GL_NEAREST,
35  GL_NEAREST);
38  "brick0512_C.png",
39  GL_LINEAR,
40  GL_LINEAR);
43  "brick0512_C.png",
44  GL_LINEAR_MIPMAP_LINEAR,
45  GL_LINEAR);
48  "brick0512_C.png",
50  GL_LINEAR);
52  256,
54  "Wave_radial10_256C.jpg");
56  AppCommon::shaderPath + "TextureOnly3D.vert",
57  AppCommon::shaderPath + "TextureOnly3D.frag");
58 }
#define SL_ANISOTROPY_MAX
Definition: SLGLTexture.h:34
static SLstring texturePath
Path to texture images.
Definition: AppCommon.h:86
static SLstring shaderPath
Path to GLSL shader programs.
Definition: AppCommon.h:84
void addProgramToLoad(SLGLProgram *&program, const SLstring &vertShaderFile, const SLstring &fragShaderFile)
Add generic GLSL program with shader files to load.
void addTextureToLoad(SLGLTexture *&texture, const SLstring &path, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT)
Add 2D textures with internal image allocation.

Member Data Documentation

◆ _spr3D

SLGLProgram* AppDemoSceneTextureFilter::_spr3D
private

Definition at line 50 of file AppDemoSceneTextureFilter.h.

◆ _tex3D

SLGLTexture* AppDemoSceneTextureFilter::_tex3D
private

Definition at line 49 of file AppDemoSceneTextureFilter.h.

◆ _texB

SLGLTexture* AppDemoSceneTextureFilter::_texB
private

Definition at line 45 of file AppDemoSceneTextureFilter.h.

◆ _texL

SLGLTexture* AppDemoSceneTextureFilter::_texL
private

Definition at line 46 of file AppDemoSceneTextureFilter.h.

◆ _texR

SLGLTexture* AppDemoSceneTextureFilter::_texR
private

Definition at line 48 of file AppDemoSceneTextureFilter.h.

◆ _texT

SLGLTexture* AppDemoSceneTextureFilter::_texT
private

Definition at line 47 of file AppDemoSceneTextureFilter.h.


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