diff --git a/3d-viewer/3d_cache/sg/scenegraph.cpp b/3d-viewer/3d_cache/sg/scenegraph.cpp index 0aee4bf713..7a4c6ae5c2 100644 --- a/3d-viewer/3d_cache/sg/scenegraph.cpp +++ b/3d-viewer/3d_cache/sg/scenegraph.cpp @@ -260,7 +260,13 @@ bool SCENEGRAPH::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) aFile << " Transform {\n"; } - S3D::FormatPoint( tmp, center ); + // convert center to 1VRML unit = 0.1 inch + SGPOINT pt = center; + pt.x /= 2.54; + pt.y /= 2.54; + pt.z /= 2.54; + + S3D::FormatPoint( tmp, pt ); aFile << " center " << tmp << "\n"; S3D::FormatOrientation( tmp, rotation_axis, rotation_angle ); aFile << " rotation " << tmp << "\n"; @@ -268,7 +274,13 @@ bool SCENEGRAPH::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) aFile << " scale " << tmp << "\n"; S3D::FormatOrientation( tmp, scale_axis, scale_angle ); aFile << " scaleOrientation " << tmp << "\n"; - S3D::FormatPoint( tmp, translation ); + + // convert translation to 1VRML unit = 0.1 inch + pt = translation; + pt.x /= 2.54; + pt.y /= 2.54; + pt.z /= 2.54; + S3D::FormatPoint( tmp, pt ); aFile << " translation " << tmp << "\n"; aFile << " children [\n"; diff --git a/plugins/3d/vrml/v1/vrml1_transform.cpp b/plugins/3d/vrml/v1/vrml1_transform.cpp index 3a4606ec0b..4d6258fb10 100644 --- a/plugins/3d/vrml/v1/vrml1_transform.cpp +++ b/plugins/3d/vrml/v1/vrml1_transform.cpp @@ -173,6 +173,11 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) return false; } + + // convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm + center.x *= 2.54; + center.y *= 2.54; + center.z *= 2.54; } else if( !glob.compare( "rotation" ) ) { @@ -233,6 +238,11 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) return false; } + + // convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm + translation.x *= 2.54; + translation.y *= 2.54; + translation.z *= 2.54; } else { diff --git a/plugins/3d/vrml/v2/vrml2_transform.cpp b/plugins/3d/vrml/v2/vrml2_transform.cpp index e3eb084883..c430ff9103 100644 --- a/plugins/3d/vrml/v2/vrml2_transform.cpp +++ b/plugins/3d/vrml/v2/vrml2_transform.cpp @@ -188,6 +188,11 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) return false; } + + // convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm + center.x *= 2.54; + center.y *= 2.54; + center.z *= 2.54; } else if( !glob.compare( "rotation" ) ) { @@ -248,6 +253,11 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) return false; } + + // convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm + translation.x *= 2.54; + translation.y *= 2.54; + translation.z *= 2.54; } else if( !glob.compare( "children" ) ) {