Added include/osg/EarthSky and src/osg/EarthSky to cvs.
Also move osg across to using radians for angular paramters by default. By defining USE_DEGREES_INTERNALLY you can get the OSG to revert to the old style degrees. This later feature is deprecated and only meant for helping comptability in the interim.
This commit is contained in:
@@ -204,8 +204,8 @@ bool GliderManipulator::calcMovement()
|
||||
osg::Vec3 sv = _camera->getSideVector();
|
||||
osg::Vec3 lv = _camera->getLookVector();
|
||||
|
||||
float pitch = -dy*0.15f*dt;
|
||||
float roll = -dx*0.1f*dt;
|
||||
float pitch = inDegrees(-dy*0.15f*dt);
|
||||
float roll = inDegrees(-dx*0.1f*dt);
|
||||
|
||||
osg::Matrix mat;
|
||||
mat.makeTrans(-center);
|
||||
@@ -214,7 +214,7 @@ bool GliderManipulator::calcMovement()
|
||||
if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED)
|
||||
{
|
||||
float bank = asinf(sv.z());
|
||||
float yaw = (-bank*180.0f/M_PI)*dt;
|
||||
float yaw = inRadians(-bank)*dt;
|
||||
mat *= Matrix::rotate(yaw,0.0f,0.0f,1.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -336,8 +336,7 @@ int main( int argc, char **argv )
|
||||
osg::Timer_t after_load = timer.tick();
|
||||
cout << "Time for load = "<<timer.delta_s(before_load,after_load)<<" seconds"<<endl;
|
||||
|
||||
osg::ref_ptr<MySceneView> mySceneView = new MySceneView(viewerMode,socketNumber,camera_fov,camera_offset);
|
||||
|
||||
osg::ref_ptr<MySceneView> mySceneView = new MySceneView(viewerMode,socketNumber,camera_fov,osg::inDegrees(camera_offset));
|
||||
mySceneView->setSceneData(rootnode);
|
||||
|
||||
// initialize the viewer.
|
||||
|
||||
@@ -170,7 +170,7 @@ int main( int argc, char **argv )
|
||||
myTransform->addChild( createCube() );
|
||||
|
||||
// move node in a circle at 90 degrees a sec.
|
||||
myTransform->setAppCallback(new TransformCallback(myTransform,90.0f));
|
||||
myTransform->setAppCallback(new TransformCallback(myTransform,osg::inDegrees(90.0f)));
|
||||
|
||||
// create the viewer and the model to it.
|
||||
osgGLUT::Viewer viewer;
|
||||
|
||||
@@ -473,7 +473,7 @@ int main( int argc, char **argv )
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootNode );
|
||||
|
||||
loadedModelTransform->setAppCallback(new TransformCallback(loadedModelTransform,45.0f));
|
||||
loadedModelTransform->setAppCallback(new TransformCallback(loadedModelTransform,osg::inDegrees(45.0f)));
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
|
||||
@@ -10,7 +10,6 @@ using namespace osg;
|
||||
Billboard::Billboard()
|
||||
{
|
||||
_mode = AXIAL_ROT;
|
||||
// _mode = POINT_ROT_WORLD;
|
||||
_axis.set(0.0f,0.0f,1.0f);
|
||||
}
|
||||
|
||||
@@ -85,7 +84,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
|
||||
{
|
||||
mat.makeIdent();
|
||||
//float rotation_zrotation_z = atan2f(ev.x(),ev.y());
|
||||
//mat.makeRot(rotation_z*180.0f/M_PI,0.0f,0.0f,1.0f);
|
||||
//mat.makeRot(inRadians(rotation_z),0.0f,0.0f,1.0f);
|
||||
float inv = 1.0f/ev_length;
|
||||
float c = ev.y()*inv;
|
||||
float s = ev.x()*inv;
|
||||
@@ -123,7 +122,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
|
||||
cp /= cp_len;
|
||||
|
||||
float rotation_cp = acosf(dot);
|
||||
mat.makeRot(rotation_cp*180.0f/M_PI,cp[0],cp[1],cp[2]);
|
||||
mat.makeRot(inRadians(rotation_cp),cp[0],cp[1],cp[2]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
20
src/osg/EarthSky.cpp
Normal file
20
src/osg/EarthSky.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "osg/EarthSky"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
/**
|
||||
* EarthSky constructor.
|
||||
*/
|
||||
EarthSky::EarthSky()
|
||||
{
|
||||
StateSet* stateset = new StateSet;
|
||||
stateset->setRenderBinDetails(-1,"RenderBin");
|
||||
setStateSet(stateset);
|
||||
|
||||
_requiresClear = true;
|
||||
_clearColor.set(0.0f,0.0f,0.0f,1.0f);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using namespace osg;
|
||||
#define DEG2RAD(x) ((x)*M_PI/180.0)
|
||||
#define RAD2DEG(x) ((x)*180.0/M_PI)
|
||||
|
||||
|
||||
// temporary #define's for warning that deprecated methods are being
|
||||
// used which should be replaced by the new variants.
|
||||
#define WARN_DEPRECATED
|
||||
@@ -33,8 +34,6 @@ using namespace osg;
|
||||
#define DEPRECATED(message)
|
||||
#endif
|
||||
|
||||
#define ANGLES_IN_DEGREES
|
||||
|
||||
|
||||
#define SET_ROW(row, v1, v2, v3, v4 ) \
|
||||
_mat[(row)][0] = (v1); \
|
||||
@@ -168,11 +167,8 @@ void Matrix::makeRot( const Vec3& from, const Vec3& to )
|
||||
double d = from * to; // dot product == cos( angle between from & to )
|
||||
if( d < 0.9999 ) {
|
||||
double angle = acos(d);
|
||||
#ifdef ANGLES_IN_DEGREES
|
||||
angle = RAD2DEG(angle);
|
||||
#endif
|
||||
Vec3 axis = to ^ from; //we know ((to) x (from)) is perpendicular to both
|
||||
makeRot( angle, axis );
|
||||
makeRot( inRadians(angle) , axis );
|
||||
}
|
||||
else
|
||||
makeIdent();
|
||||
@@ -188,7 +184,7 @@ void Matrix::makeRot( float angle, float x, float y, float z ) {
|
||||
if( d == 0 )
|
||||
return;
|
||||
|
||||
#ifdef ANGLES_IN_DEGREES
|
||||
#ifdef USE_DEGREES_INTERNALLY
|
||||
angle = DEG2RAD(angle);
|
||||
#endif
|
||||
|
||||
@@ -230,7 +226,7 @@ void Matrix::makeRot( const Quat& q ) {
|
||||
|
||||
void Matrix::makeRot( float yaw, float pitch, float roll)
|
||||
{
|
||||
#ifdef ANGLES_IN_DEGREES
|
||||
#ifdef USE_DEGREES_INTERNALLY
|
||||
yaw = DEG2RAD(yaw);
|
||||
pitch = DEG2RAD(pitch);
|
||||
roll = DEG2RAD(roll);
|
||||
|
||||
@@ -405,7 +405,7 @@ bool DriveManipulator::calcMovement()
|
||||
|
||||
float dx = _ga_t0->getX()-mx;
|
||||
|
||||
float yaw = dx*0.1f*dt;
|
||||
float yaw = inDegrees(dx*0.1f*dt);
|
||||
|
||||
osg::Matrix mat;
|
||||
mat.makeTrans(-center.x(),-center.y(),-center.z());
|
||||
|
||||
@@ -201,8 +201,8 @@ bool FlightManipulator::calcMovement()
|
||||
osg::Vec3 sv = _camera->getSideVector();
|
||||
osg::Vec3 lv = _camera->getLookVector();
|
||||
|
||||
float pitch = -dy*0.15f*dt;
|
||||
float roll = -dx*0.1f*dt;
|
||||
float pitch = inDegrees(-dy*0.15f*dt);
|
||||
float roll = inDegrees(-dx*0.1f*dt);
|
||||
|
||||
osg::Matrix mat;
|
||||
mat.makeTrans(-center);
|
||||
@@ -211,7 +211,7 @@ bool FlightManipulator::calcMovement()
|
||||
if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED)
|
||||
{
|
||||
float bank = asinf(sv.z());
|
||||
float yaw = (-bank*180.0f/M_PI)*dt;
|
||||
float yaw = inRadians(-bank)*dt;
|
||||
mat *= Matrix::rotate(yaw,0.0f,0.0f,1.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ void TrackballManipulator::trackball(osg::Vec3& axis,float& angle, float p1x, fl
|
||||
*/
|
||||
if (t > 1.0) t = 1.0;
|
||||
if (t < -1.0) t = -1.0;
|
||||
angle = asin(t) * 180.0f/M_PI;
|
||||
angle = inRadians(asin(t));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user