[gameprogrammer] Re: issues with Calculating texture coordinates
- From: Scott Harper <lareon@xxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Thu, 1 Jun 2006 01:47:27 -0600
Perhaps a description of the effect your are striving for might help.
In any case, (and I can't be sure without knowing better your goal)
it sounds to me like you are trying too hard with this whole
thing... If you are trying to map a texture onto screen coordinates,
then you merely find how far across the screen the vertex is, and
figure the ratio, and that's basically (assuming you don't have any
blank space around the texture area) your texture coordinate.
Now, if you're trying to determine the texture coordinates for, say,
a sphere or a cylinder, then I'm afraid I cannot help you. That's
something I have yet to investigate; though it seems to me you would
not need to get any information about the view-space for calculating
texture coordinates on a regular surface... So perhaps I'm very
confused about your purposes.
If nothing else, we can get this thread kick-started so you can get
as much help as you need. ^_^
--Scott
On May 31, 2006, at 10:41 PM, Gautam Narain wrote:
Hi,
I am trying to figure out how to calculate texture coordinates and
was looking into some google sites. I also went through Bob's
Texture mapping information in gameprogrammer.org page and the
PCGPE article. However I still have some doubts :-
Firstly it says to have view space coordinates - I am getting the
windows screen coordinates
using the gluProject function OpenGL. Then it says to calculate the
P, M, N vectors(i.e. the vertex in the texture space) and then to
calculate the 9 magic numbers.
From what I read from the 2 articles - if I have 3 vectors v1, v2
and v3 then
P = v1 ;
M = v2 - P;
N = P - v3;
Now after I calculate the 9 magic numbers and then I calculate the
fx and fy(framebuffer vectors) which is the screen space or view
space vector v1 -> v1.x / v1.z and v1.y / v1.z.
Using these 9 magic numbers and the frame buffer vector we
calculate the values of U and V right and that is the index into
the texture to use ?
However this does not seem to work. I have a window coordinate as
<320.000000, 240.000000, 0.900901> so if I divide by 0.9 it will
give me a value around 355 and in turn the U and V will be a large
value.
Is my understanding of view space correct in assuming that its
screen coordinates or window coordinates ? And if so then what
exactly am I missing.
Also lastly to calculate the UV for each vertex for a triangle the
magic numbers needs to be computed once only right and the
different fx and fy values give the different UV coordinates ?
Thanks
Gautam
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] issues with Calculating texture coordinates
- From: Gautam Narain
Other related posts:
- » [gameprogrammer] issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
- » [gameprogrammer] Re: issues with Calculating texture coordinates
Hi,
I am trying to figure out how to calculate texture coordinates and was looking into some google sites. I also went through Bob's Texture mapping information in gameprogrammer.org page and the PCGPE article. However I still have some doubts :-
Firstly it says to have view space coordinates - I am getting the windows screen coordinates
using the gluProject function OpenGL. Then it says to calculate the P, M, N vectors(i.e. the vertex in the texture space) and then to calculate the 9 magic numbers.
From what I read from the 2 articles - if I have 3 vectors v1, v2 and v3 then
P = v1 ; M = v2 - P; N = P - v3;
Now after I calculate the 9 magic numbers and then I calculate the fx and fy(framebuffer vectors) which is the screen space or view space vector v1 -> v1.x / v1.z and v1.y / v1.z.
Using these 9 magic numbers and the frame buffer vector we calculate the values of U and V right and that is the index into the texture to use ?
However this does not seem to work. I have a window coordinate as <320.000000, 240.000000, 0.900901> so if I divide by 0.9 it will give me a value around 355 and in turn the U and V will be a large value.
Is my understanding of view space correct in assuming that its screen coordinates or window coordinates ? And if so then what exactly am I missing.
Also lastly to calculate the UV for each vertex for a triangle the magic numbers needs to be computed once only right and the different fx and fy values give the different UV coordinates ?
Thanks Gautam
- [gameprogrammer] issues with Calculating texture coordinates
- From: Gautam Narain