H3D API  2.4.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
X3DBackgroundNode.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __X3DBACKGROUNDNODE_H__
30 #define __X3DBACKGROUNDNODE_H__
31 
32 #include <H3D/X3DBindableNode.h>
34 #include <H3D/MFFloat.h>
35 #include <H3D/MFColor.h>
36 #include <H3D/SFMatrix4f.h>
37 #include <H3D/SFMatrix4d.h>
38 #include <H3D/SFFloat.h>
39 
40 namespace H3D {
41 
125  class H3DAPI_API X3DBackgroundNode :
126  public X3DBindableNode {
127  public:
128 
130 
132  X3DBackgroundNode( Inst< SFSetBind > _set_bind = 0,
133  Inst< SFNode > _metadata = 0,
134  Inst< SFTime > _bindTime = 0,
135  Inst< SFBool > _isBound = 0,
136  Inst< DisplayList > _displayList = 0,
137  Inst< MFFloat > _groundAngle = 0,
138  Inst< MFColor > _groundColor = 0,
139  Inst< MFFloat > _skyAngle = 0,
140  Inst< MFColor > _skyColor = 0,
141  Inst< SFFloat > _transparency = 0);
142 
144  static inline X3DBackgroundNode *getActive() {
145  return static_cast< X3DBackgroundNode * >
146  ( X3DBindableNode::getActive( "X3DBackgroundNode" ) );
147  }
148 
150  virtual void traverseSG( TraverseInfo &ti ) {
152  if( localToGlobal->getValue() != ti.getAccForwardMatrix() ) {
153  localToGlobal->setValue( ti.getAccForwardMatrix() );
154  }
155  }
156 
160  virtual void renderBackground();
161 
164  virtual RGBA glClearColor() {
165  if( skyColor->size() == 1 ) {
166  RGB c = skyColor->getValueByIndex( 0 );
167  H3DFloat a = 1.0f - transparency->getValue();
168  return RGBA( c.r*a, c.g*a, c.b*a, a );
169  } else {
170  return RGBA( 0, 0, 0, 0 );
171  }
172  }
173 
177  virtual void render();
178 
180  H3DUniquePtr< DisplayList > displayList;
181 
190  H3DUniquePtr< MFFloat > groundAngle;
191 
192 
207  H3DUniquePtr< MFColor > groundColor;
208 
219  H3DUniquePtr< MFFloat > skyAngle;
220 
235  H3DUniquePtr< MFColor > skyColor;
236 
243  H3DUniquePtr< SFFloat > transparency;
244 
247  protected:
250  H3DUniquePtr< SFMatrix4f > localToGlobal;
251 
254  H3DUniquePtr< SFMatrix4d > projectionMatrix;
255 
256 
257  bool render_enabled;
258  };
259 }
260 
261 #endif
262 
Header file for H3DDisplayListObject.
Contains the MFColor field class.
Contains the MFFloat field class.
Contains the SFFloat field class.
Contains the SFMatrix4d field class.
Contains the SFMatrix4f field class.
Header file for X3DBindableNode, X3D scene-graph node.
We use the Field's lazy evaluation mechanisms to manage the GL display lists for rendering,...
Definition: H3DDisplayListObject.h:60
virtual void traverseSG(TraverseInfo &ti)
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph.
Definition: Node.cpp:50
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
const Matrix4f & getAccForwardMatrix()
Get the accumulated forward transformation matrix, i.e.
Definition: TraverseInfo.h:363
X3DBackgroundNode is the abstract type from which all backgrounds inherit.
Definition: X3DBackgroundNode.h:126
H3DUniquePtr< SFFloat > transparency
The transparency field simply specifies the transparency for the sky and ground.
Definition: X3DBackgroundNode.h:243
static X3DBackgroundNode * getActive()
Convenience function to get the top of the X3DBackgroundNode stack.
Definition: X3DBackgroundNode.h:144
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: X3DBackgroundNode.h:246
H3DUniquePtr< MFColor > groundColor
The groundColor field specifies the colour of the ground at the various angles on the ground partial ...
Definition: X3DBackgroundNode.h:207
H3DUniquePtr< MFColor > skyColor
The skyColor field specifies the colour of the sky at various angles on the sky sphere.
Definition: X3DBackgroundNode.h:235
virtual void traverseSG(TraverseInfo &ti)
Saves the accForwardMatrix for use in the render function.
Definition: X3DBackgroundNode.h:150
virtual RGBA glClearColor()
Returns the color that OpenGL should clear the buffer with before starting to render to it.
Definition: X3DBackgroundNode.h:164
H3DUniquePtr< MFFloat > groundAngle
The groundAngle field specifies the angles from the nadir that the concentric circles of colour appea...
Definition: X3DBackgroundNode.h:190
H3DUniquePtr< SFMatrix4f > localToGlobal
A field that transforms from local to global space.
Definition: X3DBackgroundNode.h:250
H3DUniquePtr< MFFloat > skyAngle
The skyAngle field specifies the angles from the zenith in which concentric circles of colour appear.
Definition: X3DBackgroundNode.h:219
H3DUniquePtr< DisplayList > displayList
The DisplayList instance handling the OpenGL caching of this object.
Definition: X3DBackgroundNode.h:180
H3DUniquePtr< SFMatrix4d > projectionMatrix
Projection matrix for background C++ field only.
Definition: X3DBackgroundNode.h:254
X3DBindableNode is the abstract base type for all bindable children nodes, including Background,...
Definition: X3DBindableNode.h:108
static X3DBindableNode * getActive(const string &bindable_stack_name)
Returns the active bindable instance, i.e.
Definition: X3DBindableNode.h:149
float H3DFloat
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194