MultiTouch android control sample code

Started by Mr_Chaos, August 14, 2014, 02:37:20 PM

Previous topic - Next topic

Mr_Chaos

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

EgonOlsen


Mr_Chaos

Updated with the actual camera movement code from the Activity

aeroxr1

#3
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 ?


EgonOlsen

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.

aeroxr1

#5
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 ..

aeroxr1

#6
This is what I have to do :

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 ? :)

EgonOlsen

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... ???

aeroxr1

#8
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

Mr_Chaos

Quote from: aeroxr1 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

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