Drawing 'Flight Control' - style paths in iTorque
by Richard Skala · in iTorque 2D · 04/28/2010 (5:10 pm) · 5 replies
For the iPhone project I am working on, I want the user to be able to use his finger and draw a line or scribble on the screen. Is there some tutorial or information on how to do this with iTorque?
I currently am using the 'onMouseDragged' function, and for every call in there, I place a dot at the position passed to the function, and this works when I move my finger slowly. However, when I swipe my finger quickly across the screen, the distance between the points can be large, creating big gaps between the dots. Is 'onMouseDragged' the wrong place to do this? Is it not updated quickly enough per second or something?
This TopMeadow guy is using the mouse to draw with Torque (Windows), so I see that it is at least possible:
http://www.youtube.com/watch?v=KLTfTMsdF5A#t=4m25s
Any help is appreciated.
I currently am using the 'onMouseDragged' function, and for every call in there, I place a dot at the position passed to the function, and this works when I move my finger slowly. However, when I swipe my finger quickly across the screen, the distance between the points can be large, creating big gaps between the dots. Is 'onMouseDragged' the wrong place to do this? Is it not updated quickly enough per second or something?
This TopMeadow guy is using the mouse to draw with Torque (Windows), so I see that it is at least possible:
http://www.youtube.com/watch?v=KLTfTMsdF5A#t=4m25s
Any help is appreciated.
About the author
Founded in 2009, Pixel Vandals Inc. is focused on bringing fun, fresh, and new ideas to the iPhone. www.pixelvandals.com www.pixelvandals.com/vineking
#2
04/28/2010 (9:28 pm)
Thank you for your quick and helpful response (and also thanks for your help with a previous post of mine). Using iTorque, I use C++ almost entirely, so that is not a problem. I've been trying to do as much research as I can, and I think, like you said, I need some sort of curve algorithm. I think what might work here is something called a "Catmull-Rom" spline. Do you think that would work, and do you know of any good resources on them? Information is kind of sparse and all over the place.
#3
As for a good resource: they are pretty simple and the wiki contains the relevant informations :)
Alternatively look into the t2dPath class and add "rendering possibilities" to it as you will need these paths at the end of the day anyway if anything is meant to follow them (they already render in editor at least when selected but you need to expand that to render without selection and in the game)
04/28/2010 (9:58 pm)
I think that would work.As for a good resource: they are pretty simple and the wiki contains the relevant informations :)
Alternatively look into the t2dPath class and add "rendering possibilities" to it as you will need these paths at the end of the day anyway if anything is meant to follow them (they already render in editor at least when selected but you need to expand that to render without selection and in the game)
#4
04/29/2010 (2:38 am)
RSkull, the t2dpath let's you use a CATMULL so there must be some code in there somewhere.
#5
http://www.torquepowered.com/community/forums/viewthread/111713
04/29/2010 (12:28 pm)
I found a related thread about this that I didn't find before:http://www.torquepowered.com/community/forums/viewthread/111713
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
The most natural way of doing it would be using CoreGraphics directly likely and use the path object as that gives you high performance. Once the operation is done you could create a t2d path from the data you captured before.
Alternatively some smart (and pure C++) solution with dynamically expanding paths could work but you might need to experiment with the path settings for curving etc (also check if the path dublication error is still present as that could easily break your neck if it is)
onMouseDragged or the corresponding iPhone function to ensure its "object collision independent" would be the right place to do it.
Just to make sure: you will always get gaps between the point they will never line up. The iphone doesn't sample it that fast that fast moving fingers are detected. You need to create paths or at least lines between them to get continous data. This would even be the case with a direct XCode project and nothing but the point sampling :)
That it works on the desktop does not say much as desktop gpus if they aren't intel burn even 3GS to ashes, not considering the cpu overpower of them.