PDA

View Full Version : Strached Model / Software Renderer



Key-Real
16-03-2022, 02:14 PM
Hi,
I'm writing a software renderer.
I can not understand why my box is streched when I move it.
Projection issue?


function v3dMakeProjection(v:v3dVector):v3dVector;
var outV:v3dVector;
centerX,centerY:longint;
fNear,fFar,fFov,fAspectRatio,fFovRad:single;
begin


fNear := 0.01;
fFar := 1000.0;
fFov := 90.0;
fAspectRatio := vScreen.height / vScreen.width;
fFovRad := 1.0 / tan(fFov * 0.5 / 180.0 * 3.14159);

outV:=v;

centerX:=vscreen.width div 2;
centerY:=vscreen.height div 2;


outV.x:=fAspectRatio*fFovRad*outV.x / outV.z * (vScreen.width / 2) + centerX;
outV.y:=-fFovRad * outV.y / outV.z * (vScreen.height / 2) + centerY;
// outV.z:=( (fFar/(fFar-fNear)) - ((fFar*fNear) / (fFar-fNear)) ) * outV.z;

v3dMakeProjection:=outV;
end;


What I'm doing wrong?


http://www.sistavip.com/pub/forum.pas




to Compile you need the GFX Framework "vipgfx4"
https://sourceforge.net/projects/vipgfx/files