Skip to content

Commit

Permalink
fixed bug with Leap Motion int abs prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
MapTube committed Sep 30, 2014
1 parent 80d46f0 commit 30cd3e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions GeoGL/LeapController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ void LeapController::EllipsoidDistance(Ellipsoid& e,const float LeapY)
//code copied from ellipsoid orbit controller
const float scrollSpeed = 0.01f;
const double nullzone=0.1; //null zone in the middle where zoom is clamped to zero (in raw normalised leap coordinates)
if (abs(LeapY)<nullzone) return;
if (glm::abs(LeapY)<nullzone) return;

//complex version where it zooms in a percentage of the distance from the eye to the centre
glm::dvec3 vCameraPos = con_camera->GetCameraPos();
glm::dmat4 mCamera = con_camera->GetCameraMatrix();
double h = e.heightAboveSurfaceAtPoint(vCameraPos);
double delta = -h*LeapY*scrollSpeed; //where speed is the percentage i.e. 1/100=0.01
//std::cout<<"delta="<<delta<<std::endl;
glm::dmat4 mNewCamera = glm::translate(mCamera,glm::dvec3(0,0,delta));
con_camera->SetCameraMatrix(mNewCamera);
}
Expand Down Expand Up @@ -128,14 +129,14 @@ void LeapController::EllipsoidSpin(Ellipsoid& e, const float LeapX, const float
//fudge the speed delta
double delta = speed*h;
if (delta>0.01) delta=0.01;
std::cout<<"delta: "<<delta<<std::endl;
//std::cout<<"delta: "<<delta<<std::endl;

//I've added the minus to both angles so that visually we're moving the sphere with our hand, which seems a lot more intuitive
//calculate speed and handle the null zone in the middle
double ax=0,ay=0;
if (abs(LeapX)>=nullzone)
if (glm::abs(LeapX)>=nullzone)
ax=-delta*LeapX;
if (abs(LeapZ)>=nullzone)
if (glm::abs(LeapZ)>=nullzone)
ay=-delta*LeapZ;

//now on to the rotations
Expand Down
4 changes: 2 additions & 2 deletions GeoGL/tiledearth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ TiledEarthNode* TiledEarth::MakePatch(int WidthSegments, int HeightSegments, dou
std::string MakeTextureTileString(int Z,int X,int Y,const std::string& base)
{
std::stringstream ss;
ss<<"../data/BlueMarble/land_ocean_ice_QUAD_"<<Z<<"_"<<X<<"_"<<Y<<".jpg";
//ss<<"../data/BlueMarble/bluemarble_jan04/world_topo_QUAD_"<<Z<<"_"<<X<<"_"<<Y<<".jpg";
//ss<<"../data/BlueMarble/land_ocean_ice_QUAD_"<<Z<<"_"<<X<<"_"<<Y<<".jpg";
ss<<"../data/BlueMarble/bluemarble_jan04/world_topo_QUAD_"<<Z<<"_"<<X<<"_"<<Y<<".jpg";
return ss.str();
}

Expand Down

0 comments on commit 30cd3e1

Please sign in to comment.