70     assert(
mesh && 
"No mesh passed");
 
  104     assert(
mesh && 
"No mesh passed");
 
  135 #ifdef SL_USE_ENTITIES 
  137     SLint parentID = SLScene::entities.getParentID(
this);
 
  138     if (
entityID != INT32_MIN && parentID != INT32_MIN)
 
  141             SLScene::entities.clear();
 
  143             SLScene::entities.deleteEntity(
entityID);
 
  159     assert(
mesh && 
"No mesh passed");
 
  209     assert(child && 
"The child pointer is null.");
 
  210     assert(
this != child && 
"You can not add the node to itself.");
 
  211     assert(!child->
parent() && 
"The child has already a parent.");
 
  217 #ifdef SL_USE_ENTITIES 
  231     assert(insertC && afterC);
 
  232     assert(insertC != afterC);
 
  254 #ifdef SL_USE_ENTITIES 
  256     SLint parentID = SLScene::entities.getParentID(
this);
 
  257     if (
entityID != INT32_MIN && parentID != INT32_MIN)
 
  259         SLScene::entities.deleteChildren(
entityID);
 
  303     assert(!
name.empty());
 
  316     std::deque<SLNode*> list;
 
  326                                 deque<SLNode*>& list,
 
  331         if (child->_mesh == 
mesh)
 
  332             list.push_back(child);
 
  334             child->findChildrenHelper(
mesh, list, findRecursive);
 
  354                                 deque<SLNode*>& list,
 
  359         if (child->drawBits()->get(drawbit))
 
  360             list.push_back(child);
 
  362             child->findChildrenHelper(drawbit, list, findRecursive);
 
  374             (*it)->parent(
nullptr);
 
  387         child->cull3DRec(
sv);
 
  441                     else if (
typeid(*
this) == 
typeid(
SLText))
 
  463         child->cull2DRec(
sv);
 
  471     else if (
typeid(*
this) == 
typeid(
SLText))
 
  499         child->statsRec(stats);
 
  510     assert(ray != 
nullptr);
 
  525     SLbool meshWasHit = 
false;
 
  528     if (
_mesh == 
nullptr)
 
  549         if (
_mesh->
hit(ray, 
this) && !meshWasHit)
 
  559         if (child->hitRec(ray) && !meshWasHit)
 
  618 #ifdef SL_USE_ENTITIES 
  620         SLScene::entities.getEntity(
_entityID)->om.setMatrix(
_om);
 
  656         child->needWMUpdate();
 
  757         _aabb.
mergeWS(child->updateAABBRec(updateAlsoAABBinOS));
 
  761     if (updateAlsoAABBinOS)
 
  780     cout << 
"Node: " << 
_name << endl;
 
  789         cout << 
", " << 
_mesh->
numI() * 3 << 
" tri";
 
  794         cout << 
"- Mesh: none";
 
  808         child->setDrawBitsRec(bit, state);
 
  816         child->setPrimitiveTypeRec(primitiveType);
 
  995     rot.
rotate(angleDeg, localAxis);
 
 1051     if (fabs(cosAngle - 1.0) <= FLT_EPSILON || fabs(cosAngle + 1.0) <= FLT_EPSILON)
 
 1056         localUp = rot * localUp;
 
 1074     if (fabs(scaleFactor) > FLT_EPSILON)
 
 1077         cout << 
"Node can't be scaled: " << 
name().c_str() << endl;
 
 1127                              const function<
void(
SLMesh*)>& cbInformNodes)
 
 1132         forceCPUSkinning = 
true;
 
 1134     bool hasChanges = 
