BAZINGA! It still does not have a reset for a second animation. However, I did test every quadrant by moving ship_02 around the screen, and also with both models on and off the axis lines in case division by zero or weird trig errors at transition points cropped up. The atan2(); is supposed to deal with this stuff automatically behind the scenes, but as the old Russian proverb goes "???????, ?? ????????."
The ship stuff is from another post I'm working on(post # 64443), but it should work for you once the details are renamed by you. Here it is, in this case, the first ship rotates towards, and points at the second ship: In your case, you'd want to make ship_02_POSITION the spot where the touch occurred. You may have to calibrate the touchPos variable to OpenGL's centered coordinates. I assume Android uses either top left or bottom left for the 0, 0 point of the touch screen
//========================================================================================================
GLfloat ship_01_POSITION[] = {5.0, 7.0, 0.0};
GLfloat ship_01_ROTATION[] = {0.0, 0.0, 0.0, 1.0};
GLfloat ship_02_POSITION[] = {0.0, -5.0, 0.0};
GLfloat ship_02_ROTATION[] = {0.0, 0.0, 0.0, 1.0};
GLfloat blendedRotation = 0.0;
GLfloat startRotation = 0.0;
GLfloat targetRotation = 180.0;
GLfloat sliderTime = 0.0;
GLfloat incrementTime = 0.0;
GLfloat distanceBetweenModels[] = {0.0, 0.0, 0.0};
//=========================================================================================================
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//=========================================================================================================
void Render(void)
{
//============================= - The next seven lines of code seems to have round 1 taken care of.
incrementTime += 0.001;
//--------------------------------
distanceBetweenModels[1] = ship_02_POSITION[1] - ship_01_POSITION[1]; // Y2 - Y1 <--distance formula...high school math? check!
distanceBetweenModels[0] = ship_02_POSITION[0] - ship_01_POSITION[0]; // X2 - X1
//------------------------------------------------------------------------------------------------------
targetRotation = atan2(distanceBetweenModels[0], distanceBetweenModels[1])* 180 / 3.14159; //<- atan2 function... high school math? ...check!
blendedRotation = (startRotation * (1.0 - sliderTime)) + (targetRotation * sliderTime); //<- mix()... high school math? sure why not... check!
if(sliderTime <= 1.0) // This will prevent the rotation from over-shooting
{
sliderTime += incrementTime;
}
//=====================================================================================================================
glPushMatrix();
DrawShip(ship_01_POSITION_X, ship_01_POSITION_Y, ship_01_POSITION_Z, ship_01_ROTATION, ship_01_COLOR);
glPopMatrix();
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
glPushMatrix();
DrawShip(ship_02_POSITION_X, ship_02_POSITION_Y, ship_02_POSITION_Z, ship_02_ROTATION, ship_02_COLOR);
glPopMatrix();
//=========================================================================================
}
//===========================================================================================================
That's straight forward enough to keep me from having an anxiety attack every time I think of it. I wish i could say the same for collision handling.
Once you've gotten this far we can proceed to updating it so that every touch resets the whole she-bang for another round.