John Xie
2008-03-18 21:36:00 UTC
Hi all,
I am using directx 9 sample frame work as the start point of my 3D project.
In the source code to convert screen point to vector function as following:
public Vector3 ScreenToVector(float screenPointX, float screenPointY)
{
float x = -(screenPointX - width / 2.0f) / (radius * width/2.0f);
float y = (screenPointY - height / 2.0f) / (radius * height/2.0f);
float z = 0.0f;
float mag = (x*x) + (y*y);
if (mag > 1.0f)
{
float scale = 1.0f / (float)Math.Sqrt(mag);
x *= scale;
y *= scale;
}
else
z = (float)Math.Sqrt(1.0f - mag);
return new Vector3(x,y,z)
}
My question is why there is negative x not y?
According the link
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48, y should be
negative and x is positive.
Any explanation?
Thanks
I am using directx 9 sample frame work as the start point of my 3D project.
In the source code to convert screen point to vector function as following:
public Vector3 ScreenToVector(float screenPointX, float screenPointY)
{
float x = -(screenPointX - width / 2.0f) / (radius * width/2.0f);
float y = (screenPointY - height / 2.0f) / (radius * height/2.0f);
float z = 0.0f;
float mag = (x*x) + (y*y);
if (mag > 1.0f)
{
float scale = 1.0f / (float)Math.Sqrt(mag);
x *= scale;
y *= scale;
}
else
z = (float)Math.Sqrt(1.0f - mag);
return new Vector3(x,y,z)
}
My question is why there is negative x not y?
According the link
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48, y should be
negative and x is positive.
Any explanation?
Thanks