CPPGPGPU Library - Reference (Doxygen)

Main Page | General Use | Reference | Examples Info | Get/Download CPPGPGPU | SF.net Page

BasicNodes.h

Go to the documentation of this file.
00001 #ifndef _BASIC_NODES_H
00002 
00003 #include "Node.h"
00004 #include <OGLParts.h>
00005 
00007 class ShaderNode : public NodeObject
00008 {
00009 public:
00010     ShaderNode( const string & sName ) : NodeObject( sName ), m_fTimeSinceLastCheck( 0.0 ) { SetShader( sName ); }
00011     CLASS_RTTI( ShaderNode, NodeObject );
00012 
00013     virtual void Render();
00014     virtual void Update( const float fDtime );
00015 
00016     inline bool SetShader( const string & sShaderName ) { m_sShaderName = sShaderName; return S.LoadShader( sShaderName.c_str() ); }
00017     inline void SetUniformIs( vector<string> & vsnNames  ) { vsnIs = vsnNames; }
00018     inline void SetUniformFs( vector<string> & vsnNames, vector<float> & ivsnFs ) { vsnFs = vsnNames; vfnFs = ivsnFs; }
00019 
00020     static void SetGlobalCheckTime( float fTime ) { m_fTimePerCheck = fTime; }
00021 
00022     Shader S;
00023 private:
00024     float m_fTimeSinceLastCheck;
00025     static float m_fTimePerCheck;
00026     vector< string > vsnIs;
00027     vector< string > vsnFs;
00028     vector< float > vfnFs;
00029     string m_sShaderName;
00030 };
00031 
00033 class TextureNode : public NodeObject
00034 {
00035 public:
00036     TextureNode( const string & sName );
00037     CLASS_RTTI( TextureNode, NodeObject );
00038 
00039     virtual void Render();
00040 
00041     //Exposed T because of the loose attachment.
00042     Texture T;
00043 private:
00044 };
00045 
00047 class TextureSetNode : public NodeObject
00048 {
00049 public:
00050     TextureSetNode( const string & sName );
00051     CLASS_RTTI( TextureSetNode, NodeObject );
00052 
00054     virtual void Render();
00055 
00057     void SetupTextureset( vector< TextureNode > & vTextures ) { m_vAllTextures = vTextures; }
00058 private:
00059     vector< TextureNode > m_vAllTextures;
00060 };
00061 
00063 class RFBufferNode: public NodeObject
00064 {
00065 public:
00066     RFBufferNode( const string & sName ) : NodeObject( sName ) { }
00067     CLASS_RTTI( RFBufferNode, NodeObject );
00068 
00069     virtual void Render();
00070 
00072     void ConfigureForRun( vector< TextureNode * > & vTextures, bool bNeedDepth = false );
00073 
00075     RFBuffer B;
00076 private:
00077     vector< TextureNode * > m_vAllTextures;
00078     vector< Texture > m_vAllCoreTextures;
00079 };
00080 
00081 class SquareNode : public NodeObject
00082 {
00083 public:
00084     SquareNode( const string & sName ) : NodeObject( sName ) { }
00085     CLASS_RTTI( SquareNode, NodeObject );
00086 
00087     virtual void Render();
00088 };
00089 
00091 class TransformNode : public NodeObject
00092 {
00093 public:
00094     TransformNode( const string & sName ) : NodeObject( sName ),
00095         m_fX( 0.0f ), m_fY( 0.0f ), m_fZ( 0.0f ),
00096         m_rX( 0.0f ), m_rY( 0.0f ), m_rZ( 0.0f ),
00097         m_sX( 1.0f ), m_sY( 1.0f ), m_sZ( 1.0f ) {  }
00098     CLASS_RTTI( TransformNode, NodeObject );
00099 
00100     virtual void Render();
00101 
00102     inline void SetPosition( float fx, float fy, float fz ) { m_fX = fx; m_fY = fy, m_fZ = fz; }
00103     inline void GetPosition( float & fx, float & fy, float & fz ) { fx = m_fX; fy = m_fY; fz = m_fZ; }
00104 
00105     inline void SetRotation( float fx, float fy, float fz ) { m_rX = fx; m_rY = fy; m_rZ = fz; }
00106     inline void GetRotation( float & fx, float & fy, float & fz ) { fx = m_rX; fy = m_rY; fz = m_rZ; }
00107 
00108     inline void SetScale( float fx, float fy, float fz ) { m_sX = fx; m_sY = fy; m_sZ = fz; }
00109     inline void GetScale( float & fx, float & fy, float & fz ) { fx = m_sX; fy = m_sY; fz = m_sZ; }
00110 private:
00111     float m_fX, m_fY, m_fZ;
00112     float m_rX, m_rY, m_rZ;
00113     float m_sX, m_sY, m_sZ;
00114 };
00115 
00117 class ModelNode : public NodeObject
00118 {
00119 public:
00120     ModelNode( const string & sName ) : NodeObject( sName ), iList( 0 ) { LoadOBJ( sName.c_str() ); }
00121     ~ModelNode();
00122     CLASS_RTTI( ModelNode, NodeObject );
00123 
00124     bool LoadOBJ( const char * sFileToLoad );
00125 
00126     virtual void Render();
00127 private:
00128     GLuint iList;
00129 };
00130 
00132 CODERENDERNODE( DataRunNode, SetupForDataRun(), PopFromDataRun() );
00133 
00135 CODERENDERNODE( TeapotNode, glutSolidTeapot( 1.0 ),  );
00136 
00137 
00138 #endif
00139 
00140 /*
00141 Copyright (c) 2007 Charles Lohr
00142 
00143 Permission is hereby granted, free of charge, to any person obtaining a copy
00144 of this software and associated documentation files (the "Software"), to deal
00145 in the Software without restriction, including without limitation the rights
00146 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00147 copies of the Software, and to permit persons to whom the Software is
00148 furnished to do so, subject to the following conditions:
00149 
00150 The above copyright notice and this permission notice shall be included in
00151 all copies or substantial portions of the Software.
00152 
00153 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00154 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00155 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00156 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00157 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00158 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00159 THE SOFTWARE.
00160 */

© 2005-2007 Charles Lohr, Joshua Allen, David Chapman, Andrew Lohr. All material including documentation under the MIT/X11 license.