XY coords of the pixel the player is looking at

Grab your favourite IDE and tinker with the innards of game engines

XY coords of the pixel the player is looking at

Postby SM Sith Lord on Tue Jun 18, 2013 3:09 pm

I have a procedural texture placed on a prop and I want to get the X/Y coordinates of the pixel (in texture space) that the player is looking at. The attached diagram illustrates this.

I can see a lot of things that could potentially make this impossible, but lack the experience to know for sure without spending hours searching code & web.

Does anybody have suggestions on how I could accomplish this? Or alternatively, anybody know if this is impossible? :D
Attachments
texturecords.gif
(16.27 KiB) Not downloaded yet
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: XY coords of the pixel the player is looking at

Postby Gary on Wed Jun 19, 2013 3:37 am

Can't use a VGUI? I assume that can do something similar since you can use them as touch screens.
https://developer.valvesoftware.com/wik ... n_Creation
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: XY coords of the pixel the player is looking at

Postby SM Sith Lord on Fri Jun 21, 2013 2:00 pm

I'm not sure how to get the XY coordinates of the pixel the player is looking at even if its a VGUI surface rendered on the model.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: XY coords of the pixel the player is looking at

Postby Sandern on Fri Jun 21, 2013 7:17 pm

SM Sith Lord wrote:I'm not sure how to get the XY coordinates of the pixel the player is looking at even if its a VGUI surface rendered on the model.

What information are you lacking for calculating the XY coordinates? You should be able to calculate the XY coord as long as you know the 3d point the player is looking at (a simple trace forward or alternatively look at the code of C_VGuiScreen::ClientThink), the four coordinates of the corners of your screen and the resolution of your vgui render texture.
Sandern
Regular
Regular
 
Joined: Thu Jun 30, 2005 1:08 pm
Location: Netherlands

Re: XY coords of the pixel the player is looking at

Postby SM Sith Lord on Sat Jun 22, 2013 8:21 pm

Well, I'm not currently using a VGUI surface for the texture. Its a procedural texture that is skinned onto a prop.

However, I looked at the C_VGuiScreen::ClientThink function and it looks like it does exactly what I'm trying to do.

Where are these VGUI surfaces used in-game? It'd love to play around with one to see if it is behaving as I expect them to. My big concern is that they have to be drawn as flat planes as opposed to skinned onto props.

Thanks for the lead Sandern, I will be learning more about C_VGuiScreen class very soon.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: XY coords of the pixel the player is looking at

Postby SM Sith Lord on Sat Jun 22, 2013 8:27 pm

Basically the function will be given the player, a prop, and the name of a texture used on the prop that I want to find out where on it the player is looking.

The texture might span across multiple faces or might not be present on the prop at all.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Return to Programming

Who is online

Users browsing this forum: No registered users