Advertisement Jump to content
Sign in to follow this  
muimui1911

Object follow the mouse movement

This topic is 4881 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
{
placed_models.push_back(model_on_cursor);
model_on_cursor=0;
}

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!