|
Revision 13041, 2.3 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include <osg/ClipPlane> |
|---|
| 14 | #include <osg/StateSet> |
|---|
| 15 | #include <osg/Notify> |
|---|
| 16 | |
|---|
| 17 | using namespace osg; |
|---|
| 18 | |
|---|
| 19 | ClipPlane::ClipPlane() |
|---|
| 20 | { |
|---|
| 21 | _clipPlane.set(0.0,0.0,0.0,0.0); |
|---|
| 22 | _clipPlaneNum = 0; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | ClipPlane::~ClipPlane() |
|---|
| 27 | { |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | void ClipPlane::setClipPlaneNum(unsigned int num) |
|---|
| 31 | { |
|---|
| 32 | if (_clipPlaneNum==num) return; |
|---|
| 33 | |
|---|
| 34 | if (_parents.empty()) |
|---|
| 35 | { |
|---|
| 36 | _clipPlaneNum = num; |
|---|
| 37 | return; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | osg::ref_ptr<ClipPlane> clipPlaneRef = this; |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | ParentList parents = _parents; |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | ParentList::iterator itr; |
|---|
| 50 | for(itr = parents.begin(); |
|---|
| 51 | itr != parents.end(); |
|---|
| 52 | ++itr) |
|---|
| 53 | { |
|---|
| 54 | osg::StateSet* stateset = *itr; |
|---|
| 55 | stateset->removeAttribute(this); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | _clipPlaneNum = num; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | for(itr = parents.begin(); |
|---|
| 63 | itr != parents.end(); |
|---|
| 64 | ++itr) |
|---|
| 65 | { |
|---|
| 66 | osg::StateSet* stateset = *itr; |
|---|
| 67 | stateset->setAttribute(this); |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | unsigned int ClipPlane::getClipPlaneNum() const |
|---|
| 72 | { |
|---|
| 73 | return _clipPlaneNum; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | void ClipPlane::apply(State&) const |
|---|
| 77 | { |
|---|
| 78 | #if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE) |
|---|
| 79 | glClipPlane((GLenum)(GL_CLIP_PLANE0+_clipPlaneNum),_clipPlane.ptr()); |
|---|
| 80 | #else |
|---|
| 81 | OSG_NOTICE<<"Warning: ClipPlane::apply(State&) - not supported."<<std::endl; |
|---|
| 82 | #endif |
|---|
| 83 | } |
|---|