Changeset 7620
- Timestamp:
- 12/08/07 14:29:31 (6 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 6 modified
-
include/osg/ClipPlane (modified) (2 diffs)
-
include/osg/Hint (modified) (3 diffs)
-
include/osg/Light (modified) (3 diffs)
-
src/osg/ClipPlane.cpp (modified) (2 diffs)
-
src/osg/Hint.cpp (modified) (2 diffs)
-
src/osg/Light.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/ClipPlane
r6311 r7620 28 28 29 29 ClipPlane(); 30 inline ClipPlane(unsigned int no) { setClipPlaneNum(no); } 30 31 inline ClipPlane(unsigned int no,const Vec4d& plane) { setClipPlaneNum(no); setClipPlane(plane); } 31 32 inline ClipPlane(unsigned int no,const Plane& plane) { setClipPlaneNum(no); setClipPlane(plane); } … … 43 44 } 44 45 45 META_StateAttribute(osg, ClipPlane, CLIPPLANE); 46 virtual osg::Object* cloneType() const { return new ClipPlane( _clipPlaneNum ); } 47 virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new ClipPlane(*this,copyop); } 48 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ClipPlane *>(obj)!=NULL; } 49 virtual const char* libraryName() const { return "osg"; } 50 virtual const char* className() const { return "ClipPlane"; } 51 virtual Type getType() const { return CLIPPLANE; } 46 52 47 53 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ -
OpenSceneGraph/trunk/include/osg/Hint
r6824 r7620 26 26 Hint(): 27 27 _target(GL_NONE), 28 _mode(GL_ NONE) {}28 _mode(GL_DONT_CARE) {} 29 29 30 30 Hint(GLenum target, GLenum mode): … … 38 38 _mode(hint._mode) {} 39 39 40 META_StateAttribute(osg, Hint, HINT); 40 virtual osg::Object* cloneType() const { return new Hint( _target, GL_DONT_CARE ); } 41 virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Hint(*this,copyop); } 42 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Hint *>(obj)!=NULL; } 43 virtual const char* libraryName() const { return "osg"; } 44 virtual const char* className() const { return "Light"; } 45 virtual Type getType() const { return HINT; } 41 46 42 47 virtual int compare(const StateAttribute& sa) const 43 48 { 44 // check the types are equal and then create the rhs variable45 // used by the COMPARE_StateAttribute_Parameter macro's below.46 COMPARE_StateAttribute_Types(Hint,sa)49 // check the types are equal and then create the rhs variable 50 // used by the COMPARE_StateAttribute_Parameter macro's below. 51 COMPARE_StateAttribute_Types(Hint,sa) 47 52 48 53 // compare each paramter in turn against the rhs. … … 56 61 virtual unsigned int getMember() const { return static_cast<unsigned int>(_target); } 57 62 58 inline void setTarget(GLenum target) { _target = target; }63 inline void setTarget(GLenum target); 59 64 inline GLenum getTarget() const { return _target; } 60 65 -
OpenSceneGraph/trunk/include/osg/Light
r6311 r7620 28 28 Light(); 29 29 30 Light(unsigned int lightnum); 31 30 32 /** Copy constructor using CopyOp to manage deep vs shallow copy. */ 31 33 Light(const Light& light,const CopyOp& copyop=CopyOp::SHALLOW_COPY): … … 43 45 _spot_cutoff(light._spot_cutoff) {} 44 46 45 META_StateAttribute(osg, Light, LIGHT); 47 virtual osg::Object* cloneType() const { return new Light(_lightnum); } 48 virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Light(*this,copyop); } 49 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Light *>(obj)!=NULL; } 50 virtual const char* libraryName() const { return "osg"; } 51 virtual const char* className() const { return "Light"; } 52 virtual Type getType() const { return LIGHT; } 46 53 47 54 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ … … 79 86 80 87 /** Set which OpenGL light to operate on. */ 81 void setLightNum(int num) { _lightnum = num; }88 void setLightNum(int num); 82 89 83 90 /** Get which OpenGL light this osg::Light operates on. */ -
OpenSceneGraph/trunk/src/osg/ClipPlane.cpp
r5328 r7620 12 12 */ 13 13 #include <osg/ClipPlane> 14 #include <osg/StateSet> 14 15 #include <osg/Notify> 15 16 … … 29 30 void ClipPlane::setClipPlaneNum(unsigned int num) 30 31 { 32 if (_clipPlaneNum==num) return; 33 34 if (_parents.empty()) 35 { 36 _clipPlaneNum = num; 37 return; 38 } 39 40 // take a reference to this clip plane to prevent it from going out of scope 41 // when we remove it temporarily from its parents. 42 osg::ref_ptr<ClipPlane> clipPlaneRef = this; 43 44 // copy the parents as they _parents list will be changed by the subsequent removeAttributes. 45 ParentList parents = _parents; 46 47 // remove this attribute from its parents as its position is being changed 48 // and would no longer be valid. 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 // assign the clip plane number 31 59 _clipPlaneNum = num; 60 61 // add this attribute back into its original parents with its new position 62 for(itr = parents.begin(); 63 itr != parents.end(); 64 ++itr) 65 { 66 osg::StateSet* stateset = *itr; 67 stateset->setAttribute(this); 68 } 32 69 } 33 70 -
OpenSceneGraph/trunk/src/osg/Hint.cpp
r6824 r7620 13 13 14 14 #include <osg/Hint> 15 #include <osg/StateSet> 15 16 16 17 using namespace osg; … … 22 23 glHint(_target, _mode); 23 24 } 25 26 void Hint::setTarget(GLenum target) 27 { 28 if (_target==target) return; 29 30 if (_parents.empty()) 31 { 32 _target = target; 33 return; 34 } 35 36 // take a reference to this clip plane to prevent it from going out of scope 37 // when we remove it temporarily from its parents. 38 osg::ref_ptr<Hint> hintRef = this; 39 40 // copy the parents as they _parents list will be changed by the subsequent removeAttributes. 41 ParentList parents = _parents; 42 43 // remove this attribute from its parents as its position is being changed 44 // and would no longer be valid. 45 ParentList::iterator itr; 46 for(itr = parents.begin(); 47 itr != parents.end(); 48 ++itr) 49 { 50 osg::StateSet* stateset = *itr; 51 stateset->removeAttribute(this); 52 } 53 54 // assign the hint target 55 _target = target; 56 57 // add this attribute back into its original parents with its new position 58 for(itr = parents.begin(); 59 itr != parents.end(); 60 ++itr) 61 { 62 osg::StateSet* stateset = *itr; 63 stateset->setAttribute(this); 64 } 65 } 66 -
OpenSceneGraph/trunk/src/osg/Light.cpp
r5328 r7620 12 12 */ 13 13 #include <osg/Light> 14 #include <osg/StateSet> 14 15 #include <osg/Notify> 15 16 … … 19 20 { 20 21 init(); 21 22 // notify(DEBUG) << "_ambient "<<_ambient<<std::endl;23 // notify(DEBUG) << "_diffuse "<<_diffuse<<std::endl;24 // notify(DEBUG) << "_specular "<<_specular<<std::endl;25 // notify(DEBUG) << "_position "<<_position<<std::endl;26 // notify(DEBUG) << "_direction "<<_direction<<std::endl;27 // notify(DEBUG) << "_spot_exponent "<<_spot_exponent<<std::endl;28 // notify(DEBUG) << "_spot_cutoff "<<_spot_cutoff<<std::endl;29 // notify(DEBUG) << "_constant_attenuation "<<_constant_attenuation<<std::endl;30 // notify(DEBUG) << "_linear_attenuation "<<_linear_attenuation<<std::endl;31 // notify(DEBUG) << "_quadratic_attenuation "<<_quadratic_attenuation<<std::endl;32 22 } 33 23 24 Light::Light(unsigned int lightnum) 25 { 26 init(); 27 _lightnum = lightnum; 28 } 34 29 35 30 Light::~Light( void ) … … 51 46 _linear_attenuation = 0.0f; 52 47 _quadratic_attenuation = 0.0f; 48 49 // notify(DEBUG) << "_ambient "<<_ambient<<std::endl; 50 // notify(DEBUG) << "_diffuse "<<_diffuse<<std::endl; 51 // notify(DEBUG) << "_specular "<<_specular<<std::endl; 52 // notify(DEBUG) << "_position "<<_position<<std::endl; 53 // notify(DEBUG) << "_direction "<<_direction<<std::endl; 54 // notify(DEBUG) << "_spot_exponent "<<_spot_exponent<<std::endl; 55 // notify(DEBUG) << "_spot_cutoff "<<_spot_cutoff<<std::endl; 56 // notify(DEBUG) << "_constant_attenuation "<<_constant_attenuation<<std::endl; 57 // notify(DEBUG) << "_linear_attenuation "<<_linear_attenuation<<std::endl; 58 // notify(DEBUG) << "_quadratic_attenuation "<<_quadratic_attenuation<<std::endl; 53 59 } 60 61 void Light::setLightNum(int num) 62 { 63 if (_lightnum==num) return; 64 65 if (_parents.empty()) 66 { 67 _lightnum = num; 68 return; 69 } 70 71 // take a reference to this clip plane to prevent it from going out of scope 72 // when we remove it temporarily from its parents. 73 osg::ref_ptr<Light> lightRef = this; 74 75 // copy the parents as they _parents list will be changed by the subsequent removeAttributes. 76 ParentList parents = _parents; 77 78 // remove this attribute from its parents as its position is being changed 79 // and would no longer be valid. 80 ParentList::iterator itr; 81 for(itr = parents.begin(); 82 itr != parents.end(); 83 ++itr) 84 { 85 osg::StateSet* stateset = *itr; 86 stateset->removeAttribute(this); 87 } 88 89 // assign the hint target 90 _lightnum = num; 91 92 // add this attribute back into its original parents with its new position 93 for(itr = parents.begin(); 94 itr != parents.end(); 95 ++itr) 96 { 97 osg::StateSet* stateset = *itr; 98 stateset->setAttribute(this); 99 } 100 } 101 54 102 55 103
