Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/21/26 19:15
Camera always moves upwards?
by clonman. 02/21/26 09:29
Zorro version 3.0 prerelease!
by TipmyPip. 02/20/26 13:22
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Petra, 1 invisible), 6,267 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
mouse angle over an object #426340
07/21/13 16:05
07/21/13 16:05
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I heve the 3D cordinates of the my mouse.

Code:
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 Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Code:
...
  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

M
Malice
Unregistered
Malice
Unregistered
M



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

M
Malice
Unregistered
Malice
Unregistered
M



A simple logic solution is ..
Code:
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;



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1