Hi Anton, nothing prevents you to use the same code with osg
just get osg::Matrixd viewMatrix=osgcamera->getViewMatrix(); osg::Matrixd projMatrix=osgcamera->getProjectionMatrix(); GLint viewport[4]; viewport[0]=osgcamera->getViewport()->x(); viewport[1]=osgcamera->getViewport()->y(); viewport[2]=osgcamera->getViewport()->width(); viewport[3]=osgcamera->getViewport()->height(); then you might pass viewMatrix.ptr() projMatrix.ptr() viewport to gluUnProject function Regards Sergey On Thu, Oct 30, 2014 at 4:28 PM, AntonPopov <[email protected]> wrote: > Hi, > > I would like to calculate the scale of a pixel. In a program in OpenGL, I > hate it posted a Function. How can I make it for OSG? > > > Code: > > Public Function get_Massstab() As Double > > Dim modelmatrix(15) As Double > Dim projMatrix(15) As Double > Dim viewMatrix(3) As Integer > > Dim tx1 As Double > Dim ty1 As Double > Dim tz1 As Double > Dim tx2 As Double > Dim ty2 As Double > Dim tz2 As Double > Dim dist As Double > > Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, modelmatrix) > Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, projMatrix) > Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewMatrix) > > gluUnProject(0, 0, 0, modelmatrix, projMatrix, viewMatrix, tx1, ty1, > tz1) > gluUnProject(0, 1, 0, modelmatrix, projMatrix, viewMatrix, tx2, ty2, > tz2) > > 'einen Pixel > dist = Math.Sqrt((tx1 - tx2) ^ 2 + (ty1 - ty2) ^ 2 + (tz1 - tz2) ^ 2) > Return dist > > End Function > > > > > Thank you! > > Cheers, > Anton[/code] > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=61462#61462 > > > > > Attachments: > http://forum.openscenegraph.org//files/size2_801.png > http://forum.openscenegraph.org//files/size1_776.png > > > _______________________________________________ > 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

