Hi Guys,
I am playing around with making a basic software driven 3D framework for learning purposes only. I know it will not be very performant.
Hard one to explain, so hit me up with any questions if it isn't clear.
I am manually calculating each point of a triangle, which I am drawing to the screen with lines.
In the code snippet below, zero_x and zero_y are the co-ordinates of the centre of the window. So the positions are between -1 and 1 like DirectX etc...
The triangle points have already been transformed in to 3D space against a World, View, and Projection matrix. np0x & y are the points in screen co-ordinates.
np0x = (wvp[12] * zero_x) + zero_x;
np0y = (wvp[13] * zero_y) + zero_y;
Looping through each of the points to render a triangle with lines is working great (aspect ratio, position, etc.), however depth isn't working. If I set the camera z distance to any number, the triangle always renders the same size on the screen.
I suspect that my calculations require wvp[14] (the z transform coordinate) to be multiplied in there as well to scale the x and y up and down.
I have tried all sorts of combinations with wvp[14] value but am unable to get the triangle to render correctly when I do so.
Any advice on this would be awesome.
Thanks in advance.