Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::SpatialEntity Class Referenceabstract

A convenience class to generate transformation matrices between the different coordinate systems in use. More...

#include <spatialdata.h>

+ Inheritance diagram for inviwo::SpatialEntity:

Public Member Functions

 SpatialEntity (const glm::mat4 &modelMatrix)
 
 SpatialEntity (const glm::mat4 &modelMatrix, const glm::mat4 &worldMatrix)
 
 SpatialEntity (const SpatialEntity &rhs)
 
SpatialEntityoperator= (const SpatialEntity &that)
 
virtual SpatialEntityclone () const =0
 
glm::vec3 getOffset () const
 
void setOffset (const glm::vec3 &offset)
 
glm::mat3 getBasis () const
 
void setBasis (const glm::mat3 &basis)
 
glm::mat4 getModelMatrix () const
 
void setModelMatrix (const glm::mat4 &modelMatrix)
 
glm::mat4 getWorldMatrix () const
 
void setWorldMatrix (const glm::mat4 &worldMatrix)
 
virtual const SpatialCoordinateTransformergetCoordinateTransformer () const
 
virtual const SpatialCameraCoordinateTransformergetCoordinateTransformer (const Camera &camera) const
 
virtual const AxisgetAxis (size_t index) const =0
 

Protected Attributes

std::unique_ptr< SpatialCoordinateTransformertransformer_
 
std::unique_ptr< SpatialCameraCoordinateTransformercameraTransformer_
 
glm::mat4 modelMatrix_
 
glm::mat4 worldMatrix_
 

Detailed Description

A convenience class to generate transformation matrices between the different coordinate systems in use.

Spatial meta data in Inviwo uses 4 different coordinate systems, they are defined as

  • Index - The voxel indices in the data
  • Data - The corresponding texture coordinates of the data.
  • Model - Defines a local basis and offset for the data.
  • World - Puts the data at a position and angle in the scene.

A matrix is always stored in a 1 dim array, for example a 4x4 matrix would be: m = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) in c/c++, that uses row major, that translates to a matrix like

m[0][0]=1  m[0][1]=2  m[0][2]=3  m[0][3]=4
m[1][0]=5  m[1][1]=6  m[1][2]=7  m[1][3]=8
m[2][0]=9  m[2][1]=10 m[2][2]=11 m[2][3]=12
m[3][0]=13 m[3][1]=14 m[3][2]=15 m[3][3]=16

here the first index represent the row and the second the column: m[row][column]. On the gpu, that uses column major, the same array would look like:

m[0][0]=1  m[1][0]=5  m[2][0]=9  m[3][0]=13
m[0][1]=2  m[1][1]=6  m[2][1]=10 m[3][1]=14
m[0][2]=3  m[1][2]=7  m[2][2]=11 m[3][2]=15
m[0][3]=4  m[1][3]=8  m[2][3]=12 m[3][3]=16

here the first index is the column and the second the row: m[column][row]

For example to create a translation matrix for on the gpu you want:

1  0  0 dx
0  1  0 dy
0  0  1 dz
0  0  0  1

That means that in c/c++ you would create a transposed matrix like:

1  0  0  0
0  1  0  0
0  0  1  0
dx dy dz 1

GLM also uses column major hence in glm you write m[column][row] hence you would enter the a translation like:

m[0][0]=1  m[1][0]=0  m[2][0]=0  m[3][0]=dx
m[0][1]=0  m[1][1]=1  m[2][1]=0  m[3][1]=dy
m[0][2]=0  m[1][2]=0  m[2][2]=1  m[3][2]=dz
m[0][3]=0  m[1][3]=0  m[2][3]=0  m[3][3]=1

This means that they have the same representation as on the gpu.

Member Function Documentation

◆ getAxis()

virtual const Axis * inviwo::SpatialEntity::getAxis ( size_t index) const
pure virtual

returns the axis information corresponding to index

Returns
nullptr if there is no axis for index

Implemented in inviwo::CompositeTransform, inviwo::Layer, inviwo::LightSource, inviwo::Mesh, inviwo::SpatialIdentity, inviwo::Volume, and inviwo::VolumeTetraMesh.


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