I am new to OF and can’t seem to understand the hang of this. I created a box shape but am not sure how to get it to rotate on the origin. I basically just want the mouse to be able to drag my square clockwise. Where are any tutorials / sources that may be able to help me?


Hi! Welcome to the forum :slight_smile:

Could you maybe show a few lines of code and describe how it is failing to work as you want?

The key to understand transformations is to realize that they are always applied to the coordinate system and not to the object you are drawing. In order to draw a rotated (say) square you have first to ofRotate the CS then draw your square as usual. The same goes for translations and scaling.

To capture the mouse you have to store in a class variable the x (or y) position in the mousedown handler, then the same in mousemoved. When drawing compute the difference among the two and use it to rotate your object. There are other ways of course but this one is the simplest.

If you need to apply many transformations ofPushMatrix and ofPopMatrix come handy.