Developer Documentation
ACG::SceneGraph::TextureNode Class Reference

#include <ACG/Scenegraph/TextureNode.hh>

Inheritance diagram for ACG::SceneGraph::TextureNode:
ACG::SceneGraph::BaseNode ACG::SceneGraph::EnvMapNode

Classes

class  TextureInfo
 

Public Member Functions

 TextureNode (BaseNode *_parent=0, const std::string &_name="<TextureNode>", bool _texture_repeat=true, GLint _texture_filter=GL_LINEAR)
 Default constructor. Applies all properties. More...
 
virtual ~TextureNode ()
 Destructor. More...
 
 ACG_CLASSNAME (TextureNode)
 set class name
 
bool alpha ()
 get transparency status More...
 
void set_alpha (bool _status)
 set transparency status More...
 
bool repeat ()
 get texture repeat status More...
 
void set_repeat (bool _status)
 set texture repeat status More...
 
GLint filter ()
 get texture filter More...
 
void set_filter (GLint _filter)
 set texture filter More...
 
void set_texture_mode (GLenum _mode)
 
void enable_mipmapping ()
 Enable mipmapping. More...
 
void disable_mipmapping ()
 Disable mipmapping. More...
 
bool mipmapping () const
 Get mipmapping status. More...
 
Change active texture
bool activateTexture (GLuint _id)
 Set active Texture. More...
 
GLuint activeTexture ()
 Get active Texture. More...
 
bool read (const char *_filename)
 Uses a QImage to load the texture from the given file. More...
 
void set_texture (const QImage &_image)
 Uses a QImage to set the texture. More...
 
void set_texture (const float *_image, int _width, int _height)
 Uses a float buffer to set the texture. More...
 
void set_texture (const unsigned char *_image, int _width, int _height)
 Uses a byte buffer to set the texture. More...
 
Change specific texture
bool read (const char *_filename, GLuint _id)
 Uses a QImage to load the texture from the given file. More...
 
void set_texture (const QImage &_image, GLuint _id)
 Uses a QImage to set the texture. More...
 
void set_texture (const float *_image, int _width, int _height, GLuint _id)
 Uses a float buffer to set the texture. More...
 
void set_texture (const unsigned char *_image, int _width, int _height, GLuint _id)
 Uses a byte buffer to set the texture. More...
 
SceneGraph traversal functions
void enter (GLState &_state, const DrawModes::DrawMode &_drawmode) override
 set default texture and states for the nodes children More...
 
void leave (GLState &_state, const DrawModes::DrawMode &_drawmode) override
 Unbind Texture. More...
 
void enterPick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) override
 Do nothing in picking. More...
 
void leavePick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) override
 Do nothing in picking. More...
 
- Public Member Functions inherited from ACG::SceneGraph::BaseNode
 BaseNode (BaseNode *_parent=0, std::string _name="<unknown>")
 Default constructor. More...
 
 BaseNode (BaseNode *_parent, BaseNode *_child, std::string _name="<unknown>")
 Put this node between _parent and _child. More...
 
virtual ~BaseNode ()
 Destructor. More...
 
void delete_subtree ()
 Delete the whole subtree of this node. More...
 
virtual const std::string & className () const =0
 Return class name (implemented by the ACG_CLASSNAME macro)
 
virtual DrawModes::DrawMode availableDrawModes () const
 
virtual void boundingBox (Vec3d &, Vec3d &)
 
virtual void enter (GLState &, const DrawModes::DrawMode &)
 
virtual void enter (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode)
 
virtual void draw (GLState &, const DrawModes::DrawMode &)
 Draw this node using the draw modes _drawMode. More...
 
virtual void getRenderObjects (IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
 Deferred draw call with shader based renderer. More...
 
virtual void leave (GLState &, const DrawModes::DrawMode &)
 
virtual void leave (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode)
 
virtual void enterPick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode)
 
virtual void pick (GLState &, PickTarget)
 
virtual void leavePick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode)
 
void enablePicking (bool _enable)
 
bool pickingEnabled ()
 
virtual void mouseEvent (GLState &, QMouseEvent *)
 Handle mouse event (some interaction, e.g. modeling) More...
 
