|
mouse angle over an object
#426340
07/21/13 16:05
07/21/13 16:05
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
I heve the 3D cordinates of the my mouse.
vec_set(mouse_pos,mouse_cursor);
target_from.x = mouse_pos.x;
target_from.y = mouse_pos.y;
target_from.z = 0;
vec_for_screen (target_from, camera);
target_to.x = mouse_pos.x;
target_to.y = mouse_pos.y;
target_to.z = mouse_range;
vec_for_screen (target_to, camera);
c_trace (target_from.x, target_to.x, IGNORE_ME | IGNORE_YOU | IGNORE_PASSENTS | IGNORE_MODELS | IGNORE_PASSABLE | USE_BOX); //vc_set (my.x, target.x); // and place the red target model to the proper spot on the terrain
vec_set(TARGET,target.x);
But now, I was wondering the angle of my mouse over an object. I tried many ways but I am not succeeding! Please could someone provide me a solution?
Last edited by NeoNeper; 07/21/13 16:06.
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: mouse angle over an object
[Re: NeoNeper]
#426342
07/21/13 16:19
07/21/13 16:19
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
...
vec_set(tmp1,axys.x); //axys is the object
vec_sub(tmp1,TARGET); //TARGET is mouse position 3D
vec_to_angle(tmp2.pan,tmp1);
draw_text(_chr(str_for_num(NULL,tmp2.pan)),100,100,_vec(255,0,0));
in this example I made, I get close to getting! The problem is that he comes back and starts 180 sample: 1..2..160..180 | -179...-169...-2
Last edited by NeoNeper; 07/21/13 16:22.
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: mouse angle over an object
[Re: NeoNeper]
#426348
07/21/13 17:07
07/21/13 17:07
|
Malice
Unregistered
|
Malice
Unregistered
|
My last post was wrong.. Try looking at the var trig functions there maybe something you can do with sin and cos but my math there is bad.. And if there isn't a simple way to shift this back to 0-360* range you might ask the developer for a function, but I am sure this can be done with simple math.
Last edited by Malice; 07/21/13 17:09.
|
|
|
Re: mouse angle over an object
[Re: ]
#426351
07/21/13 17:47
07/21/13 17:47
|
Malice
Unregistered
|
Malice
Unregistered
|
A simple logic solution is ..
vec_to_ang(tmp2.pan,tmp1);
if(sign(tmp2.pan) < 0)
tmp2.pan +=360;
if(sign(tmp2.tilt) < 0)
tmp2.tilt += 360;
if(sign(tmp2.roll) < 0 )
tmp2.roll += 360;
|
|
|
|