00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __SGL_PROBE_HPP
00028 #define __SGL_PROBE_HPP
00029
00030 #include <sgl.h>
00031 #include <sglTraverser.hpp>
00032 #include <sglMat4.hpp>
00033 #include <sglFrustum.hpp>
00034
00035 class sglGeode;
00036 class sglDrawable;
00037
00038
00039
00046 class SGL_DLL_API sglProbe : public sglTraverser
00047 {
00048 public:
00049 enum ModeEnum
00050 {
00051 ePRIMITIVE = 0x00000001,
00052 eGEOMETRY = 0x00000002,
00053 eGEODE = 0x00000004,
00054 eCULL_BACK = 0x00000008,
00055 eCULL_FRONT = 0x00000010,
00056 eNORMAL = 0x00000020,
00057 eTRANSFORM = 0x00000040,
00058 ePATH = 0x00000080,
00059
00060 eSWITCH_ALL = 0x00000100,
00061 eSWITCH_NONE = 0x00000200,
00062
00063 eLOD_ALL = 0x00000400,
00064 eLOD_NONE = 0x00000800,
00065 eLOD_VIEW = 0x00001000,
00066
00067
00068 eBILLBOARD_VIEW = 0x00002000,
00069
00070 eANIMATION_ALL = 0x00004000,
00071 eANIMATION_NONE = 0x00008000,
00072
00073 eLAYER_NONE = 0x00010000,
00074 eLAYER_BASE = 0x00020000,
00075 eLAYER_DECAL = 0x00040000,
00076
00077
00078
00079 eUNSCALE_VIEW = 0x00080000,
00080 eUNPROJECT_VIEW = 0x00100000
00081 };
00082
00083 sglProbe() : sglTraverser() {}
00084 virtual ~sglProbe() {}
00085 };
00086
00087
00088
00095 template <class T>
00096 class SGL_DLL_API sglProbeTemplate : public sglProbe
00097 {
00098 public:
00099 class SGL_DLL_API ProbeResult
00100 {
00101 public:
00102 const sglGeode *m_geode;
00103 const sglDrawable *m_geometry;
00104 sglMat4<T> m_xform;
00105
00106 public:
00107 ProbeResult() : m_geode(NULL), m_geometry(NULL)
00108 { m_xform.buildIdentity(); }
00109 virtual ~ProbeResult() {}
00110
00111 virtual void reset() = 0;
00112
00113 protected:
00114
00115
00116 void resetInternal()
00117 {
00118 m_geode = NULL;
00119 m_geometry = NULL;
00120 m_xform.buildIdentity();
00121 }
00122 };
00123
00124 public:
00125 sglProbeTemplate() : sglProbe(), m_mode(eGEODE|eCULL_BACK) {}
00126 virtual ~sglProbeTemplate() {}
00127
00128 virtual void reset()
00129 {
00130 m_modelview_matrix.buildIdentity();
00131 }
00132
00133 void setMode(unsigned int mode) { m_mode = mode; }
00134 unsigned int getMode() const { return m_mode; }
00135
00137 void setViewportSize(unsigned int x, unsigned int y)
00138 { m_viewport_x = x; m_viewport_y = y; }
00140 void getViewportSize(unsigned int &x, unsigned int &y)
00141 { x = m_viewport_x; y = m_viewport_y; }
00142
00144 void setViewFrustum(const sglFrustum<T> &frustum)
00145 {
00146 m_orig_view_frustum = frustum;
00147 m_current_view_frustum = frustum;
00148 }
00149
00153 sglFrustum<T> &getOrigViewFrustum() { return m_orig_view_frustum; }
00155 sglFrustum<T> &getViewFrustum() { return m_current_view_frustum; }
00156
00160 sglMat4<T>& getModelViewMatrix() { return m_modelview_matrix; }
00161
00164 void setModelViewMatrix(const sglMat4<T> &mat) { m_modelview_matrix = mat; }
00165
00166
00167 private:
00168 sglProbeTemplate(const sglProbeTemplate &);
00169 sglProbeTemplate &operator=(const sglProbeTemplate &);
00170
00171 protected:
00172 unsigned int m_mode;
00173
00174 unsigned int m_viewport_x;
00175 unsigned int m_viewport_y;
00176 sglFrustum<T> m_orig_view_frustum;
00177 sglFrustum<T> m_current_view_frustum;
00178
00179 sglMat4<T> m_modelview_matrix;
00180 };
00181
00182 #endif