void setDirty (bool _dirty=true)
 mark node for redrawn More...
 
bool isDirty () const
 Check if node should be redrawn. More...
 
ChildIter childrenBegin ()
 Returns: begin-iterator of children. More...
 
ConstChildIter childrenBegin () const
 Same but cont. More...
 
ChildIter childrenEnd ()
 Returns: end-iterator of children. More...
 
ConstChildIter childrenEnd () const
 Same but const. More...
 
ChildRIter childrenRBegin ()
 Returns: reverse begin-iterator of children. More...
 
ConstChildRIter childrenRBegin () const
 Same but const. More...
 
ChildRIter childrenREnd ()
 Returns: reverse end-iterator of children. More...
 
ConstChildRIter childrenREnd () const
 Same but const. More...
 
void push_back (BaseNode *_node)
 Insert _node at the end of the list of children. More...
 
void remove (ChildIter _pos)
 
size_t nChildren () const
 number of children More...
 
ChildIter find (BaseNode *_node)
 
BaseNodefind (const std::string &_name)
 
BaseNodeparent ()
 Get the nodes parent node. More...
 
const BaseNodeparent () const
 Get the nodes parent node. More...
 
void set_parent (BaseNode *_parent)
 Set the parent of this node. More...
 
StatusMode status () const
 Get node's status. More...
 
void set_status (StatusMode _s)
 Set the status of this node. More...
 
void hide ()
 Hide Node: set status to HideNode. More...
 
void show ()
 Show node: set status to Active. More...
 
bool visible ()
 Is node visible (status == Active)? More...
 
bool hidden ()
 Is node not visible (status != Active)? More...
 
std::string name () const
 Returns: name of node (needs not be unique) More...
 
void name (const std::string &_name)
 rename a node More...
 
unsigned int id () const
 
DrawModes::DrawMode drawMode () const
 Return the own draw modes of this node. More...
 
void drawMode (DrawModes::DrawMode _drawMode)
 
unsigned int traverseMode () const
 Return how the node should be traversed. More...
 
void setTraverseMode (unsigned int _mode)
 Set traverse mode for node. More...
 
MultipassBitMask multipassStatus () const
 Get the current multipass settings for the nodes status functions. More...
 
void setMultipassStatus (const MultipassBitMask _passStatus)
 Set multipass settings for the nodes status functions. More...
 
void multipassStatusSetActive (const unsigned int _i, bool _active)
 Set multipass status to traverse in a specific pass. More...
 
bool multipassStatusActive (const unsigned int _i) const
 Get multipass status to traverse in a specific pass. More...
 
MultipassBitMask multipassNode () const
 Get the current multipass settings for the node. More...
 
void setMultipassNode (const MultipassBitMask _passNode)
 Set multipass settings for the node. More...
 
void multipassNodeSetActive (const unsigned int _i, bool _active)
 Set Node status to traverse in a specific pass. More...
 
bool multipassNodeActive (const unsigned int _i) const
 Get Node status to traverse in a specific pass. More...
 
void setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON)
 Set custom shaders. More...
 
void setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_tessControlShaderFile, const std::string &_tessEvalShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON)
 Set custom shaders. More...
 
void setRenderObjectUniformPool (const GLSL::UniformPool *_pool)
 Set uniforms for shader based rendering. More...
 
const GLSL::UniformPoolgetRenderObjectUniformPool ()
 Get uniforms for shader based rendering. More...
 
void setRenderObjectTexture (int _samplerSlot, GLuint _texId, GLenum _texType=GL_TEXTURE_2D)
 Set textures for shader based rendering. More...
 
void setRenderObjectModifier (RenderObjectModifier *_modifier)
 Set modifier for render objects. More...
 
RenderObjectModifiergetRenderObjectModifier ()
 Get render-object modifier. More...
 
void applyRenderObjectSettings (DrawModes::DrawModePrimitive _primitive, RenderObject *_obj) const
 Set shaders, textures and uniforms as provided by user to a render-object. More...
 

Private Member Functions

void setTextureDataGL (GLuint _textureId, GLenum _target, GLint _width, GLint _height, GLenum _format, GLenum _type, const void *_data)
 
void checkEmpty ()
 Check if a texture is already generated by this Node. More...
 
