00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #ifndef _GRSSGEXT_H_
00028 #define _GRSSGEXT_H_
00029
00030
00031
00032
00033
00034
00035
00036
00037 class ssgBranchCb : public ssgBranch
00038 {
00039
00040 protected:
00041
00042 ssgCallback preDrawCB;
00043 ssgCallback postDrawCB;
00044
00045 public:
00046
00047 ssgBranchCb(void):ssgBranch() {
00048 preDrawCB = NULL;
00049 postDrawCB = NULL;
00050 }
00051
00052 void cull ( sgFrustum *f, sgMat4 m, int test_needed )
00053 {
00054 int cull_result = cull_test ( f, m, test_needed ) ;
00055
00056 if ( cull_result == SSG_OUTSIDE )
00057 return ;
00058
00059 if ( preDrawCB != NULL && ! (*preDrawCB)(this) )
00060 return ;
00061
00062 for ( ssgEntity *e = getKid ( 0 ) ; e != NULL ; e = getNextKid() )
00063 e -> cull ( f, m, cull_result != SSG_INSIDE ) ;
00064
00065 if ( postDrawCB != NULL )
00066 (*postDrawCB)(this) ;
00067 }
00068
00069 void setCallback ( int cb_type, ssgCallback cb ) {
00070 if ( cb_type == SSG_CALLBACK_PREDRAW )
00071 preDrawCB = cb ;
00072 else
00073 postDrawCB = cb ;
00074 }
00075
00076 };
00077
00078
00079
00080 class ssgLoaderOptionsEx : public ssgLoaderOptions
00081 {
00082 public:
00083 ssgLoaderOptionsEx()
00084 : ssgLoaderOptions()
00085 {}
00086
00087 ssgTexture* createTexture(char* tfname,
00088 int wrapu = TRUE, int wrapv = TRUE,
00089 int mipmap = TRUE)
00090 {
00091 char *buf;
00092 char *s;
00093
00094 buf = (char *)malloc(strlen(tfname)+1);
00095 strcpy(buf, tfname);
00096
00097
00098 s = strrchr(buf, '.');
00099 if (s) {
00100 *s = 0;
00101 }
00102
00103
00104 s = strrchr(buf, '_');
00105
00106 if (s) {
00107
00108 if (strncmp(s, "_n", 4) == 0) {
00109 mipmap = FALSE;
00110 }
00111 }
00112 free(buf);
00113
00114 return ssgLoaderOptions::createTexture(tfname, wrapu, wrapv, mipmap) ;
00115 }
00116
00117 virtual void makeModelPath ( char* path, const char *fname ) const
00118 {
00119 ulFindFile ( path, model_dir, fname, NULL ) ;
00120 }
00121
00122 virtual void makeTexturePath ( char* path, const char *fname ) const
00123 {
00124 ulFindFile ( path, texture_dir, fname, NULL ) ;
00125 }
00126
00127 };
00128
00129
00130
00131 #endif
00132
00133
00134