Changeset 8804
- Timestamp:
- 08/28/08 11:43:00
- Files:
-
- OpenSceneGraph/trunk/include/osg/AutoTransform (modified) (5 diffs)
- OpenSceneGraph/trunk/src/osg/AutoTransform.cpp (modified) (9 diffs)
- OpenSceneGraph/trunk/src/osgWrappers/osg/AutoTransform.cpp (modified) (4 diffs)
- OpenSceneGraph/trunk/src/osgWrappers/osgTerrain/Layer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/trunk/include/osg/AutoTransform
r8734 r8804 43 43 virtual const AutoTransform* asAutoTransform() const { return this; } 44 44 45 inline void setPosition(const Vec3 & pos) { _position = pos; _matrixDirty=true; dirtyBound(); }46 inline const Vec3 & getPosition() const { return _position; }45 inline void setPosition(const Vec3d& pos) { _position = pos; _matrixDirty=true; dirtyBound(); } 46 inline const Vec3d& getPosition() const { return _position; } 47 47 48 48 … … 50 50 inline const Quat& getRotation() const { return _rotation; } 51 51 52 inline void setScale( floatscale) { setScale(osg::Vec3(scale,scale,scale)); }52 inline void setScale(double scale) { setScale(osg::Vec3(scale,scale,scale)); } 53 53 54 void setScale(const Vec3 & scale);55 inline const Vec3 & getScale() const { return _scale; }54 void setScale(const Vec3d& scale); 55 inline const Vec3d& getScale() const { return _scale; } 56 56 57 void setMinimumScale( floatminimumScale) { _minimumScale = minimumScale; }58 floatgetMinimumScale() const { return _minimumScale; }57 void setMinimumScale(double minimumScale) { _minimumScale = minimumScale; } 58 double getMinimumScale() const { return _minimumScale; } 59 59 60 void setMaximumScale( floatmaximumScale) { _maximumScale = maximumScale; }61 floatgetMaximumScale() const { return _maximumScale; }60 void setMaximumScale(double maximumScale) { _maximumScale = maximumScale; } 61 double getMaximumScale() const { return _maximumScale; } 62 62 63 inline void setPivotPoint(const Vec3 & pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); }64 inline const Vec3 & getPivotPoint() const { return _pivotPoint; }63 inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); } 64 inline const Vec3d& getPivotPoint() const { return _pivotPoint; } 65 65 66 66 … … 99 99 virtual ~AutoTransform() {} 100 100 101 Vec3 _position;102 Vec3 _pivotPoint;103 float_autoUpdateEyeMovementTolerance;101 Vec3d _position; 102 Vec3d _pivotPoint; 103 double _autoUpdateEyeMovementTolerance; 104 104 105 105 AutoRotateMode _autoRotateMode; … … 108 108 109 109 mutable Quat _rotation; 110 mutable Vec3 _scale;110 mutable Vec3d _scale; 111 111 mutable bool _firstTimeToInitEyePoint; 112 112 mutable osg::Vec3 _previousEyePoint; … … 114 114 mutable Viewport::value_type _previousWidth; 115 115 mutable Viewport::value_type _previousHeight; 116 mutable osg::Matrix _previousProjection;117 mutable osg::Vec3 _previousPosition;116 mutable osg::Matrixd _previousProjection; 117 mutable osg::Vec3d _previousPosition; 118 118 119 float_minimumScale;120 float_maximumScale;121 float_autoScaleTransitionWidthRatio;119 double _minimumScale; 120 double _maximumScale; 121 double _autoScaleTransitionWidthRatio; 122 122 123 123 void computeMatrix() const; 124 124 125 mutable bool _matrixDirty;126 mutable osg::Matrix _cachedMatrix;125 mutable bool _matrixDirty; 126 mutable osg::Matrixd _cachedMatrix; 127 127 }; 128 128 OpenSceneGraph/trunk/src/osg/AutoTransform.cpp
r7968 r8804 19 19 20 20 AutoTransform::AutoTransform(): 21 _autoUpdateEyeMovementTolerance(0.0 f),21 _autoUpdateEyeMovementTolerance(0.0), 22 22 _autoRotateMode(NO_ROTATION), 23 23 _autoScaleToScreen(false), 24 _scale(1.0 f,1.0f,1.0f),24 _scale(1.0,1.0,1.0), 25 25 _firstTimeToInitEyePoint(true), 26 _minimumScale(0.0 f),27 _maximumScale( FLT_MAX),28 _autoScaleTransitionWidthRatio(0.25 f),26 _minimumScale(0.0), 27 _maximumScale(DBL_MAX), 28 _autoScaleTransitionWidthRatio(0.25), 29 29 _matrixDirty(true) 30 30 { … … 50 50 } 51 51 52 void AutoTransform::setScale(const Vec3 & scale)52 void AutoTransform::setScale(const Vec3d& scale) 53 53 { 54 54 _scale = scale; … … 88 88 matrix.postMult(osg::Matrix::translate(-_position)* 89 89 osg::Matrix::rotate(_rotation.inverse())* 90 osg::Matrix::scale(1.0 f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*90 osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())* 91 91 osg::Matrix::translate(_pivotPoint)); 92 92 } … … 95 95 matrix = osg::Matrix::translate(-_position)* 96 96 osg::Matrix::rotate(_rotation.inverse())* 97 osg::Matrix::scale(1.0 f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())*97 osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())* 98 98 osg::Matrix::translate(_pivotPoint); 99 99 } … … 139 139 } 140 140 141 osg::Vec3 eyePoint = cs->getEyeLocal();142 osg::Vec3 localUp = cs->getUpLocal();143 osg::Vec3 position = getPosition();141 osg::Vec3d eyePoint = cs->getEyeLocal(); 142 osg::Vec3d localUp = cs->getUpLocal(); 143 osg::Vec3d position = getPosition(); 144 144 145 145 const osg::Matrix& projection = *(cs->getProjectionMatrix()); … … 148 148 if (!_firstTimeToInitEyePoint) 149 149 { 150 osg::Vec3 dv = _previousEyePoint-eyePoint;150 osg::Vec3d dv = _previousEyePoint-eyePoint; 151 151 if (dv.length2()>getAutoUpdateEyeMovementTolerance()*(eyePoint-getPosition()).length2()) 152 152 { 153 153 doUpdate = true; 154 154 } 155 osg::Vec3 dupv = _previousLocalUp-localUp;155 osg::Vec3d dupv = _previousLocalUp-localUp; 156 156 // rotating the camera only affects ROTATE_TO_* 157 157 if (_autoRotateMode && … … 180 180 if (getAutoScaleToScreen()) 181 181 { 182 float size = 1.0f/cs->pixelSize(getPosition(),0.48f);183 184 if (_autoScaleTransitionWidthRatio>0.0 f)182 double size = 1.0/cs->pixelSize(getPosition(),0.48); 183 184 if (_autoScaleTransitionWidthRatio>0.0) 185 185 { 186 if (_minimumScale>0.0 f)186 if (_minimumScale>0.0) 187 187 { 188 floatj = _minimumScale;189 float i = (_maximumScale<FLT_MAX) ?188 double j = _minimumScale; 189 double i = (_maximumScale<DBL_MAX) ? 190 190 _minimumScale+(_maximumScale-_minimumScale)*_autoScaleTransitionWidthRatio : 191 _minimumScale*(1.0 f+_autoScaleTransitionWidthRatio);192 float c = 1.0f/(4.0f*(i-j));193 float b = 1.0f - 2.0f*c*i;194 float a = j + b*b / (4.0f*c);195 float k = -b / (2.0f*c);191 _minimumScale*(1.0+_autoScaleTransitionWidthRatio); 192 double c = 1.0/(4.0*(i-j)); 193 double b = 1.0 - 2.0*c*i; 194 double a = j + b*b / (4.0*c); 195 double k = -b / (2.0*c); 196 196 197 197 if (size<k) size = _minimumScale; … … 199 199 } 200 200 201 if (_maximumScale< FLT_MAX)201 if (_maximumScale<DBL_MAX) 202 202 { 203 floatn = _maximumScale;204 floatm = (_minimumScale>0.0) ?203 double n = _maximumScale; 204 double m = (_minimumScale>0.0) ? 205 205 _maximumScale+(_minimumScale-_maximumScale)*_autoScaleTransitionWidthRatio : 206 _maximumScale*(1.0 f-_autoScaleTransitionWidthRatio);207 float c = 1.0f / (4.0f*(m-n));208 float b = 1.0f - 2.0f*c*m;209 float a = n + b*b/(4.0f*c);210 float p = -b / (2.0f*c);206 _maximumScale*(1.0-_autoScaleTransitionWidthRatio); 207 double c = 1.0 / (4.0*(m-n)); 208 double b = 1.0 - 2.0*c*m; 209 double a = n + b*b/(4.0*c); 210 double p = -b / (2.0*c); 211 211 212 212 if (size>p) size = _maximumScale; … … 231 231 else if (_autoRotateMode==ROTATE_TO_CAMERA) 232 232 { 233 osg::Vec3 PosToEye = _position - eyePoint;233 osg::Vec3d PosToEye = _position - eyePoint; 234 234 osg::Matrix lookto = osg::Matrix::lookAt( 235 osg::Vec3 (0,0,0), PosToEye, localUp);235 osg::Vec3d(0,0,0), PosToEye, localUp); 236 236 Quat q; 237 237 q.set(osg::Matrix::inverse(lookto)); OpenSceneGraph/trunk/src/osgWrappers/osg/AutoTransform.cpp
r8734 r8804 18 18 #include <osg/Object> 19 19 #include <osg/Quat> 20 #include <osg/Vec3 >20 #include <osg/Vec3d> 21 21 22 22 // Must undefine IN and OUT macros defined in Windows headers … … 85 85 "", 86 86 ""); 87 I_Method1(void, setPosition, IN, const osg::Vec3 &, pos,88 Properties::NON_VIRTUAL, 89 __void__setPosition__C5_Vec3 _R1,90 "", 91 ""); 92 I_Method0(const osg::Vec3 &, getPosition,93 Properties::NON_VIRTUAL, 94 __C5_Vec3 _R1__getPosition,87 I_Method1(void, setPosition, IN, const osg::Vec3d &, pos, 88 Properties::NON_VIRTUAL, 89 __void__setPosition__C5_Vec3d_R1, 90 "", 91 ""); 92 I_Method0(const osg::Vec3d &, getPosition, 93 Properties::NON_VIRTUAL, 94 __C5_Vec3d_R1__getPosition, 95 95 "", 96 96 ""); … … 105 105 "", 106 106 ""); 107 I_Method1(void, setScale, IN, float, scale,108 Properties::NON_VIRTUAL, 109 __void__setScale__ float,110 "", 111 ""); 112 I_Method1(void, setScale, IN, const osg::Vec3 &, scale,113 Properties::NON_VIRTUAL, 114 __void__setScale__C5_Vec3 _R1,115 "", 116 ""); 117 I_Method0(const osg::Vec3 &, getScale,118 Properties::NON_VIRTUAL, 119 __C5_Vec3 _R1__getScale,120 "", 121 ""); 122 I_Method1(void, setMinimumScale, IN, float, minimumScale,123 Properties::NON_VIRTUAL, 124 __void__setMinimumScale__ float,125 "", 126 ""); 127 I_Method0( float, getMinimumScale,128 Properties::NON_VIRTUAL, 129 __ float__getMinimumScale,130 "", 131 ""); 132 I_Method1(void, setMaximumScale, IN, float, maximumScale,133 Properties::NON_VIRTUAL, 134 __void__setMaximumScale__ float,135 "", 136 ""); 137 I_Method0( float, getMaximumScale,138 Properties::NON_VIRTUAL, 139 __ float__getMaximumScale,140 "", 141 ""); 142 I_Method1(void, setPivotPoint, IN, const osg::Vec3 &, pivot,143 Properties::NON_VIRTUAL, 144 __void__setPivotPoint__C5_Vec3 _R1,145 "", 146 ""); 147 I_Method0(const osg::Vec3 &, getPivotPoint,148 Properties::NON_VIRTUAL, 149 __C5_Vec3 _R1__getPivotPoint,107 I_Method1(void, setScale, IN, double, scale, 108 Properties::NON_VIRTUAL, 109 __void__setScale__double, 110 "", 111 ""); 112 I_Method1(void, setScale, IN, const osg::Vec3d &, scale, 113 Properties::NON_VIRTUAL, 114 __void__setScale__C5_Vec3d_R1, 115 "", 116 ""); 117 I_Method0(const osg::Vec3d &, getScale, 118 Properties::NON_VIRTUAL, 119 __C5_Vec3d_R1__getScale, 120 "", 121 ""); 122 I_Method1(void, setMinimumScale, IN, double, minimumScale, 123 Properties::NON_VIRTUAL, 124 __void__setMinimumScale__double, 125 "", 126 ""); 127 I_Method0(double, getMinimumScale, 128 Properties::NON_VIRTUAL, 129 __double__getMinimumScale, 130 "", 131 ""); 132 I_Method1(void, setMaximumScale, IN, double, maximumScale, 133 Properties::NON_VIRTUAL, 134 __void__setMaximumScale__double, 135 "", 136 ""); 137 I_Method0(double, getMaximumScale, 138 Properties::NON_VIRTUAL, 139 __double__getMaximumScale, 140 "", 141 ""); 142 I_Method1(void, setPivotPoint, IN, const osg::Vec3d &, pivot, 143 Properties::NON_VIRTUAL, 144 __void__setPivotPoint__C5_Vec3d_R1, 145 "", 146 ""); 147 I_Method0(const osg::Vec3d &, getPivotPoint, 148 Properties::NON_VIRTUAL, 149 __C5_Vec3d_R1__getPivotPoint, 150 150 "", 151 151 ""); … … 223 223 __float__getAutoUpdateEyeMovementTolerance, 224 224 __void__setAutoUpdateEyeMovementTolerance__float); 225 I_SimpleProperty( float, MaximumScale,226 __ float__getMaximumScale,227 __void__setMaximumScale__ float);228 I_SimpleProperty( float, MinimumScale,229 __ float__getMinimumScale,230 __void__setMinimumScale__ float);231 I_SimpleProperty(const osg::Vec3 &, PivotPoint,232 __C5_Vec3 _R1__getPivotPoint,233 __void__setPivotPoint__C5_Vec3 _R1);234 I_SimpleProperty(const osg::Vec3 &, Position,235 __C5_Vec3 _R1__getPosition,236 __void__setPosition__C5_Vec3 _R1);225 I_SimpleProperty(double, MaximumScale, 226 __double__getMaximumScale, 227 __void__setMaximumScale__double); 228 I_SimpleProperty(double, MinimumScale, 229 __double__getMinimumScale, 230 __void__setMinimumScale__double); 231 I_SimpleProperty(const osg::Vec3d &, PivotPoint, 232 __C5_Vec3d_R1__getPivotPoint, 233 __void__setPivotPoint__C5_Vec3d_R1); 234 I_SimpleProperty(const osg::Vec3d &, Position, 235 __C5_Vec3d_R1__getPosition, 236 __void__setPosition__C5_Vec3d_R1); 237 237 I_SimpleProperty(const osg::Quat &, Rotation, 238 238 __C5_Quat_R1__getRotation, 239 239 __void__setRotation__C5_Quat_R1); 240 I_SimpleProperty(const osg::Vec3 &, Scale,241 __C5_Vec3 _R1__getScale,242 __void__setScale__C5_Vec3 _R1);240 I_SimpleProperty(const osg::Vec3d &, Scale, 241 __C5_Vec3d_R1__getScale, 242 __void__setScale__C5_Vec3d_R1); 243 243 END_REFLECTOR 244 244 OpenSceneGraph/trunk/src/osgWrappers/osgTerrain/Layer.cpp
r7872 r8804 870 870 END_REFLECTOR 871 871 872 BEGIN_OBJECT_REFLECTOR(osgTerrain::SwitchLayer) 873 I_DeclaringFile("osgTerrain/Layer"); 874 I_BaseType(osgTerrain::Layer); 875 I_Constructor0(____SwitchLayer, 876 "", 877 ""); 878 I_ConstructorWithDefaults2(IN, const osgTerrain::SwitchLayer &, switchLayer, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, 879 ____SwitchLayer__C5_SwitchLayer_R1__C5_osg_CopyOp_R1, 880 "Copy constructor using CopyOp to manage deep vs shallow copy. ", 881 ""); 882 I_Method0(osg::Object *, cloneType, 883 Properties::VIRTUAL, 884 __osg_Object_P1__cloneType, 885 "Clone the type of an object, with Object* return type. ", 886 "Must be defined by derived classes. "); 887 I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop, 888 Properties::VIRTUAL, 889 __osg_Object_P1__clone__C5_osg_CopyOp_R1, 890 "Clone an object, with Object* return type. ", 891 "Must be defined by derived classes. "); 892 I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, 893 Properties::VIRTUAL, 894 __bool__isSameKindAs__C5_osg_Object_P1, 895 "", 896 ""); 897 I_Method0(const char *, libraryName, 898 Properties::VIRTUAL, 899 __C5_char_P1__libraryName, 900 "return the name of the object's library. ", 901 "Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name. "); 902 I_Method0(const char *, className, 903 Properties::VIRTUAL, 904 __C5_char_P1__className, 905 "return the name of the object's class type. ", 906 "Must be defined by derived classes. "); 907 I_Method0(void, clear, 908 Properties::NON_VIRTUAL, 909 __void__clear, 910 "", 911 ""); 912 I_Method1(void, setActiveLayer, IN, unsigned int, i, 913 Properties::NON_VIRTUAL, 914 __void__setActiveLayer__unsigned_int, 915 "", 916 ""); 917 I_Method0(unsigned int, getActiveLayer, 918 Properties::NON_VIRTUAL, 919 __unsigned_int__getActiveLayer, 920 "", 921 ""); 922 I_Method2(void, setFileName, IN, unsigned int, i, IN, const std::string &, filename, 923 Properties::NON_VIRTUAL, 924 __void__setFileName__unsigned_int__C5_std_string_R1, 925 "", 926 ""); 927 I_Method1(const std::string &, getFileName, IN, unsigned int, i, 928 Properties::NON_VIRTUAL, 929 __C5_std_string_R1__getFileName__unsigned_int, 930 "", 931 ""); 932 I_Method2(void, setLayer, IN, unsigned int, i, IN, osgTerrain::Layer *, layer, 933 Properties::NON_VIRTUAL, 934 __void__setLayer__unsigned_int__Layer_P1, 935 "", 936 ""); 937 I_Method1(osgTerrain::Layer *, getLayer, IN, unsigned int, i, 938 Properties::NON_VIRTUAL, 939 __Layer_P1__getLayer__unsigned_int, 940 "", 941 ""); 942 I_Method1(const osgTerrain::Layer *, getLayer, IN, unsigned int, i, 943 Properties::NON_VIRTUAL, 944 __C5_Layer_P1__getLayer__unsigned_int, 945 "", 946 ""); 947 I_Method1(void, addLayer, IN, const std::string &, filename, 948 Properties::NON_VIRTUAL, 949 __void__addLayer__C5_std_string_R1, 950 "", 951 ""); 952 I_Method1(void, addLayer, IN, osgTerrain::Layer *, layer, 953 Properties::NON_VIRTUAL, 954 __void__addLayer__Layer_P1, 955 "", 956 ""); 957 I_Method1(void, removeLayer, IN, unsigned int, i, 958 Properties::NON_VIRTUAL, 959 __void__removeLayer__unsigned_int, 960 "", 961 ""); 962 I_Method0(unsigned int, getNumLayers, 963 Properties::NON_VIRTUAL, 964 __unsigned_int__getNumLayers, 965 "", 966 ""); 967 I_SimpleProperty(unsigned int, ActiveLayer, 968 __unsigned_int__getActiveLayer, 969 __void__setActiveLayer__unsigned_int); 970 I_IndexedProperty(const std::string &, FileName, 971 __C5_std_string_R1__getFileName__unsigned_int, 972 __void__setFileName__unsigned_int__C5_std_string_R1, 973 0); 974 I_ArrayProperty(osgTerrain::Layer *, Layer, 975 __Layer_P1__getLayer__unsigned_int, 976 __void__setLayer__unsigned_int__Layer_P1, 977 __unsigned_int__getNumLayers, 978 __void__addLayer__Layer_P1, 979 0, 980 __void__removeLayer__unsigned_int); 981 END_REFLECTOR 982