int available (GLuint _id)
 check this node for a texture More...
 
void updateMipmaps (bool _mipmap)
 Build mip maps of textures that don't have one yet. More...
 

Private Attributes

std::vector< TextureInfotextures_
 
bool alpha_
 
bool texture_repeat_
 
GLenum tex_mode_
 
GLint texture_filter_
 
bool mipmapping_globally_active_
 
bool last_mipmapping_status_
 
bool mipmapping_
 
int activeTexture_
 currently active texture More...
 
DrawModes::DrawMode open_volume_mesh_texture_draw_modes_
 OpenVolumeMesh DrawModes using textures. More...
 

Setting textures

GLuint add_texture (const QImage &_image)
 Add a texture to this node. More...
 
void applyTextureParameters (int _id)
 
void applyGLSettings ()
 

Additional Inherited Members

- Public Types inherited from ACG::SceneGraph::BaseNode
enum  StatusMode { Active = 0x1 , HideNode = 0x2 , HideChildren = 0x4 , HideSubtree = 0x8 }
 Status modi. More...
 
enum  TraverseMode { NodeFirst = 0x1 , ChildrenFirst = 0x2 , SecondPass = 0x4 }
 Node traverse types. More...
 
typedef std::vector< BaseNode * >::const_iterator ConstChildIter
 allows to iterate over children More...
 
typedef std::vector< BaseNode * >::iterator ChildIter
 allows to iterate over children More...
 
typedef std::vector< BaseNode * >::const_reverse_iterator ConstChildRIter
 allows to reverse iterate over children More...
 
typedef std::vector< BaseNode * >::reverse_iterator ChildRIter
 allows to reverse iterate over children More...
 
enum  PASSES {
  NOPASS = 0 , ALLPASSES = 1 << 0 , PASS_1 = 1 << 1 , PASS_2 = 1 << 2 ,
  PASS_3 = 1 << 3 , PASS_4 = 1 << 4 , PASS_5 = 1 << 5 , PASS_6 = 1 << 6 ,
  PASS_7 = 1 << 7 , PASS_8 = 1 << 8
}
 This enum should be used to enable rendering of a node in different. More...
 
typedef unsigned int MultipassBitMask
 Multipass pass bit mask type. More...
 

Detailed Description

Set Texture for this node and all its children. All changes will be done in the enter() method undone in the leave() method. Enable Environment Mapping if you need it. To use Blending or AlphaTest use a MaterialNode.

Definition at line 87 of file TextureNode.hh.

Constructor & Destructor Documentation

◆ TextureNode()

ACG::SceneGraph::TextureNode::TextureNode ( BaseNode _parent = 0,
const std::string &  _name = "<TextureNode>",
bool  _texture_repeat = true,
GLint  _texture_filter = GL_LINEAR 
)

Default constructor. Applies all properties.

Definition at line 70 of file TextureNode.cc.

◆ ~TextureNode()

ACG::SceneGraph::TextureNode::~TextureNode ( )
virtual

Destructor.

Definition at line 94 of file TextureNode.cc.

Member Function Documentation

◆ activateTexture()

bool ACG::SceneGraph::TextureNode::activateTexture ( GLuint  _id)

Set active Texture.

Sets the active texture of this node to the given id

Definition at line 566 of file TextureNode.cc.

◆ activeTexture()

GLuint ACG::SceneGraph::TextureNode::activeTexture ( )

Get active Texture.

Gets the currently active texture of this node

Definition at line 556 of file TextureNode.cc.

◆ add_texture()

GLuint ACG::SceneGraph::TextureNode::add_texture ( const QImage &  _image)

Add a texture to this node.

Definition at line 465 of file TextureNode.cc.

◆ alpha()

bool ACG::SceneGraph::TextureNode::alpha ( )
inline

get transparency status

Definition at line 104 of file TextureNode.hh.

◆ applyGLSettings()

void ACG::SceneGraph::TextureNode::applyGLSettings ( )
private

Set basic gl settings

Definition at line 128 of file TextureNode.cc.

◆ applyTextureParameters()

void ACG::SceneGraph::TextureNode::applyTextureParameters ( int  _id)
private

Apply the internal texture properties to the currently active texture

