Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
I need help, I don't really know how to do this #324473
05/21/10 01:22
05/21/10 01:22
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
Hi everyone, I really appreciate some help, my problem is maybe something easy but I haven't work with this kind of things yet so I don't have too much experience combining 2D with 3D vectors.

My problem is this one, I have a 3D arm which I want to follow the mouse pointer since it has a crosshair bitmap, I was trying to do so but the way I was implementing works just with 3D objects, here's the code attached to the arm model:


vec_set(temp.x, me.x);

vec_set(temp2.x, mouse_pos);

vec_sub(temp.x, temp2.x);

vec_to_angle(me.tilt, temp);


And here's an image of what I want to achieve:






I don't have anything else to add, so thanks for reading and I hope I can find some help soon.

Last edited by Theil; 05/21/10 05:23.
Re: I need help, I don't really know how to do this [Re: Theil] #324482
05/21/10 06:35
05/21/10 06:35
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
hmmm... Maybe vec_for_screen and / or vec_to_screen may help. Check those out in the manual. Good luck.


A8 com / A7 free
Re: I need help, I don't really know how to do this [Re: Rich] #324485
05/21/10 06:57
05/21/10 06:57
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
I was trying something like this:

temp.x = mouse_pos.x;
temp.y = mouse_pos.y;

vec_to_screen(temp,camera);

vec_to_angle(me.tilt, temp);

it almost work but it's moving sideways and not just only its tilt, thanks for the replay.

Re: I need help, I don't really know how to do this [Re: Theil] #324518
05/21/10 13:32
05/21/10 13:32
Joined: Aug 2005
Posts: 238
Caermundh Offline
Member
Caermundh  Offline
Member

Joined: Aug 2005
Posts: 238
I *think* this might work Theil:

temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = me.z;
vec_for_screen(temp,camera);
vec_sub(temp,me.x);
vec_to_angle(me.pan,temp)

Give it a try and let me know if it works for you

Re: I need help, I don't really know how to do this [Re: Caermundh] #324548
05/21/10 17:05
05/21/10 17:05
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
The arm moves up and down, but doesn't follow the mouse pointer, thanks for the replay I think I'm getting close but I think there must be something missing.

Re: I need help, I don't really know how to do this [Re: Theil] #324556
05/21/10 17:55
05/21/10 17:55
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
does there any 3d object exist, where you can point at?
if its so, try it with this code:
Code:
action pointAtMouse()
{
	VECTOR temp;
	
	VECTOR from;
	VECTOR to;
	
	vec_set(from,vector(mouse_pos.x,mouse_pos.y,0));
	vec_set(to,vector(mouse_pos.x,mouse_pos.y,10000));
	
	vec_for_screen(from,camera);
	vec_for_screen(to,camera);
	
	if(c_trace(from,to,IGNORE_PASSENTS))
	{
		vec_set(temp,tar)
	}
	else
	{
		vec_set(temp,to);		
	}
	vec_sub(temp,my.x);
	vec_to_angle(my.pan,temp); 
}




Visit my site: www.masterq32.de
Re: I need help, I don't really know how to do this [Re: MasterQ32] #324563
05/21/10 18:22
05/21/10 18:22
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
No there is not any 3D object besides the arm, the mouse pointer is a simple bitmap I assigned to it, thanks for the help so far but it still doesn't work, it moves when I move the mouse but it doesn't follow the mouse pointer. =/

Re: I need help, I don't really know how to do this [Re: Theil] #324564
05/21/10 18:33
05/21/10 18:33
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
try to calculate the angle with tangens and rotate the panel with this.
Code:
var angle = atan(mouse_pos.y / mouse_pos.y);



Last edited by Richi007; 05/21/10 18:33.

Visit my site: www.masterq32.de
Re: I need help, I don't really know how to do this [Re: MasterQ32] #324569
05/21/10 19:22
05/21/10 19:22
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
I don't know how to do it, and it is not a panel what I'm trying to rotate, it's a 3d entity, sorry if I'm being annoying, I don't get it to work, thanks for the help so far laugh

Re: I need help, I don't really know how to do this [Re: Theil] #324570
05/21/10 19:33
05/21/10 19:33
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
So you're trying a arm face the crosshair (not literally ofc as the crosshair is in 2d space whereas the arm is 3d space) try below one, untested.

Code:
VECTOR* trace_to;
var trace_distance = 500;
function trace_to_crosshair(ENTITY* ent)
{
   VECTOR temp;
   vec_set(temp,nullvector);
   vec_set(trace_to,nullvector);
   while(ent)
   {
 //Replace mouse cursor and trace_distance with your own variables!     
      vec_set(trace_to,vector(mouse_cursor.x,mouse_cursor.y,trace_distance);
      vec_set(temp,trace_to.x); 
      vec_sub(temp,ent.x);
      vec_to_angle(ent.pan,temp);
   wait(1);
   }
return 1;
}



Page 1 of 2 1 2

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