opengl es - Android Open GL 1.1 View Rotation -


im new development open gl. trying figure out how rotate view can see sides of object on view. similar how google maps rotations. suggestions? current code.

 @override public boolean ontouchevent(motionevent e) {     float x = e.getx();     float y = e.gety();      switch (e.getaction() & motionevent.action_mask) {      case motionevent.action_down:         mode = 0; //safety precaution screen taps vs swiping         mpreviousx = x;//safety precaution screen taps vs swiping         mpreviousy = y;//safety precaution screen taps vs swiping         case motionevent.action_pointer_down:             if(e.getpointercount() == 2) {//two fingers down                 olddist = distance(e);//old distance equals new distance motion event                 mode = 1;             }             break;         case motionevent.action_move:             if (mode == 1) {                 newdist = distance(e);                  if (newdist > olddist) {     // distance increasing                     mrenderer.increasescale(math.abs(olddist - newdist) / 100);                 } else if (newdist < olddist) {   // distance decreasing                     mrenderer.decreasescale(math.abs(olddist - newdist) / 100);                 }                    //matrix.rotatem(m, moffset, a, x, y, z);                  olddist = newdist;             } else if(mode == 0) {                 float dx = x - mpreviousx;                 float dy = y - mpreviousy;                  // reverse direction of rotation above mid-line                 if (y < mview.getheight() / 2) {                     dx = dx * -1;                 }                  // reverse direction of rotation left of mid-line                 if (x > mview.getwidth() / 2) {                     dy = dy * -1;                 }                  mrenderer.xangle += dx * touch_scale_factor;                 mrenderer.yangle += dy * touch_scale_factor;                  x = e.getx();                 y = e.gety();                  float distancex = x - mpreviousx;                 float distancey = y - mpreviousy;                  mrenderer.moveleftright(distancex/100);                 mrenderer.moveupdown(distancey/100);                  mview.requestrender();                 mpreviousx = x;                 mpreviousy = y;             }             break;         case motionevent.action_pointer_up:             mode = 0;             break;         default:             super.ontouchevent(e);     }     return true; } 


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -