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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGL.h>
00049
00050 #include <OSGDrawActionBase.h>
00051 #include <OSGRenderAction.h>
00052 #include <OSGCamera.h>
00053
00054 #include "OSGSClipPlaneChunk.h"
00055
00056 OSG_USING_NAMESPACE
00057
00058
00059
00060
00061
00073
00074
00075
00076
00077 StateChunkClass SClipPlaneChunk::_class("SClipPlane", 6);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 SClipPlaneChunk::SClipPlaneChunk(void) :
00090 Inherited()
00091 {
00092 }
00093
00094 SClipPlaneChunk::SClipPlaneChunk(const SClipPlaneChunk &source) :
00095 Inherited(source)
00096 {
00097 }
00098
00099 SClipPlaneChunk::~SClipPlaneChunk(void)
00100 {
00101 }
00102
00103
00104
00105 const StateChunkClass *SClipPlaneChunk::getClass(void) const
00106 {
00107 return &_class;
00108 }
00109
00110
00111
00112 void SClipPlaneChunk::changed(BitVector, UInt32)
00113 {
00114 }
00115
00116
00117
00118 void SClipPlaneChunk::dump( UInt32 ,
00119 const BitVector) const
00120 {
00121 SLOG << "Dump SClipPlaneChunk NI" << std::endl;
00122 }
00123
00124
00125
00126
00127 void SClipPlaneChunk::activate(DrawActionBase *action, UInt32 idx)
00128 {
00129 RenderAction *ra = dynamic_cast<RenderAction *>(action);
00130
00131 GLdouble glEq[4];
00132 Vec4f & eq = getEquation();
00133 glEq[0] = eq[0];
00134 glEq[1] = eq[1];
00135 glEq[2] = eq[2];
00136 glEq[3] = eq[3];
00137
00138 glClipPlane( GL_CLIP_PLANE0 + idx, glEq);
00139 glEnable( GL_CLIP_PLANE0 + idx);
00140 }
00141
00142
00143
00144
00145 void SClipPlaneChunk::changeFrom(DrawActionBase *action, StateChunk * old_chunk,
00146 UInt32 idx)
00147 {
00148 SClipPlaneChunk const *old = dynamic_cast<SClipPlaneChunk const*>(old_chunk);
00149
00150
00151
00152 if(old == this)
00153 return;
00154
00155 RenderAction *ra = dynamic_cast<RenderAction *>(action);
00156
00157 GLdouble glEq[4];
00158 Vec4f & eq = getEquation();
00159 glEq[0] = eq[0];
00160 glEq[1] = eq[1];
00161 glEq[2] = eq[2];
00162 glEq[3] = eq[3];
00163
00164 glClipPlane( GL_CLIP_PLANE0 + idx, glEq);
00165 }
00166
00167
00168 void SClipPlaneChunk::deactivate(DrawActionBase *, UInt32 idx)
00169 {
00170 glDisable( GL_CLIP_PLANE0 + idx);
00171 }
00172
00173
00174
00175
00176 Real32 SClipPlaneChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00177 {
00178 return 0;
00179 }
00180
00181 bool SClipPlaneChunk::operator < (const StateChunk &other) const
00182 {
00183 return this < &other;
00184 }
00185
00186 bool SClipPlaneChunk::operator == (const StateChunk &other) const
00187 {
00188 SClipPlaneChunk const *tother = dynamic_cast<SClipPlaneChunk const*>(&other);
00189
00190 if(!tother)
00191 return false;
00192
00193 if(getEquation() != tother->getEquation())
00194 return false;
00195
00196 return true;
00197 }
00198
00199 bool SClipPlaneChunk::operator != (const StateChunk &other) const
00200 {
00201 return ! (*this == other);
00202 }
00203
00204
00205
00206
00207
00208 #ifdef OSG_SGI_CC
00209 #pragma set woff 1174
00210 #endif
00211
00212 #ifdef OSG_LINUX_ICC
00213 #pragma warning( disable : 177)
00214 #endif
00215
00216 namespace
00217 {
00218 static Char8 cvsid_cpp [] = "@(#)$Id: OSGSClipPlaneChunk.cpp,v 1.1 2007/04/26 15:22:01 a-m-z Exp $";
00219 static Char8 cvsid_hpp [] = OSGSCLIPPLANECHUNK_HEADER_CVSID;
00220 static Char8 cvsid_inl [] = OSGSCLIPPLANECHUNK_INLINE_CVSID;
00221
00222 static Char8 cvsid_fields_hpp[] = OSGSCLIPPLANECHUNKFIELDS_HEADER_CVSID;
00223 }
00224
00225 #ifdef __sgi
00226 #pragma reset woff 1174
00227 #endif
00228