X3DBackgroundNode.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __X3DBACKGROUNDNODE_H__
00030 #define __X3DBACKGROUNDNODE_H__
00031 
00032 #include "X3DBindableNode.h"
00033 #include "H3DDisplayListObject.h"
00034 #include "MFFloat.h"
00035 #include "MFColor.h"
00036 #include "SFMatrix4f.h"
00037 
00038 namespace H3D {
00039 
00123   class H3DAPI_API X3DBackgroundNode : 
00124     public X3DBindableNode {
00125   public:
00126     
00127     typedef H3DDisplayListObject::DisplayList DisplayList;
00128 
00130     X3DBackgroundNode( Inst< SFSetBind > _set_bind    = 0,
00131                        Inst< SFNode    > _metadata    = 0,
00132                        Inst< SFTime    > _bindTime    = 0,
00133                        Inst< SFBool    > _isBound     = 0,
00134                        Inst< DisplayList > _displayList = 0,
00135                        Inst< MFFloat   > _groundAngle = 0,
00136                        Inst< MFColor   > _groundColor = 0,
00137                        Inst< MFFloat   > _skyAngle    = 0,
00138                        Inst< MFColor   > _skyColor    = 0 );
00139 
00141     static inline X3DBackgroundNode *getActive() {
00142       return static_cast< X3DBackgroundNode * >
00143         ( X3DBindableNode::getActive( "X3DBackgroundNode" ) );
00144     }
00145 
00146 #ifdef USE_HAPTICS
00148     virtual void traverseSG( TraverseInfo &ti ) {
00149       X3DBindableNode::traverseSG( ti );
00150       if( localToGlobal->getValue() != ti.getAccForwardMatrix() ) {
00151         localToGlobal->setValue( ti.getAccForwardMatrix() );
00152       }
00153     }
00154 #endif
00155 
00159     virtual void renderBackground() {
00160       render_enabled = true;
00161       displayList->callList();
00162       render_enabled = false;
00163     }
00164 
00167     virtual RGB glClearColor() {
00168       if( skyColor->size() > 0 )
00169         return skyColor->getValueByIndex( 0 );
00170       else 
00171         return RGB( 0, 0, 0 );
00172     }
00173 
00177     virtual void render();
00178 
00180     auto_ptr< DisplayList > displayList;
00181 
00190     auto_ptr< MFFloat >  groundAngle;
00191 
00192  
00207     auto_ptr< MFColor >  groundColor;
00208 
00219     auto_ptr< MFFloat >  skyAngle;
00220 
00235     auto_ptr< MFColor >  skyColor;
00236 
00238     static H3DNodeDatabase database;
00239   protected:
00240     auto_ptr< SFMatrix4f > localToGlobal;
00241     bool render_enabled;
00242   };
00243 }
00244 
00245 #endif
00246 

Generated on Thu Aug 24 12:38:35 2006 for H3D API by  doxygen 1.4.5