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

Class for test scene for volume rendering of an angiographic MRI scan". More...

#include <AppDemoSceneVolumeRayCast.h>

Inheritance diagram for AppDemoSceneVolumeRayCast:
[legend]

Public Member Functions

 AppDemoSceneVolumeRayCast ()
 
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_mriTex3D
 
SLGLProgram_sp
 

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 test scene for volume rendering of an angiographic MRI scan".

Definition at line 20 of file AppDemoSceneVolumeRayCast.h.

Constructor & Destructor Documentation

◆ AppDemoSceneVolumeRayCast()

AppDemoSceneVolumeRayCast::AppDemoSceneVolumeRayCast ( )

Definition at line 20 of file AppDemoSceneVolumeRayCast.cpp.

21  : SLScene("Volume Ray Cast Test")
22 {
23  info("Volume Rendering of an angiographic MRI scan");
24 }
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneVolumeRayCast::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 52 of file AppDemoSceneVolumeRayCast.cpp.

53 {
54  // Create transfer LUT 1D texture
55  SLVAlphaLUTPoint tfAlphas = {SLAlphaLUTPoint(0.00f, 0.00f),
56  SLAlphaLUTPoint(0.01f, 0.75f),
57  SLAlphaLUTPoint(1.00f, 1.00f)};
58  SLTexColorLUT* tf = new SLTexColorLUT(am,
59  tfAlphas,
60  CLUT_BCGYR);
61 
62  // Load shader and uniforms for volume size
64  "u_volumeX",
65  (SLfloat)_mriTex3D->images()[0]->width());
67  "u_volumeY",
68  (SLfloat)_mriTex3D->images()[0]->height());
70  "u_volumeZ",
71  (SLfloat)_mriTex3D->images().size());
72  _sp->addUniform1f(volX);
73  _sp->addUniform1f(volY);
74  _sp->addUniform1f(volZ);
75 
76  // Create volume rendering material
77  SLMaterial* matVR = new SLMaterial(am,
78  "matVR",
79  _mriTex3D,
80  tf,
81  nullptr,
82  nullptr,
83  _sp);
84 
85  // Create camera
86  SLCamera* cam1 = new SLCamera("Camera 1");
87  cam1->translation(0, 0, 3);
88  cam1->lookAt(0, 0, 0);
89  cam1->focalDist(3);
90  cam1->background().colors(SLCol4f(0, 0, 0));
91  cam1->setInitialState();
93 
94  // Set light
95  SLLightSpot* light1 = new SLLightSpot(am, this, 0.3f);
96  light1->powers(0.1f, 1.0f, 1.0f);
97  light1->attenuation(1, 0, 0);
98  light1->translation(5, 5, 5);
99 
100  // Assemble scene with box node
101  SLNode* scene = new SLNode("Scene");
102  root3D(scene);
103  scene->addChild(light1);
104  scene->addChild(new SLNode(new SLBox(am,
105  -1,
106  -1,
107  -1,
108  1,
109  1,
110  1,
111  "Box",
112  matVR)));
113  scene->addChild(cam1);
114 
115  sv->camera(cam1);
116 }
float SLfloat
Definition: SL.h:173
@ UT_const
constant value
Definition: SLEnums.h:233
SLGLUniform< SLfloat > SLGLUniform1f
Definition: SLGLUniform.h:149
@ CLUT_BCGYR
blue to cyan to green to yellow to red
Definition: SLTexColorLUT.h:30
vector< SLAlphaLUTPoint > SLVAlphaLUTPoint
Definition: SLTexColorLUT.h:57
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.
Axis aligned box mesh.
Definition: SLBox.h:31
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
void addUniform1f(SLGLUniform1f *u)
add float uniform
CVVImage & images()
Definition: SLGLTexture.h:225
Template for a single GLSL uniform variable.
Definition: SLGLUniform.h:24
void attenuation(const SLfloat kConstant, const SLfloat kLinear, const SLfloat kQuadratic)
Definition: SLLight.h:116
void powers(SLfloat ambiPow, SLfloat diffPow, SLfloat specPow, const SLCol4f &ambiDiffSpecCol=SLCol4f::WHITE)
Sets the ambient, diffuse and specular powers all with the same color.
Definition: SLLight.h:74
SLLightSpot class for a spot light source.
Definition: SLLightSpot.h:36
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
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 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
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
SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values.
Definition: SLTexColorLUT.h:70
Alpha point with alpha value and position value between 0-1.
Definition: SLTexColorLUT.h:51

◆ registerAssetsToLoad()

void AppDemoSceneVolumeRayCast::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 27 of file AppDemoSceneVolumeRayCast.cpp.

28 {
29  // Load volume data into 3D texture
30  SLVstring mriImages;
31  for (SLint i = 0; i < 207; ++i)
32  mriImages.push_back(Utils::formatString(al.texturePath() + "i%04u_0000b.png", i));
33 
34  SLint clamping3D = GL_CLAMP_TO_EDGE;
35  if (SLGLState::instance()->getSLVersionNO() > "320")
36  clamping3D = 0x812D; // GL_CLAMP_TO_BORDER
37 
39  mriImages,
40  GL_LINEAR,
41  GL_LINEAR,
42  clamping3D,
43  clamping3D,
44  "mri_head_front_to_back",
45  false);
47  AppCommon::shaderPath + "VolumeRenderingRayCast.vert",
48  AppCommon::shaderPath + "VolumeRenderingRayCast.frag");
49 }
vector< SLstring > SLVstring
Definition: SL.h:201
int SLint
Definition: SL.h:170
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.
SLstring texturePath() const
Definition: SLAssetLoader.h:71
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.
static SLGLState * instance()
Public static instance getter for singleton pattern.
Definition: SLGLState.h:74
string formatString(string fmt_str,...)
Returns a formatted string as sprintf.
Definition: Utils.cpp:320

Member Data Documentation

◆ _mriTex3D

SLGLTexture* AppDemoSceneVolumeRayCast::_mriTex3D
private

Definition at line 45 of file AppDemoSceneVolumeRayCast.h.

◆ _sp

SLGLProgram* AppDemoSceneVolumeRayCast::_sp
private

Definition at line 46 of file AppDemoSceneVolumeRayCast.h.


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