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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to