Hi Jon, The pixelSize function is an approximation of the mapping, making assumptions, for the purposes of speed, with the intention of providing good enough results for most purposes. So rather than being wrong, is just not accurate for your particular usage model.
The question then really is do we add another mode into AutoTransform that uses a more expensive computation. Feel free to adds such a mode and support into AutoTransform and submit it. Cheers, Robert. On Mon, Nov 24, 2008 at 2:04 PM, Marjamaa, Jonathon E <[EMAIL PROTECTED]> wrote: > Hi, > > I have been looking into this, and I really think there is something > wrong with the way that AutoTransform calculates the scale. > > Attached is the screen shot showing what I am seeing in dual screen. > Both screens are the same resolution, so I would guess the asymmetry in > the horizontal frustum angles is confusing the algorithm somehow, > although I am seeing problems with horizontally symmetric frustums as > well. > > I was able to get this to work much more accurately by changing > AutoTransform, line 182 from: > > float size = 1.0f/cs->pixelSize(getPosition(),0.48f); > > To: > > const osg::Matrix& matrix = *(cs->getMVPW()); > osg::Vec3d one = cs->getUpLocal(); // get a screen aligned vector > osg::Vec3d zeroTrans = osg::Vec3d(0, 0, 0) * matrix; // get node origin > in screen space > osg::Vec3d oneTrans = one * matrix; // get vector in screen space > float size = 1.0 / sqrt((zeroTrans[0] - oneTrans[0]) * (zeroTrans[0] - > oneTrans[0]) + > (zeroTrans[1] - oneTrans[1]) * (zeroTrans[1] - > oneTrans[1]) + > (zeroTrans[2] - oneTrans[2]) * (zeroTrans[2] - > oneTrans[2])); // calculate the length of the vector in screen space > > I am sure this is more expensive, but it does get me to something more > closely resembling localized screen space. > > Jon > > -----Original Message----- > From: Marjamaa, Jonathon E > Sent: Thursday, November 20, 2008 4:23 PM > To: [email protected] > Subject: [osg-users] AutoTransform scaling precision. > > Hello, > >> I am seeing some odd behavior with AutoTransform. The following .osg >> file creates an AutoTransform with a grid of lines attached. The >> lines are each separated by one unit of space. When I look at the >> file in osgviewer, I see that this spacing is not kept. It looks like > >> the auto-scale is not exact. The imprecision seems to vary with >> projection, viewport size, and on my windows dual-screen setup it >> varies with monitor! If I make the window very wide and short, the >> shape is scaled so much as to actually shrink significantly in screen >> space. >> >> Am I using the AutoTransform incorrectly? Am I expecting this to do >> more than was intended? >> >> Thanks, >> Jonathon Marjamaa >> >> AutoTransform { >> UniqueID AutoTransform_0 >> nodeMask 0xffffffff >> cullingActive TRUE >> referenceFrame RELATIVE >> position 0 0 0 >> rotation 0 0 0 1 >> scale 1 1 1 >> pivotPoint 0 0 0 >> autoUpdateEyeMovementTolerance 0 >> autoRotateMode ROTATE_TO_SCREEN >> autoScaleToScreen TRUE >> num_children 2 >> Geode { >> UniqueID Geode_1 >> nodeMask 0xffffffff >> cullingActive TRUE >> num_drawables 2 >> Geometry { >> useDisplayList TRUE >> useVertexBufferObjects FALSE >> VertexArray UniqueID Vec3Array_3 Vec3Array 200 >> { >> 0 0 0 >> 0 150 0 >> 0 0 0 >> 150 0 0 >> 2 0 0 >> 2 150 0 >> 0 2 0 >> 150 2 0 >> 4 0 0 >> 4 150 0 >> 0 4 0 >> 150 4 0 >> 6 0 0 >> 6 150 0 >> 0 6 0 >> 150 6 0 >> 8 0 0 >> 8 150 0 >> 0 8 0 >> 150 8 0 >> 10 0 0 >> 10 150 0 >> 0 10 0 >> 150 10 0 >> 12 0 0 >> 12 150 0 >> 0 12 0 >> 150 12 0 >> 14 0 0 >> 14 150 0 >> 0 14 0 >> 150 14 0 >> 16 0 0 >> 16 150 0 >> 0 16 0 >> 150 16 0 >> 18 0 0 >> 18 150 0 >> 0 18 0 >> 150 18 0 >> 20 0 0 >> 20 150 0 >> 0 20 0 >> 150 20 0 >> 22 0 0 >> 22 150 0 >> 0 22 0 >> 150 22 0 >> 24 0 0 >> 24 150 0 >> 0 24 0 >> 150 24 0 >> 26 0 0 >> 26 150 0 >> 0 26 0 >> 150 26 0 >> 28 0 0 >> 28 150 0 >> 0 28 0 >> 150 28 0 >> 30 0 0 >> 30 150 0 >> 0 30 0 >> 150 30 0 >> 32 0 0 >> 32 150 0 >> 0 32 0 >> 150 32 0 >> 34 0 0 >> 34 150 0 >> 0 34 0 >> 150 34 0 >> 36 0 0 >> 36 150 0 >> 0 36 0 >> 150 36 0 >> 38 0 0 >> 38 150 0 >> 0 38 0 >> 150 38 0 >> 40 0 0 >> 40 150 0 >> 0 40 0 >> 150 40 0 >> 42 0 0 >> 42 150 0 >> 0 42 0 >> 150 42 0 >> 44 0 0 >> 44 150 0 >> 0 44 0 >> 150 44 0 >> 46 0 0 >> 46 150 0 >> 0 46 0 >> 150 46 0 >> 48 0 0 >> 48 150 0 >> 0 48 0 >> 150 48 0 >> 50 0 0 >> 50 150 0 >> 0 50 0 >> 150 50 0 >> 52 0 0 >> 52 150 0 >> 0 52 0 >> 150 52 0 >> 54 0 0 >> 54 150 0 >> 0 54 0 >> 150 54 0 >> 56 0 0 >> 56 150 0 >> 0 56 0 >> 150 56 0 >> 58 0 0 >> 58 150 0 >> 0 58 0 >> 150 58 0 >> 60 0 0 >> 60 150 0 >> 0 60 0 >> 150 60 0 >> 62 0 0 >> 62 150 0 >> 0 62 0 >> 150 62 0 >> 64 0 0 >> 64 150 0 >> 0 64 0 >> 150 64 0 >> 66 0 0 >> 66 150 0 >> 0 66 0 >> 150 66 0 >> 68 0 0 >> 68 150 0 >> 0 68 0 >> 150 68 0 >> 70 0 0 >> 70 150 0 >> 0 70 0 >> 150 70 0 >> 72 0 0 >> 72 150 0 >> 0 72 0 >> 150 72 0 >> 74 0 0 >> 74 150 0 >> 0 74 0 >> 150 74 0 >> 76 0 0 >> 76 150 0 >> 0 76 0 >> 150 76 0 >> 78 0 0 >> 78 150 0 >> 0 78 0 >> 150 78 0 >> 80 0 0 >> 80 150 0 >> 0 80 0 >> 150 80 0 >> 82 0 0 >> 82 150 0 >> 0 82 0 >> 150 82 0 >> 84 0 0 >> 84 150 0 >> 0 84 0 >> 150 84 0 >> 86 0 0 >> 86 150 0 >> 0 86 0 >> 150 86 0 >> 88 0 0 >> 88 150 0 >> 0 88 0 >> 150 88 0 >> 90 0 0 >> 90 150 0 >> 0 90 0 >> 150 90 0 >> 92 0 0 >> 92 150 0 >> 0 92 0 >> 150 92 0 >> 94 0 0 >> 94 150 0 >> 0 94 0 >> 150 94 0 >> 96 0 0 >> 96 150 0 >> 0 96 0 >> 150 96 0 >> 98 0 0 >> 98 150 0 >> 0 98 0 >> 150 98 0 >> 100 0 0 >> 100 150 0 >> 0 100 0 >> 150 100 0 >> } >> VertexIndices UniqueID UShortArray_4 UShortArray 200 >> { >> 0 1 2 3 4 5 6 7 8 9 >> 10 11 12 13 14 15 16 17 18 19 >> 20 21 22 23 24 25 26 27 28 29 >> 30 31 32 33 34 35 36 37 38 39 >> 40 41 42 43 44 45 46 47 48 49 >> 50 51 52 53 54 55 56 57 58 59 >> 60 61 62 63 64 65 66 67 68 69 >> 70 71 72 73 74 75 76 77 78 79 >> 80 81 82 83 84 85 86 87 88 89 >> 90 91 92 93 94 95 96 97 98 99 >> 100 101 102 103 104 105 106 107 108 109 >> 110 111 112 113 114 115 116 117 118 119 >> 120 121 122 123 124 125 126 127 128 129 >> 130 131 132 133 134 135 136 137 138 139 >> 140 141 142 143 144 145 146 147 148 149 >> 150 151 152 153 154 155 156 157 158 159 >> 160 161 162 163 164 165 166 167 168 169 >> 170 171 172 173 174 175 176 177 178 179 >> 180 181 182 183 184 185 186 187 188 189 >> 190 191 192 193 194 195 196 197 198 199 >> } >> ColorBinding OVERALL >> ColorArray Vec4Array 1 >> { >> 1 1 1 0.85 >> } >> } >> Geometry { >> useDisplayList TRUE >> useVertexBufferObjects FALSE >> PrimitiveSets 1 >> { >> DrawArrays LINES 0 200 >> } >> VertexArray Use Vec3Array_3 >> VertexIndices Use UShortArray_4 >> ColorBinding OVERALL >> ColorArray Vec4Array 1 >> { >> 1 0 0 1 >> } >> } >> } >> } > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or > g > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

