Author Topic: MultiTouch android control sample code  (Read 4514 times)

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
MultiTouch android control sample code
« on: August 14, 2014, 02:37:20 pm »
I've finally gotten the source code for a simple MotionEvent handler posted.

I'll try to make some code to show it off later.

http://www.jpct.net/wiki/index.php/MultiTouch_camera_controls

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: MultiTouch android control sample code
« Reply #1 on: August 19, 2014, 10:49:33 am »
Thanks for sharing.

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Re: MultiTouch android control sample code
« Reply #2 on: September 10, 2014, 09:01:15 pm »
Updated with the actual camera movement code from the Activity

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: MultiTouch android control sample code
« Reply #3 on: September 22, 2014, 06:51:46 pm »
Hi.
I'm using this jpct camera system but I have a problem : when I rotate the display from portrait to landscape the camera is too much zoomed. Then I use android.view.Display.getRotation() to get the orientation of the device, but which are the values to change inside the MovementHandler for a correct camera position ?

I suppose that I have to set FOV, right ?

« Last Edit: September 22, 2014, 07:02:46 pm by aeroxr1 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: MultiTouch android control sample code
« Reply #4 on: September 22, 2014, 08:28:05 pm »
The fov that you are setting is the horizontal fov, the vertical fov adjusts accordingly to avoid image distortion. This will of course change the size of the objects. You can adjust the fov after the rotation to compensate for this effect if you want to.

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: MultiTouch android control sample code
« Reply #5 on: September 22, 2014, 08:52:57 pm »
On my scene I have an animated3d object and I would to set my camera so my object is all in the display .
Now the situation is :



How can I adapt the horizontal fov to obtain a correctly object view in landscape ?

Which are the other options ? Scale Object and moveout the camera ? But I would adapt the camera depending from the display resolution ..
« Last Edit: September 22, 2014, 09:31:51 pm by aeroxr1 »

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: MultiTouch android control sample code
« Reply #6 on: September 23, 2014, 10:36:00 am »
This is what I have to do :

Code: [Select]
cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance

 but in Mr_Chaos code I don't find something like that.. And I don't know how have to do to merge this math function with Mr_Chaos's code..

Mr_chaos's can you help me ? :)
« Last Edit: September 23, 2014, 11:27:41 am by aeroxr1 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: MultiTouch android control sample code
« Reply #7 on: September 23, 2014, 01:58:31 pm »
I'm not sure what exactly you are asking for...you know that you have to adjust the fov, you have some code that does this and you want to integrate it into...what exactly? And why doesn't it work? If this is all about moving the camera away from the model, then why just not do it? If it's about adjusting the fov, then why just not do it? I'm not sure what the actual problem is... ???

Offline aeroxr1

  • int
  • **
  • Posts: 82
    • View Profile
Re: MultiTouch android control sample code
« Reply #8 on: September 23, 2014, 03:19:47 pm »
Because I have used Mr_Chaos's code and it doesn't auto-adjust the fov and distance when the smartphone rotate from portrait to landscape ;)
But sadly I can't to edit the Mr_chaos's code because I can't see where he sets the camera distance ..
But I want to use his code  because is wonderfull ;) infact it handles the android multitouch , pinch-to-zoom and camera's rotation !

It's not easy for me to edit the code's of someonelse

edit : maybe I understand where I have to put the new code.. :D
« Last Edit: September 24, 2014, 12:40:56 am by aeroxr1 »

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Re: MultiTouch android control sample code
« Reply #9 on: September 24, 2014, 10:07:02 pm »
Because I have used Mr_Chaos's code and it doesn't auto-adjust the fov and distance when the smartphone rotate from portrait to landscape ;)
But sadly I can't to edit the Mr_chaos's code because I can't see where he sets the camera distance ..
But I want to use his code  because is wonderfull ;) infact it handles the android multitouch , pinch-to-zoom and camera's rotation !

It's not easy for me to edit the code's of someonelse

edit : maybe I understand where I have to put the new code.. :D

The MovementHandler on handles movement, rotating the display you need to handle youself.