Sign in to follow this  

Object follow the mouse movement

Recommended Posts

Hello everyone, I am building a program that can import 3dMax(.3ds) files into the virtual environment. 1. I like to ask how can I keep the object attached to the mouse after I load the object everytime and move around? the effect is when I left click the mouse, then the object will be left on the place where i click the mouse. Millions of thanks

Share this post

Link to post
Share on other sites
Ok let me see is I understand what you are asking.

You want to do three things:
1) Have the model stick to the cursor when you load it up
2) Have the model detach from the cursor when you click it
3) Have the model stay where you detached it and continue to be displayed.

Ok you need a pointer like so, to hold the model on the cursor (adjust it as needed)

Mode* model_on_cursor;

Then you need a container to store models that have been placed:

vector<Mode*> placed_models;

Next you need a place in your code where you check for input, and then store it in the container:

if(Input::left) //meaning that the left mouse button is down

That should cover everything. Just think your way through your problem and you will have no problem!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this