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 #include <stdlib.h>
00040 #include <stdio.h>
00041
00042 #include "OSGConfig.h"
00043
00044 #include <OSGGL.h>
00045
00046 #include <OSGDrawAction.h>
00047 #include <OSGRenderAction.h>
00048 #include "OSGClipPlane.h"
00049
00050 OSG_USING_NAMESPACE
00051
00057
00058
00059
00060 SClipPlaneChunkPtr ClipPlane::getChunk(void)
00061 {
00062 return _pChunk;
00063 }
00064
00065 void ClipPlane::makeChunk(void)
00066 {
00067 if(_pChunk == NullFC)
00068 {
00069 _pChunk = SClipPlaneChunk::create();
00070 }
00071
00072 _pChunk->setEquation(getEquation());
00073 }
00074
00075
00076
00077
00078 void ClipPlane::changed(BitVector whichField, UInt32 origin)
00079 {
00080 Inherited::changed(whichField, origin);
00081 }
00082
00083
00084
00085
00086
00087 void ClipPlane::dump( UInt32 uiIndent,
00088 const BitVector bvFlags) const
00089 {
00090 Inherited::dump(uiIndent, bvFlags);
00091 }
00092
00093
00094
00095
00096 ClipPlane::ClipPlane(void) :
00097 Inherited(),
00098 _pChunk (NullFC)
00099 {
00100 }
00101
00102 ClipPlane::ClipPlane(const ClipPlane &source) :
00103 Inherited(source),
00104 _pChunk (source._pChunk)
00105 {
00106 }
00107
00108
00109
00110
00111 ClipPlane::~ClipPlane(void)
00112 {
00113 if(_pChunk != NullFC)
00114 subRefCP(_pChunk);
00115 }
00116
00117
00118
00119
00120 #if 0
00121 Action::ResultE ClipPlane::drawEnter(Action *action)
00122 {
00123 if(getOn() == false)
00124 return Action::Continue;
00125
00126 DrawAction *da = dynamic_cast<DrawAction *>(action);
00127 GLenum clipplane = GL_CLIP_PLANE0 + da->getClipPlaneCount();
00128
00129 da->incClipPlaneCount();
00130
00131
00132
00133 Matrix fromworld;
00134 Matrix tobeacon;
00135
00136 action->getActNode()->getToWorld(fromworld);
00137 fromworld.invert();
00138
00139 NodePtr beacon = getBeacon();
00140
00141 if(beacon == NullFC)
00142 {
00143 SINFO << "draw: no beacon set!" << std::endl;
00144
00145 glPushMatrix();
00146 }
00147 else
00148 {
00149 getBeacon()->getToWorld(tobeacon);
00150
00151 tobeacon.mult(fromworld);
00152
00153 glPushMatrix();
00154 glMultMatrixf(tobeacon.getValues());
00155 }
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 glEnable (clipplane);
00166
00167 da->selectVisibles();
00168
00169 return Action::Continue;
00170 }
00171
00172 Action::ResultE ClipPlane::drawLeave(Action *action)
00173 {
00174 if(getOn() == false)
00175 return Action::Continue;
00176
00177 DrawAction *da = dynamic_cast<DrawAction *>(action);
00178
00179 da->decClipPlaneCount();
00180
00181 GLenum clipplane = GL_CLIP_PLANE0 + da->getClipPlaneCount();
00182
00183 glDisable(clipplane);
00184
00185 return Action::Continue;
00186 }
00187 #endif
00188
00189
00190
00191
00192 Action::ResultE ClipPlane::renderEnter(Action *action)
00193 {
00194 if(getOn() == false)
00195 return Action::Continue;
00196
00197 RenderAction *pAction = dynamic_cast<RenderAction *>(action);
00198
00199
00200 if (pAction->pushVisibility())
00201 {
00202 if(pAction->selectVisibles() == 0)
00203 {
00204 pAction->popVisibility();
00205 return Action::Skip;
00206 }
00207 }
00208
00209 pAction->dropClipPlane(this);
00210
00211 return Action::Continue;
00212 }
00213
00214 Action::ResultE ClipPlane::renderLeave(Action *action)
00215 {
00216 if(getOn() == false)
00217 return Action::Continue;
00218
00219 RenderAction *pAction = dynamic_cast<RenderAction *>(action);
00220
00221 pAction->undropClipPlane(this);
00222
00223 pAction->popVisibility();
00224
00225 return Action::Continue;
00226 }
00227
00228
00229
00230
00232
00233 void ClipPlane::initMethod(void)
00234 {
00235 RenderAction::registerEnterDefault(
00236 getClassType(),
00237 osgTypedMethodFunctor2BaseCPtrRef<
00238 Action::ResultE,
00239 ClipPlanePtr ,
00240 CNodePtr ,
00241 Action *>(&ClipPlane::renderEnter));
00242
00243 RenderAction::registerLeaveDefault(
00244 getClassType(),
00245 osgTypedMethodFunctor2BaseCPtrRef<
00246 OSG::Action::ResultE,
00247 ClipPlanePtr ,
00248 CNodePtr ,
00249 Action *>(&ClipPlane::renderLeave));
00250 }
00251
00252
00253
00254
00255
00256 #ifdef __sgi
00257 #pragma set woff 1174
00258 #endif
00259
00260 #ifdef OSG_LINUX_ICC
00261 #pragma warning( disable : 177 )
00262 #endif
00263
00264 namespace
00265 {
00266 static Char8 cvsid_cpp[] = "@(#)$Id: OSGClipPlane.cpp,v 1.1 2007/04/26 15:22:01 a-m-z Exp $";
00267 static Char8 cvsid_hpp[] = OSGCLIPPLANE_HEADER_CVSID;
00268 static Char8 cvsid_inl[] = OSGCLIPPLANE_INLINE_CVSID;
00269 }
00270