Definition at line 142 of file TextureNode.cc.

◆ available()

int ACG::SceneGraph::TextureNode::available ( GLuint  _id)
private

check this node for a texture

Returns the id of the texture if this node handles the texture.
If not -1.

Definition at line 386 of file TextureNode.cc.

◆ checkEmpty()

void ACG::SceneGraph::TextureNode::checkEmpty ( )
private

Check if a texture is already generated by this Node.

This function will create a texture if no texture exists and set the activeTexture_ to the new one.

Definition at line 370 of file TextureNode.cc.

◆ disable_mipmapping()

void ACG::SceneGraph::TextureNode::disable_mipmapping ( )

Disable mipmapping.

Definition at line 190 of file TextureNode.cc.

◆ enable_mipmapping()

void ACG::SceneGraph::TextureNode::enable_mipmapping ( )

Enable mipmapping.

Definition at line 180 of file TextureNode.cc.

◆ enter()

void ACG::SceneGraph::TextureNode::enter ( GLState _state,
const DrawModes::DrawMode _drawmode 
)
overridevirtual

set default texture and states for the nodes children

Reimplemented from ACG::SceneGraph::BaseNode.

Definition at line 487 of file TextureNode.cc.

◆ enterPick()

void ACG::SceneGraph::TextureNode::enterPick ( GLState _state,
PickTarget  _target,
const DrawModes::DrawMode _drawMode 
)
overridevirtual

Do nothing in picking.

Reimplemented from ACG::SceneGraph::BaseNode.

Definition at line 546 of file TextureNode.cc.

◆ filter()

GLint ACG::SceneGraph::TextureNode::filter ( )
inline

get texture filter

Definition at line 116 of file TextureNode.hh.

◆ leave()

void ACG::SceneGraph::TextureNode::leave ( GLState _state,
const DrawModes::DrawMode _drawmode 
)
overridevirtual

Unbind Texture.

Reimplemented from ACG::SceneGraph::BaseNode.

Definition at line 530 of file TextureNode.cc.

◆ leavePick()

void ACG::SceneGraph::TextureNode::leavePick ( GLState _state,
PickTarget  _target,
const DrawModes::DrawMode _drawMode 
)
overridevirtual

Do nothing in picking.

Reimplemented from ACG::SceneGraph::BaseNode.

Definition at line 550 of file TextureNode.cc.

◆ mipmapping()

bool ACG::SceneGraph::TextureNode::mipmapping ( ) const
inline

Get mipmapping status.

Definition at line 130 of file TextureNode.hh.

◆ read() [1/2]

bool ACG::SceneGraph::TextureNode::read ( const char *  _filename)

Uses a QImage to load the texture from the given file.

This function will change the active texture.

Definition at line 108 of file TextureNode.cc.

◆ read() [2/2]

bool ACG::SceneGraph::TextureNode::read ( const char *  _filename,
GLuint  _id 
)

Uses a QImage to load the texture from the given file.

This function will change the given texture if available.

Definition at line 397 of file TextureNode.cc.

◆ repeat()

bool ACG::SceneGraph::TextureNode::repeat ( )
inline

get texture repeat status

Definition at line 110 of file TextureNode.hh.

◆ set_alpha()

void ACG::SceneGraph::TextureNode::set_alpha ( bool  _status)
inline

set transparency status

Definition at line 107 of file TextureNode.hh.

◆ set_filter()

void ACG::SceneGraph::TextureNode::set_filter ( GLint  _filter)
inline

set texture filter

Definition at line 119 of file TextureNode.hh.

◆ set_repeat()

void ACG::SceneGraph::TextureNode::set_repeat ( bool  _status)
inline

set texture repeat status

Definition at line 113 of file TextureNode.hh.

◆ set_texture() [1/6]

void ACG::SceneGraph::TextureNode::set_texture ( const float *  _image,
int  _width,
int  _height 
)

Uses a float buffer to set the texture.

This function will change the active texture.
Assumptions: Buffer is in RGBA format, and either power of two size or using a graphics card that supports arbitrary textures.

Definition at line 354 of file TextureNode.cc.

◆ set_texture() [2/6]

