Simple Track Ball With Inertia (Composition by dust)

Author: dust
License: MIT
Date: 2010.03.26
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

here is a simple trackball you can use with exposed orientation values. now like the title says this is just a simple dirty implementation of a trackball. there is a simple patch that is basically a few math expressions nothing more than some 2nd grade math as in addition multiplication and division maybe division is 3rd grade can't remember now. so the simple patch should run on leopard as its just a few equations.

there is also a snow leopard patch that acts more like the stock trackball with inertia and friction etc..... like i said again this is a simple trackball meaning i'm not using euler angles and quaternions or z rotation. we are not flying space ships here just rotating things so sometimes there is no need for pitch roll and yaw from xy coordinates.

if you want that level of complexity or another degree of freedom or maybe more of a stock trackball feeling with exposed orientations just add the inertia from the simple trackball with inertia example presented here to my quaternion trackball located in this repository as it is a direct implementation of Apples trackball.h

PreviewAttachmentSize
simpleTrackBall.qtz12.18 KB
simpleTrackBallInertia.qtz46.18 KB

usefuldesign.au's picture
Re: Simple Track Ball With Inertia (Composition by dust)

needs units2pixy patch. no go on leopard.

dust's picture
Re: Simple Track Ball With Inertia (Composition by dust)

cool thanks for bringing that to my attention i have uploaded a fix to the simple trackball and to the inertia SL trackball. i suppose you haven't noticed this seeing your using leopard but the stock units to pixels converter supplied by apple says units to pixels but doesn't imply in which coordinate so well i just made up my own macro to save space. no big deal i just dropped the macro in the root file and it should be good to go. keep me informed as i don't have leopard but good looking out i noticed i swapped the x and y coordinates by accident. well after the conversion to rotation values your supposed to swap values meaning x pos becomes y rot etc..

so thanks i may not be real good at commenting stuff and what not but defiantly do not like to post things out of order if i can help (particularly simple things). defiantly didn't do that on purpose there is nothing more than i hate than people who open source code that doesn't run without considerable effort. i really am thinking people do that on purpose.

funny thing is i couldn't really notice the disparity between screen space coordinate conversions with the inertia going. but good looking out thanks again

toneburst's picture
Re: Simple Track Ball With Inertia (Composition by dust)

Cool. The only issue for me is that, unlike the Apple Trackball, this one jumps when you click in the Viewer, rather than the rotation being relative.

Good work, anyway. I'm going to use it to rotate lights around a model, I think.

a|x

dust's picture
Re: Simple Track Ball With Inertia (Composition by dust)

yeah i'm noticing that now that you mention it. it seems if you click in the exact middle there isn't a jump. hmm i wonder how i can fix that. maybe setting xy to 0,0 for the initial grab and smoothly interpolate to the actual position the mouse is in like envelope or something then do that for all subsequent drags but store the last point of contact as a reference.

not sure if that would work but seeing that there is a max of 2 units to be moved ie the saved point is x=-1 but the new point is x=1 then i got to smoothly go 2 units without people noticing a jump. i will it might make it more jumpy not sure.

so yeah even though the jump is slight i could see how in a performance setting that would be an issue but yeah to rotate light around and what not this should do the trick.