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
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,253 guests, and 5 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
Trace from mouse pointer? #186559
03/01/08 15:57
03/01/08 15:57
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
How do I send a raycast from the mouse pointer position? Say for exmaple that I want to have a 3D ball at the position of where the mouse pointer "hits" the 3D world. How would I do that? I know there's c_trace, and Im guessing thats part of the answer. But the problem Im having is how youre supposed to translate the mouse's x, y coordinates in 2D space to a position/angle in 3D space from where the c_trace is supposed to occur.

Help?

EDIT:
Managed to Solve it now. Solution was to use cameras position for from vector, and vec_for_screen as to vector (i placed it 1000 units away).

So, for example:
c_trace(camera.x, vec_for_screen(vector(mouse_cursor.x, mouse_cursor.y, 1000), camera), IGNORE_ME);
vec_set(me.x, target);


Last edited by Kenchu; 03/01/08 18:10.
Re: Trace from mouse pointer? [Re: Kenchu] #186560
03/01/08 16:10
03/01/08 16:10
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
vec_for_screen/vec_to_screen

Re: Trace from mouse pointer? [Re: Joey] #186561
03/01/08 16:23
03/01/08 16:23
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Wow great! Thanks.

Re: Trace from mouse pointer? [Re: Kenchu] #186562
03/01/08 17:02
03/01/08 17:02
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Hm.. But this can just give me the from vector in c_trace. How do I get a to vector? Again, what I want to do is to put something where mouse pointer hits 3d-world. Imagine that I wanna put a laser crosshair dot where mouse pointer is. So if it hits far away, then itll be very small, and if close itll be big. I dont see how to accomplish that with vec_for_screen since it needs you to tell it where to put the entity in z.

Also wanna point out that it isnt a 1st person view..

Edited main post with pic.

EDIT:
Hm, maybe you could take camera position and position of placed entity (vec_for_screen), and then use c_trace to "draw" a line between them, but that goes beyond the placed entity?

EDIT:
Managed to Solve it now. Solution was to use cameras position for from vector, and vec_for_screen as to vector (i placed it 1000 units away).


Last edited by Kenchu; 03/01/08 18:05.
Re: Trace from mouse pointer? [Re: Kenchu] #186563
03/02/08 13:41
03/02/08 13:41
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
correct, glad you solved it by yourself.


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