Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AemStones, AndrewAMD, gamers, Kingware), 1,679 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 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 | chip programmers | 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