# 3d object gesture rotation

Hello everyone,
I am adding an interactive element to my friends senior thesis in industrial design. He is making a chair/workstation, and he has a good .obj rendering of the image. I want to do some simple threshold motion detection that comes in the openCVExample, which would then rotate the 3d image, just like the objLoaderExample, based on the location of one blob. Seems simple enough.

I have detected a single blob from the camera, identified the center of that blob, drawn a circle around that point, but now I just need the 3d object to rotate according to where that center point is.

First, I have

``````

for (int i = 0; i < contourFinder.nBlobs; i++){
contourFinder.blobs[i].draw(360,540);
//draws a circle around the center of the blob in the color image.
ofCircle(contourFinder.blobs[i].centroid.x, contourFinder.blobs[i].centroid.y, 20);
//now i want to rototate the 3d object
int TheX = contourFinder.blobs[i].centroid.x;
int TheY = contourFinder.blobs[i].centroid.y;
glRotatef(TheY,1,0,0);
glRotatef(TheX,0,1,0);
}

``````

I’m guessing that’s too simple and I can’t get away with doing that. I’ve tried about 10 other things, and nothing seems to work. Either “outside of scope” or the glRotatef doesnt like my int… various errors.

If you’re wondering, in the 3d obj loader example, the object is rotated by grabbing the x and y location of the mouse like this

``````

glRotatef(mousey,1,0,0);
glRotatef(mousex,0,1,0);

``````

so if i can find out how to grab the x,y of the ofCircle, i can apply those numbers to the glRotate, and have a sweet gesture rotation. Here is a screen shot of what I have thus far:
http://farm4.static.flickr.com/3660/340-…-46de-o.png
notice the red circle in the top left area.

Any help is appreciated, and thanks to everyone who has helped me up to this point and doesnt even know it.
Peace,
Matt