Game Development Community

Some vector stuff

by ev · in Technical Issues · 06/18/2004 (11:40 am) · 2 replies

Alright, hopefully some math guru's out there can help me out. im not really a noob with vector math, but this one is beyond me.

im working on a little level editor of my own with a different engine. the question comes when trying to click and drag models and things around. you know how in the torque editor, you can select a model, and the x, y, and z arrow things come up, and you can drag the model around. i got it in my editor so that you can select entities, and properly tell when something is trying to be dragged. i just dont know what type of mathematical algorithm to implement in order to make the 3d object slide smoothly in the 3d world.

what you know:
models position, models rotation, models scale, mouse's position, mouses down position, mouses delta, etc.. basically anything.

just need help with the algorithm. can anyone please shed some light?

thanks :)

#1
06/18/2004 (12:16 pm)
If your editor views the world in axis-aligned windows, then you can simply add the mouse deltas to the model's position.
As an example, if you have a top down view, then add the mouse delta x to the model's x position, and the mouse's y delta to the model's z position. For a front-on view, the mouse delta x would be mapped to the model's x again, but the mouse y would correspond to the model's y position this time.

Unfortunately, if you have a 'free' 3D view, it isn't so easy. But I'm sure someone else will have the knowledge required. I would asume that you would have to rotate the mouse delta x and y into camera space, but I couldn't give you a definite answer.
#2
06/18/2004 (4:43 pm)
Yes, unfortunately the camera is in a perspective mode so im afraid the math will get a little more complicated than that. thank you though :)