Re: [osg-users] Local coordinates
Hi Zeiki, On 8 February 2013 06:56, Zeki Yugnak zeki.yug...@gmail.com wrote: Hi Robert, I found the problem yesterday. You are right, the problem is regarding to floating point usage. I am computing camera position using center of the object's BoundingSphere. When I start debug whole code, I figure out that the BoundingSphere type is floating point and OSG_USE_FLOAT_BOUNDINGSPHERE parameter is defined in Config header file as default. So, Flicker problem is regarding to camera position. The problem is gone after this parameter is undefined. You shouldn't need to build the OSG with double BoudingSphere for GIS applications. FYI, the header file is written by the CMake so use ccmake/CMakeSetup to select the OSG_* build options you want and let it set the headers that need setting. One more question is Why is osg::Vec3's type defined as a floating point? OpenGL hardware is built around floats so when you pass in vertex arrays they need to floats so it makes sense for the default Vec3 to be Vec3f rather than Vec3d. You can use Vec3d arrays with OpenGL but typically the driver will convert from doubles down to float and will be very very slow. The OSG avoids the precision issues that would occur normally with OpenGL and systems with large coordinate values that would be an issue with floats by using doubles in the Camera and internal Transform nodes, and during the cull traversal accumulates the projection and modelview matrices all in doubles maintaining the precisions as long as possible before it's passed to OpenGL where the driver typically casts down to floats. If you manage your Camera positioning and the database creation correctly you create a system that doesn't suffer from visible jitter as the precision issues are subpixel. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
HI Zeki, I don't know the specific cause of the problem but again as I don't have your problem infront of me or the able to see the problem first hand. Best I can do is stress that you need to use doubles. Go back through your original code submission, is everything doubles??? Keeping looking until you spot an error in not using doubles. Whether this might be the cause of the problem I cannot say. Developing your observational skills is crucial for a programmer so I'll leave it to you to sort out the details, practice makes perfect :-) Robert. On 7 February 2013 06:50, Zeki Yugnak zeki.yug...@gmail.com wrote: Hi Shayne, Thanks for your help. Your's transformation code block is the same as mine's. I really do not know why object's translation is not smooth. Also I could not use second code block because of terrain-object correlation problem. But I hope that I will translate object smoothly using local coordinates, if I can transform terrain or scene to a origin point that is used to calculate object local coordinates. Do you have any idea that could not handle with over million values in ECEF coordinate system using different coordinates system to transform object ? For example, If I transform root scene to the center of the terrain in ECEF coordinate system or add my object as a child of the terrain, Can I calculate object transformations again according to the center of the terrain in ECEF coordinate system? Do you think that it makes sense? Thank you! Regards -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52448#52448 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
Hi Robert, I found the problem yesterday. You are right, the problem is regarding to floating point usage. I am computing camera position using center of the object's BoundingSphere. When I start debug whole code, I figure out that the BoundingSphere type is floating point and OSG_USE_FLOAT_BOUNDINGSPHERE parameter is defined in Config header file as default. So, Flicker problem is regarding to camera position. The problem is gone after this parameter is undefined. One more question is Why is osg::Vec3's type defined as a floating point? Thanks for all yours help. Regards. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52478#52478 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
Hi everyone, I just started using Openscenegraph. I have some questions regarding coordinate systems. I am trying to develop simple debriefing application. I am using geographic (lat, long and alt ) coordinates and rotations information that were recorded on vehicle to transform objects in 3D space. I am also using geocentric terrain in order to show vehicle on the correct coordinates. I have no problem on terrain displaying phase but the transformation is not smooth because of cordinates's higher value. I am using world coordinates which are obtained by computeLocalToWorldTransformFromLatLongHeight to transform and position objects. So Can I use local coordinates instead of world coordinates for object transformations? or How can I transform rootscene to the origin point? ... Thank you for any help. Regards. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52387#52387 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
Zeki, Don't transform the root scene (I assume you mean the terrain). Instead just take the matrix you got from computeLocalToWorldTransformFromLatLongHeight() and put that into a MatrixTransform. Then any points under that MatrixTransform are local to that world point, and you won't have any precision jittering problems. Glenn Waldron / @glennwaldron On Tue, Feb 5, 2013 at 9:36 AM, Zeki Yugnak zeki.yug...@gmail.com wrote: Hi everyone, I just started using Openscenegraph. I have some questions regarding coordinate systems. I am trying to develop simple debriefing application. I am using geographic (lat, long and alt ) coordinates and rotations information that were recorded on vehicle to transform objects in 3D space. I am also using geocentric terrain in order to show vehicle on the correct coordinates. I have no problem on terrain displaying phase but the transformation is not smooth because of cordinates's higher value. I am using world coordinates which are obtained by computeLocalToWorldTransformFromLatLongHeight to transform and position objects. So Can I use local coordinates instead of world coordinates for object transformations? or How can I transform rootscene to the origin point? ... Thank you for any help. Regards. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52387#52387 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
Hi Glenn , I have been already doing what you're saying. Here is the transformation code block; Code: osg::Vec3 rotation(currentRotation.Heading, currentRotation.Pitch, currentRotation.Roll); osg::Matrix hprRotationMat; Util::HprToMatrix(hprRotationMat, rotation); //Ellipsoid model of the root scene osg::EllipsoidModel* ellipsoid = pScene-getEllipsoidModel(); //x, y, z positions of the object in ECEF coordinate system osg::Matrix worldMatrix; ellipsoid-computeLocalToWorldTransformFromLatLongHeight(GeoPosition.Latitude, GeoPosition.Longitude, GeoPosition.Altitude, worldMatrix); osg::Matrix resultMat = worldMatrix; osg::Quat currentRotationQuat = hprRotationMat.getRotate(); resultMat.preMultRotate(currentRotationQuat); double scaleSize = 1.0; myObject-setMatrix(GMatrix::scale( scaleSize, scaleSize, scaleSize ) * resultMat ); There is not problem correlation to object and terrain with these code block. The problem is that my object does not move smoothly. It moves up and down little bit. X,y,z coordinates are over million in ECEF coordinate system. I supposed that graphic card is giving rounding off error or else what? If I use local coordinates that are converted from lats/long/height according to center point of the terrain, object moves correctly. Bu this time, I am having terrain-object correlation problem. The terrain (is not whole earth) was created correctly using osgdem with --terrain and --geocentric parameters. Also I can compute camera position correctly and easily track my object using orbit manipulator. The question is, How can I calculate object transformation without terrain-object correlation problem ,using different coordinate system that is calculated according to center of the terrain? Below is the local coordinate calculation code block; Code: osg::Vec3d GetCartesianPoint(mLatitude, mLongitude, mAltitude) { osg::Vec3d rawCartesian; rawCartesian.x() = (mLongitude * EQUATORIAL_RADIUS) * osg::DegreesToRadians(1.0); // azuma: removed negation on mLatitude, so that as latitude increases, Y increases rawCartesian.y() = (mLatitude * EQUATORIAL_RADIUS) * osg::DegreesToRadians(1.0); rawCartesian.z() = mAltitude; osg::Vec3d mCartesianPoint = rawCartesian - gOriginOffset; return mCartesianPoint; } //gOriginOffset is computed with below code block, OriginLongitude, OriginLatitude and OriginAltitude are the center coordinates of the terrain { gOriginOffset.x() = (OriginLongitude * EQUATORIAL_RADIUS) * osg::DegreesToRadians(1.0); // azuma: removed negation on mLatitude, so that as latitude increases, Y increases gOriginOffset.y() = (OriginLatitude * EQUATORIAL_RADIUS) * osg::DegreesToRadians(1.0); gOriginOffset.z() = OriginAltitude; } Thank you! Regards.[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52435#52435 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
A couple of observations: 1) The units will be in millions because your database is a round earth database using the WGS84 spheroid ECEF CS with units in meters. 2) I don't understand how your second code blocks maps correctly to the geocentric cartesian round earth database built with osgdem using the --geocentric flag. I use this code block to map from geodetic to geocentric CS just fine without precision problems. My models move smoothly on the terrain surface... Code: void Model::UpdateOrientation() { orientation.makeRotate(osg::DegreesToRadians(roll), osg::Vec3f(0.0,1.0,0.0), // roll osg::DegreesToRadians(pitch), osg::Vec3f(1.0,0.0,0.0), // pitch osg::DegreesToRadians(-heading), osg::Vec3f(0.0,0.0,1.0)); // yaw (-heading) } void Model::UpdatePosition() { _ellipsoid-computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(lat), osg::DegreesToRadians(lon), altitude, position); } void Model::Update() { osg::Matrixd t_matrix; t_matrix = osg::Matrixd::rotate(orientation) * position; transform-setMatrix(t_matrix); } Shayne[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52441#52441 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Local coordinates
Hi Shayne, Thanks for your help. Your's transformation code block is the same as mine's. I really do not know why object's translation is not smooth. Also I could not use second code block because of terrain-object correlation problem. But I hope that I will translate object smoothly using local coordinates, if I can transform terrain or scene to a origin point that is used to calculate object local coordinates. Do you have any idea that could not handle with over million values in ECEF coordinate system using different coordinates system to transform object ? For example, If I transform root scene to the center of the terrain in ECEF coordinate system or add my object as a child of the terrain, Can I calculate object transformations again according to the center of the terrain in ECEF coordinate system? Do you think that it makes sense? Thank you! Regards -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52448#52448 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org