Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualShadowMan777

Posted 21 October 2012 - 01:07 AM

Hello. I am having issues with my coordinate system for my software renderer. Here is a picture of the issue.

http://imgbin.org/in...e=image&id=9955

This is a plan square with vertices defined as
v -0.5 -0.5 -1.5
v -0.5 0.5 0.0
v 0.5 0.5 0.0
v 0.5 -0.5 0.0


When I move the Z of the bottom left point into the negative z, by -1.5 this is what happens.

http://imgbin.org/in...e=image&id=9956

If I move the bottom left point in the +1.5 z direction, this happens.

http://imgbin.org/in...e=image&id=9957

Another interesting thing is that I have to make the UpVector (0,-1,0) to make the points in the positive Y be drawn above the origin.

Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.

#4ShadowMan777

Posted 21 October 2012 - 12:41 AM

Hello. I am having issues with my coordinate system for my software renderer. Here is a picture of the issue.

http://imgbin.org/in...e=image&id=9955

This is a plan square with vertices defined as
v -0.5 -0.5 -1.5
v -0.5 0.5 0.0
v 0.5 0.5 0.0
v 0.5 -0.5 0.0


When I move the Z of the bottom left point into the negative z, by -1.5 this is what happens.

http://imgbin.org/in...e=image&id=9956

If I move the bottom left point in the +1.5 z direction, this happens.

http://imgbin.org/index.php?page=image&id=9957


Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.

#3ShadowMan777

Posted 21 October 2012 - 12:40 AM

Hello. I am having issues with my coordinate system. Here is a picture of the issue.

http://imgbin.org/index.php?page=image&id=9955

This is a plan square with vertices defined as
v -0.5 -0.5 -1.5
v -0.5 0.5 0.0
v 0.5 0.5 0.0
v 0.5 -0.5 0.0


When I move the Z of the bottom left point into the negative z, by -1.5 this is what happens.

http://imgbin.org/in...e=image&id=9956

Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.

#2ShadowMan777

Posted 21 October 2012 - 12:39 AM

Hello. I am having issues with my coordinate system. Here is a picture of the issue.

http://imgbin.org/index.php?page=image&id=9955

This is a plan square with vertices defined as
v -0.5 -0.5 -1.5
v -0.5 0.5 0.0
v 0.5 0.5 0.0
v 0.5 -0.5 0.0


When I move the Z of the bottom left point into the negative z, by -1.5 this is what happens.

http://imgbin.org/index.php?page=image&id=9956

Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.

#1ShadowMan777

Posted 20 October 2012 - 07:44 PM

Hello. I am having issues with my coordinate system. Here is a picture of the issue.

http://imgbin.org/index.php?page=image&id=9954

The top right point is the origin at (0,0). The bottom left is (1,1), and the middle point is (.5,.5). For some reason everything is inverted and I cannot seem to figure out why and don't get where to look. Here are my matrices.


double[][] projection =
{
{ 1, 0, 0,0},
{ 0, 1, 0,0},
{ 0, 0, 0,0},
{ 0, 0, 1/focallength, 1}
};
PROJECTION = new Matrix(projection);

//This is the position of the focal point
double[][] camdata =
{
{ 1, 0, 0, -camx},
{ 0, 1, 0, -camxy},
{ 0, 0, 1, -camxz},
{ 0, 0, 0, 1}
};

//set position of camera
VRP = new Matrix(camdata);

//the view plane normal
VPN=new double[] {VPNx,VPNy,VPNz};

//up vector
UpVector=new double[] {VUPx,VUPy,VUPz};

I then calculate a camera matrix u,v,n, I have confirmed these to be 100% correct

double[][] cammat=
{
{ u[0], u[1], u[2],0},
{ v[0], v[1], v[2],0},
{ n[0], n[1], n[2],0},
{ 0, 0, 0, 1}
};
R = new Matrix(cammat);

Mcam = PROJECTION.times®.times(VRP);

finally, the viewport matrix

//this is the min and max size of the viewport, so -256 -256 256 256
double nx= maxx-minx;
double ny=maxy-miny;

double[][] mvp =
{
{ nx/2, 0,0 ,(nx-1)/2},
{ 0, ny/2,0,(ny-1)/2},
{ 0, 0, 1, 0},
{ 0, 0, 0, 1}
};


MVP = new Matrix(mvp);


M = MVP.times(Mcam);

I then multiply vertices by M to get the x,y screen coordinates. Any ideas? I am just lost. Thanks a lot for looking over all this.

PARTNERS