void ACG::SceneGraph::TextureNode::set_texture ( const float *  _image,
int  _width,
int  _height,
GLuint  _id 
)

Uses a float buffer to set the texture.

This function will change the given texture if available.
Assumptions: Buffer is in RGBA format, and either power of two size or using a graphics card that supports arbitrary textures.

Definition at line 430 of file TextureNode.cc.

◆ set_texture() [3/6]

void ACG::SceneGraph::TextureNode::set_texture ( const QImage &  _image)

Uses a QImage to set the texture.

This function will change the active texture.

Definition at line 305 of file TextureNode.cc.

◆ set_texture() [4/6]

void ACG::SceneGraph::TextureNode::set_texture ( const QImage &  _image,
GLuint  _id 
)

Uses a QImage to set the texture.

This function will change the given texture if available.

Definition at line 413 of file TextureNode.cc.

◆ set_texture() [5/6]

void ACG::SceneGraph::TextureNode::set_texture ( const unsigned char *  _image,
int  _width,
int  _height 
)

Uses a byte buffer to set the texture.

This function will change the active texture.
Assumptions: Buffer is in RGBA format, and either power of two size or using a graphics card that supports arbitrary textures.

Definition at line 286 of file TextureNode.cc.

◆ set_texture() [6/6]

void ACG::SceneGraph::TextureNode::set_texture ( const unsigned char *  _image,
int  _width,
int  _height,
GLuint  _id 
)

Uses a byte buffer to set the texture.

This function will change the given texture if available.
Assumptions: Buffer is in RGBA format, and either power of two size or using a graphics card that supports arbitrary textures.

Definition at line 446 of file TextureNode.cc.

◆ set_texture_mode()

void ACG::SceneGraph::TextureNode::set_texture_mode ( GLenum  _mode)
inline

Definition at line 121 of file TextureNode.hh.

◆ setTextureDataGL()

void ACG::SceneGraph::TextureNode::setTextureDataGL ( GLuint  _textureId,
GLenum  _target,
GLint  _width,
GLint  _height,
GLenum  _format,
GLenum  _type,
const void *  _data 
)
private

Definition at line 200 of file TextureNode.cc.

◆ updateMipmaps()

void ACG::SceneGraph::TextureNode::updateMipmaps ( bool  _mipmap)
private

Build mip maps of textures that don't have one yet.

Generate mipmaps for each texture that does not have one yet.

Definition at line 244 of file TextureNode.cc.

Member Data Documentation

◆ activeTexture_

int ACG::SceneGraph::TextureNode::activeTexture_
private

currently active texture

This index is an index to the textures_ vector! Not the GLuint!!

Definition at line 346 of file TextureNode.hh.

◆ alpha_

bool ACG::SceneGraph::TextureNode::alpha_
private

Definition at line 315 of file TextureNode.hh.

◆ last_mipmapping_status_

bool ACG::SceneGraph::TextureNode::last_mipmapping_status_
private

Definition at line 321 of file TextureNode.hh.

◆ mipmapping_

bool ACG::SceneGraph::TextureNode::mipmapping_
private

Definition at line 322 of file TextureNode.hh.

◆ mipmapping_globally_active_

bool ACG::SceneGraph::TextureNode::mipmapping_globally_active_
private

Definition at line 320 of file TextureNode.hh.

◆ open_volume_mesh_texture_draw_modes_

DrawModes::DrawMode ACG::SceneGraph::TextureNode::open_volume_mesh_texture_draw_modes_
private

OpenVolumeMesh DrawModes using textures.

Texturing will be activated for all DrawModes which are combined in this DrawMode

Definition at line 352 of file TextureNode.hh.

◆ tex_mode_

GLenum ACG::SceneGraph::TextureNode::tex_mode_
private

Definition at line 317 of file TextureNode.hh.

◆ texture_filter_

GLint ACG::SceneGraph::TextureNode::texture_filter_
private

Definition at line 318 of file TextureNode.hh.

◆ texture_repeat_

bool ACG::SceneGraph::TextureNode::texture_repeat_
private

Definition at line 316 of file TextureNode.hh.

◆ textures_

std::vector<TextureInfo> ACG::SceneGraph::TextureNode::textures_
private

Definition at line 314 of file TextureNode.hh.


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