TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
grssgext.h
Go to the documentation of this file.
1/***************************************************************************
2
3 file : grssgext.h
4 created : Wed Aug 30 01:35:45 CEST 2000
5 copyright : (C) 2000 by Eric Espie
6 email : torcs@free.fr
7 version : $Id$
8
9***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
26
27#ifndef _GRSSGEXT_H_
28#define _GRSSGEXT_H_
29
30#include "grtexture.h"
31
32/*
33 * An ssgBranch with pre and post draw callbacks.
34 * It must be clear that all the children nodes
35 * have to be non-transparent in order to be
36 * drawn immediately.
37 */
38class ssgBranchCb : public ssgBranch
39{
40
41 protected:
42
43 ssgCallback preDrawCB;
44 ssgCallback postDrawCB;
45
46 public:
47
48 ssgBranchCb(void):ssgBranch() {
49 preDrawCB = NULL;
50 postDrawCB = NULL;
51 }
52
53 void cull ( sgFrustum *f, sgMat4 m, int test_needed )
54 {
55 int cull_result = cull_test ( f, m, test_needed ) ;
56
57 if ( cull_result == SSG_OUTSIDE )
58 return ;
59
60 if ( preDrawCB != NULL && ! (*preDrawCB)(this) )
61 return ;
62
63 for ( ssgEntity *e = getKid ( 0 ) ; e != NULL ; e = getNextKid() )
64 e -> cull ( f, m, cull_result != SSG_INSIDE ) ;
65
66 if ( postDrawCB != NULL )
67 (*postDrawCB)(this) ;
68 }
69
70 void setCallback ( int cb_type, ssgCallback cb ) {
71 if ( cb_type == SSG_CALLBACK_PREDRAW )
72 preDrawCB = cb ;
73 else
74 postDrawCB = cb ;
75 }
76
77};
78
79
80/* Use the texture name to select options like mipmap */
81class ssgLoaderOptionsEx : public ssgLoaderOptions {
82 public:
83 ssgLoaderOptionsEx():ssgLoaderOptions() {}
84
85 ssgTexture* createTexture(char* tfname, int wrapu = TRUE, int wrapv = TRUE, int mipmap = TRUE) {
86 mipmap = doMipMap(tfname, mipmap);
87 return ssgLoaderOptions::createTexture(tfname, wrapu, wrapv, mipmap) ;
88 }
89
90 virtual void makeModelPath ( char* path, const char *fname ) const
91 {
92 ulFindFile ( path, model_dir, fname, NULL ) ;
93 }
94
95 virtual void makeTexturePath ( char* path, const char *fname ) const
96 {
97 ulFindFile ( path, texture_dir, fname, NULL ) ;
98 }
99};
100
101
102
103#endif /* _GRSSGEXT_H_ */
104
105
106
ssgCallback postDrawCB
Definition grssgext.h:44
void setCallback(int cb_type, ssgCallback cb)
Definition grssgext.h:70
ssgBranchCb(void)
Definition grssgext.h:48
void cull(sgFrustum *f, sgMat4 m, int test_needed)
Definition grssgext.h:53
ssgCallback preDrawCB
Definition grssgext.h:43
virtual void makeTexturePath(char *path, const char *fname) const
Definition grssgext.h:95
ssgTexture * createTexture(char *tfname, int wrapu=TRUE, int wrapv=TRUE, int mipmap=TRUE)
Definition grssgext.h:85
virtual void makeModelPath(char *path, const char *fname) const
Definition grssgext.h:90
bool doMipMap(const char *tfname, int mipmap)
Definition grtexture.cpp:28