Controlling 3D model with mouse

Hi All

Can anyone help me with something, which I think is so obvious I am overlooking it, or perhaps to do with scale.
I wanted to take the 3D model loader example and put a model under mouse control - a dragonfly, over a jpg background.
I cannot get the dragonfly to track the mouse… having tried to use the mousemoved() function to control it. I have tried various variations but what should I do to just get the model to track the mouse. It can stay on the automatic rotation…
Thanks so much…!!
A Newbie

#include "testApp.h"  
GLfloat lightOnePosition[] = {40.0, 40, 100.0, 0.0};  
GLfloat lightOneColor[] = {0.99, 0.99, 0.99, 1.0};  
GLfloat lightTwoPosition[] = {-40.0, 40, 100.0, 0.0};  
GLfloat lightTwoColor[] = {0.99, 0.99, 0.99, 1.0};  
void testApp::setup(){	  
	locatex = ofGetWidth()/2;  
	locatey = ofGetHeight()/2;  
    //some model / light stuff  
    glEnable (GL_DEPTH_TEST);  
    glShadeModel (GL_SMOOTH);  
    /* initialize lighting */  
    glLightfv (GL_LIGHT0, GL_POSITION, lightOnePosition);  
    glLightfv (GL_LIGHT0, GL_DIFFUSE, lightOneColor);  
    glEnable (GL_LIGHT0);  
    glLightfv (GL_LIGHT1, GL_POSITION, lightTwoPosition);  
    glLightfv (GL_LIGHT1, GL_DIFFUSE, lightTwoColor);  
    glEnable (GL_LIGHT1);  
    glEnable (GL_LIGHTING);  
    glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);  
    glEnable (GL_COLOR_MATERIAL);  
    //load the squirrel model - the 3ds and the texture file need to be in the same folder  
    dragonModel.loadModel("dragon/dragonfly_1_blue.3ds", 20);  
    //you can create as many rotations as you want  
    //choose which axis you want it to effect  
    //you can update these rotations later on  
    dragonModel.setRotation(0, 90, 1, 0, 0);  
    dragonModel.setRotation(1, 270, 0, 0, 1);  
    dragonModel.setScale(0.0008, 0.0008, 0.0008);  
    dragonModel.setPosition(locatex, locatey, 50);  
void testApp::update(){  
	//locatex = locatex + mouseX;  
	//locatey = locatey + mouseY;  
	dragonModel.setRotation(1, 270 + ofGetElapsedTimef() * 60, mouseX, mouseY, 100);  
void testApp::draw(){  
	myImage.draw(0, 0, ofGetWidth(), ofGetHeight());  
	ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 20, 40);  
	ofDrawBitmapString("This is an example of a 3DS model controlled by the mouse", 20, 20);  
    //lets tumble the world with the mouse  
        //draw in middle of the screen  
       // glTranslatef(locatex, locatey, 0);  
        //tumble according to mouse  
        ofSetColor(255, 255, 255, 255);  
void testApp::keyPressed  (int key){   
void testApp::keyReleased  (int key){   
void testApp::mouseMoved(int x, int y ){  
	glTranslatef(x, y, 0);  
void testApp::mouseDragged(int x, int y, int button){  
void testApp::mousePressed(int x, int y, int button){  
void testApp::mouseReleased(int x, int y, int button){  


glTranslatef(x, y, 0);  

doesn’t make sense to do in mouseMoved since at the start of draw() we are initializing the current world coordinate system so that 0,0 is the top left, etc. therefore, it’s not really going to effect the drawing on any frames after that. what if instead you did:

dragonModel.setPosition(mouseX, mouseY, 50);

in the mouse event, (or in update?) does that help ?

take care,

Many thanks Zach, now sorted!!

how would i have a 3d model rotate around a specific point?
I would like to pick any vertices on the model and define it as it’s rotation center.

Is that possible?

using the assimp Example

and this code got my almost there:

	//// glEnable(GL_CULL_FACE);  
	ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);  
	//ofRotate(mouseX, 0, 0, 1);  
	ofRotate(mouseY, 0, 1, 0);  
	ofRotate(mouseX, 1, 0, 0);  
	//normScale 126.565, scale 1, 1, 1  
	ofScale(normScale , normScale, normScale);  
	float mx = -mesh.getVertex(vCnt).x;  
	float my = -mesh.getVertex(vCnt).y;  
	float mz = -mesh.getVertex(vCnt).z;