00001 #pragma once
00002 #ifndef SHADOWPROXY_H
00003 #define SHADOWPROXY_H
00004
00005 #ifndef RT_GLES1
00006
00007 #include "Types.h"
00008 #include "Util.h"
00009 #include "RelationalNode.h"
00010 #include "Property.h"
00011
00012 namespace RenderTools {
00013
00014 class ShadowProxy {
00015 public:
00016
00017 enum ProxyType {
00018 CYLINDER,
00019 SPHERE,
00020 BOX
00021 };
00022
00023 static PropertyPtr create( const XMLNodePtr & xml = XMLNodePtr() );
00024 static void createProperties( void );
00025 virtual const string getTypeName( bool ofComponent = false ) const;
00026
00027 static void onInitialize( void );
00028 static void setCamera( const CameraPtr camera );
00029 static ShadowProxyPtr addProxy( ProxyType type, const Vec3 & size, const Vec3 & color, const RendernodePtr node, const Mat4 & matrix );
00030 static void project( void );
00031 static void render( bool showGrid );
00032 static SamplerPtr getMap( void );
00033 static Vec2 getMapSize( void );
00034 static Vec2 getMapSize2( void );
00035 static Vec2 getGridSize( void );
00036 static void deleteAssociatedProxies( const RendernodePtr node );
00037 static void deleteAssociatedProxies( string path );
00038 static int retrieveIndex( const RendernodePtr node );
00039 static CameraPtr getAssociatedCamera( void );
00040 const int getType( void ) const;
00041 Vec3 getSize( const Vec3 & offset = Vec3() ) const;
00042 void setSize( const Vec3 & size );
00043 void setColor( const Vec3 & color );
00044 const Vec3 & getColor( void ) const;
00045 const Mat4 & getLocal( void ) const;
00046 AABB getAABB( const Vec3 & offset = Vec3() );
00047 const RendernodePtr getAssociatedRendernode( void ) const;
00048 void render( void );
00049
00050 private:
00051 ShadowProxy( ProxyType type,
00052 const Vec3 & size,
00053 const Vec3 & color,
00054 const RendernodePtr node,
00055 const Mat4 & local );
00056
00057 static int addProxy( const Vec4 & position, const Vec4 & rotation, const Vec3 & color, int type, const Vec3 & size );
00058 static int getNumProxies( int x, int y );
00059 static void addIndex( int x, int y, int idx );
00060
00061 static RelationalNodePtr s_model;
00062 static ShadowProxyList s_proxies;
00063 static CameraPtr s_camera;
00064 static GLfloat s_offset;
00065 static GLfloat * s_data;
00066 static Mat4Ptr s_params;
00067 static GLint s_gridSize[2];
00068 static GLint s_mapSize[2];
00069 static GLint s_mapSize2[2];
00070 static GLint s_cellSize[2];
00071 static GLint s_numProxies;
00072 static GLint s_maxProxiesPerCell;
00073 static GLint s_maxUniqueProxies;
00074 static SamplerPtr s_map;
00075
00076 Vec3 m_size;
00077 Vec3 m_color;
00078 ProxyType m_type;
00079 Mat4 m_local;
00080 RendernodePtr m_associatedRendernode;
00081 RelationalNodePtr m_nodeProperties;
00082 };
00083
00084 inline ostream & operator << ( ostream & s, const ShadowProxy::ProxyType & v ){
00085 switch( v ){
00086 case ShadowProxy::SPHERE:
00087 s << string( "SPHERE" );
00088 break;
00089 case ShadowProxy::CYLINDER:
00090 s << string( "CYLINDER" );
00091 break;
00092 case ShadowProxy::BOX:
00093 s << string( "BOX" );
00094 break;
00095 }
00096 return( s );
00097 }
00098
00099 inline istream & operator >> ( istream & s, ShadowProxy::ProxyType & v ){
00100 string value;
00101 s >> value;
00102
00103 if( value == "SPHERE" ){
00104 v = ShadowProxy::SPHERE;
00105 }
00106 else if( value == "CYLINDER" ){
00107 v = ShadowProxy::CYLINDER;
00108 }
00109 else if( value == "BOX" ){
00110 v = ShadowProxy::BOX;
00111 }
00112
00113 return( s );
00114 }
00115
00116 };
00117
00118 #endif // RT_GLES1
00119
00120
00121
00122 #endif