false;
 
 1144         hasChanges |= child->updateMeshSkins(forceCPUSkinning, cbInformNodes);
 
 1157         child->updateMeshAccelStructs();
 
 1168             child->updateMeshMat(setMat, recursive);
 
 1179             child->setMeshMat(mat, recursive);
 
 1183 void SLNode::createInstanceAccelerationStructureTree()
 
 1185     vector<OptixInstance> instances;
 
 1189         if (!child->optixTraversableHandle())
 
 1191             child->createInstanceAccelerationStructureTree();
 
 1194         if (child->optixTraversableHandle())
 
 1196             OptixInstance instance;
 
 1199             float         transform[12] = {mat4x4.
m(0),
 
 1211             memcpy(instance.transform, transform, 
sizeof(
float) * 12);
 
 1214             instance.visibilityMask    = 255;
 
 1215             instance.flags             = OPTIX_INSTANCE_FLAG_NONE;
 
 1216             instance.traversableHandle = child->optixTraversableHandle();
 
 1217             instance.sbtOffset         = 0;
 
 1219             instances.push_back(instance);
 
 1225         _mesh->updateMeshAccelerationStructure();
 
 1226         OptixInstance instance;
 
 1229         float          transform[12] = {mat4x4.
m(0),
 
 1242         memcpy(instance.transform, transform, 
sizeof(
float) * 12);
 
 1247             instance.visibilityMask = 253;
 
 1251             instance.visibilityMask = 255;
 
 1253         instance.flags             = OPTIX_INSTANCE_FLAG_NONE;
 
 1254         instance.traversableHandle = 
_mesh->optixTraversableHandle();
 
 1255         instance.sbtOffset         = 
_mesh->sbtIndex();
 
 1257         instances.push_back(instance);
 
 1260     if (instances.empty())
 
 1265     SLOptixCudaBuffer<OptixInstance> instanceBuffer = SLOptixCudaBuffer<OptixInstance>();
 
 1266     instanceBuffer.alloc_and_upload(instances);
 
 1268     _buildInput.type                       = OPTIX_BUILD_INPUT_TYPE_INSTANCES;
 
 1269     _buildInput.instanceArray.instances    = instanceBuffer.devicePointer();
 
 1270     _buildInput.instanceArray.numInstances = (
SLuint)instances.size();
 
 1272     buildAccelerationStructure();
 
 1275 void SLNode::createInstanceAccelerationStructureFlat()
 
 1277     vector<OptixInstance> instances;
 
 1279     createOptixInstances(instances);
 
 1281     if (instances.empty())
 
 1286     SLOptixCudaBuffer<OptixInstance> instanceBuffer = SLOptixCudaBuffer<OptixInstance>();
 
 1287     instanceBuffer.alloc_and_upload(instances);
 
 1289     _buildInput.type                       = OPTIX_BUILD_INPUT_TYPE_INSTANCES;
 
 1290     _buildInput.instanceArray.instances    = instanceBuffer.devicePointer();
 
 1291     _buildInput.instanceArray.numInstances = (
SLuint)instances.size();
 
 1293     buildAccelerationStructure();
 
 1296 void SLNode::createOptixInstances(vector<OptixInstance>& instances)
 
 1300         child->createOptixInstances(instances);
 
 1305         _mesh->updateMeshAccelerationStructure();
 
 1306         OptixInstance instance;
 
 1309         float          transform[12] = {mat4x4.
m(0),
 
 1321         memcpy(instance.transform, transform, 
sizeof(
float) * 12);
 
 1324         if (
_mesh->
name().find(
"LightSpot") != -1 ||
 
 1327             instance.visibilityMask = 252;
 
 1329         else if (
_mesh->
name().find(
"LightRect") != -1)
 
 1331             instance.visibilityMask = 254;
 
 1335             instance.visibilityMask = 255;
 
 1337         instance.flags             = OPTIX_INSTANCE_FLAG_NONE;
 
 1338         instance.traversableHandle = 
_mesh->optixTraversableHandle();
 
 1339         instance.sbtOffset         = 
_mesh->sbtIndex();
 
 1341         instances.push_back(instance);
 
#define PROFILE_FUNCTION()
 
#define SL_DB_ONLYEDGES
Draw only hard edges.
 
#define SL_DB_WITHEDGES
Draw faces with hard edges.
 
#define SL_DB_OVERDRAW
Draw node over all other nodes.
 
#define SL_DB_VOXELS
Draw the voxels of the uniform grid.
 
#define SL_DB_HIDDEN
Flags an object as hidden.
 
SLTransformSpace
Describes the relative space a transformation is applied in.
 
SLVec3< SLfloat > SLVec3f
 
Defines an axis aligned bounding box.
 
void mergeWS(SLAABBox &bb)
Merges the bounding box bb to this one by extending this one axis aligned.
 
SLbool isHitInWS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.
 
void isVisible(SLbool visible)
 
void minWS(const SLVec3f &minC)
 
void fromWStoOS(const SLVec3f &minWS, const SLVec3f &maxWS, const SLMat4f &wmI)
Recalculate min and max before transformation in object coords.
 
void maxWS(const SLVec3f &maxC)
 
void updateAxisWS(const SLMat4f &wm)
Updates the axis of the owning node.
 
void setCenterAndRadiusWS()
Calculates center & radius of the bounding sphere around the AABB.
 
SLAnimSkeleton keeps track of a skeletons joints and animations.
 
SLAnimation is the base container for all animation data.
 
Active or visible camera node class.
 
SLbool get(SLuint bit)
Returns the specified bit.
 
void set(SLuint bit, SLbool state)
Sets the specified bit to the passed state.
 
void allOff()
Turns all bits off.
 
SLLightDirect class for a directional light source.
 
Light node class for a rectangular light source.
 
SLLightSpot class for a spot light source.
 
void rotation(const T angleDEG, const SLVec3< T > &axis)
Sets the rotation components
 
SLVec3< T > translation() const
 
void posAtUp(T PosX, T PosY, T PosZ, T dirAtX=0, T dirAtY=0, T dirAtZ=0, T dirUpX=0, T dirUpY=0, T dirUpZ=0)
Same as lightAt.
 
void setMatrix(const SLMat4 &A)
Set matrix by other 4x4 matrix.
 
void rotation(T degAng, const SLVec3< T > &axis, SLbool keepTranslation=true)
Sets the rotation with or without overwriting the translation.
 
void invert()
Inverts the matrix.
 
void rotate(T degAng, T axisx, T axisy, T axisz)
 
void multiply(const SLMat4 &A)
 
SLMat4< T > inverted() const
Computes the inverse of a 4x4 non-singular matrix.
 
void identity()
Sets the identity matrix.
 
void scaling(T sxyz, SLbool keepTrans=true)
Sets the scaling with or without overwriting the translation.
 
void translate(T tx, T ty, T tz=0)
 
Defines a standard CG material with textures and a shader program.
 
SLVNode & nodesVisible2D()
 
SLVNode & nodesVisible3D()
 
void emissive(const SLCol4f &emis)
 
An SLMesh object is a triangulated mesh, drawn with one draw call.
 
SLGLPrimitiveType primitive() const
 
void transformSkin(bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
Transforms the vertex positions and normals with by joint weights.
 
virtual void init(SLNode *node)
SLMesh::shapeInit sets the transparency flag of the AABB.
 
SLbool accelStructIsOutOfDate()
 
virtual void draw(SLSceneView *sv, SLNode *node, SLuint intances=0)
 
SLbool hit(SLRay *ray, SLNode *node)
 
void addStats(SLNodeStats &stats)
 
virtual void buildAABB(SLAABBox &aabb, const SLMat4f &wmNode)
 
const SLAnimSkeleton * skeleton() const
 
SLNode represents a node in a hierarchical scene graph.
 
bool updateMeshSkins(bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
Update all skinned meshes recursively.
 
void resetToInitialState()
 
virtual void drawMesh(SLSceneView *sv)
Draws the single mesh.
 
void rotation(const SLQuat4f &rot, SLTransformSpace relativeTo=TS_parent)
 
function< void()> _onUpdateCB
Optional lambda callback once per update.
 
void addChild(SLNode *child)
 
SLubyte _levelForSM
Level of LOD to use for shadow mapping (0 = the visible one will be drawn)
 
SLMat4f _wmI
inverse world matrix
 
SLbool drawBit(SLuint bit)
 
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
 
bool removeMesh()
Returns true if a mesh was assigned and set it to nullptr.
 
SLAnimation * _animation
animation of the node
 
virtual void needUpdate()
 
SLDrawBits _drawBits
node level drawing flags
 
void rotate(const SLQuat4f &rot, SLTransformSpace relativeTo=TS_object)
 
SLAABBox _aabb
axis aligned bounding box
 
SLNode * _parent
pointer to the parent node
 
const SLMat4f & updateAndGetWM() const
 
static SLuint numWMUpdates
NO. of calls to updateWMRec per frame.
 
virtual SLNode * copyRec()
 
SLMat4f _om
object matrix for local transforms
 
static unsigned int instanceIndex
???
 
bool insertChild(SLNode *insertC, SLNode *afterC)
 
SLbool _isAABBUpToDate
is the saved aabb still valid
 
const SLAnimSkeleton * skeleton()
Returns the first skeleton found in the meshes.
 
void setPrimitiveTypeRec(SLGLPrimitiveType primitiveType)
 
SLfloat _minLodCoverage
Min. LOD coverage for visibility (0.0 < _minLodCoverage < 1.0)
 
SLVec3f translationOS() const
 
SLMat4f _initialOM
the initial om state
 
bool _isSelected
flag if node and one or more of its meshes are selected
 
bool _castsShadows
flag if meshes of node should cast shadows
 
void setMeshMat(SLMaterial *mat, bool recursive)
Set the mesh material recursively.
 
virtual void cullChildren3D(SLSceneView *sv)
Initializer function to call SLNode::cull3DRec recursively.
 
virtual void addMesh(SLMesh *mesh)
 
void updateMeshAccelStructs()
 
SLVNode _children
vector of children nodes
 
virtual void statsRec(SLNodeStats &stats)
 
const SLMat4f & updateAndGetWMI() const
 
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
 
SLMesh * _mesh
pointer to a single mesh
 
void updateMeshMat(std::function< void(SLMaterial *m)> setMat, bool recursive)
Updates the mesh material recursively with a material lambda.
 
SLNode(const SLstring &name="Node")
Construct a new SLNode::SLNode object.
 
virtual SLAABBox & updateAABBRec(SLbool updateAlsoAABBinOS)
 
deque< T * > findChildren(const SLstring &name="", SLbool findRecursive=true, SLbool canContain=false)
 
SLMat4f _wm
world matrix for world transform
 
virtual void cull2DRec(SLSceneView *sv)
 
bool removeChild(SLNode *child)
remove child from vector of children. Removes false if not found, else true.
 
void scaleToCenter(SLfloat maxDim)
 
SLbool _isWMIUpToDate
is the inverse WM of this node still valid
 
SLint _entityID
ID in the SLVEntity graph for Data Oriented Design.
 
SLint _depth
depth of the node in a scene tree
 
void findChildrenHelper(const SLstring &name, deque< T * > &list, SLbool findRecursive, SLbool canContain=false)
 
virtual bool hitRec(SLRay *ray)
 
SLbool _isWMUpToDate
is the WM of this node still valid
 
void setDrawBitsRec(SLuint bit, SLbool state)
 
virtual void cull3DRec(SLSceneView *sv)
 
void rotateAround(const SLVec3f &point, SLVec3f &axis, SLfloat angleDeg, SLTransformSpace relativeTo=TS_world)
 
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
 
Base class for all other classes.
 
void name(const SLstring &Name)
 
SLstring _name
name of an object
 
const SLstring & name() const
 
SLParticleSystem creates a particle meshes from a point primitive buffer.
 
void setNotVisibleInFrustum()
 
SLMat4< T > toMat4() const
 
Ray class with ray and intersection properties.
 
SLVec3f origin
Vector to the origin of ray in WS.
 
SLMesh * hitMesh
Points to the intersected mesh.
 
SLVec3f dir
Direction vector of ray in WS.
 
SLfloat length
length from origin to an intersection
 
SLNode * hitNode
Points to the intersected node.
 
void setDirOS(const SLVec3f &Dir)
Setter for the rays direction in object space also setting the inverse direction.
 
SLVec3f originOS
Vector to the origin of ray in OS.
 
SLSceneView * sv
Pointer to the sceneview.
 
SLbool isShaded() const
Returns true if a shadow ray hits an object on the ray to the light.
 
SceneView class represents a dynamic real time 3D view onto the scene.
 
SLVNode & nodesOpaque3D()
 
SLVNode & nodesBlended2D()
 
std::unordered_set< SLMaterial * > & visibleMaterials3D()
 
void camera(SLCamera *camera)
 
SLVNode & nodesBlended3D()
 
SLVNode & nodesOverdrawn()
 
void doFrustumCulling(SLbool doFC)
 
std::unordered_set< SLMaterial * > & visibleMaterials2D()
 
SLText creates a mesh using a textured font from SLTexFont.
 
void set(const T X, const T Y, const T Z)
 
T dot(const SLVec3 &v) const
 
SLEntity is the Data Oriented Design version of a SLNode.
 
Struct for scene graph statistics.
 
SLuint numNodes
NO. of children nodes.
 
SLuint numLights
NO. of lights in mesh.
 
SLuint numNodesLeaf
NO. of leaf nodes.
 
SLuint numNodesGroup
NO. of group nodes.
 
SLuint numBytes
NO. of bytes allocated.