Podracer / papervision3d

Automatically exported from code.google.com/p/papervision3d
0 stars 1 forks source link

Camera3D.createPerspectiveMatrix() seems not correct #222

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In PV3D, projected Z is clipped in the range [0, 1]
but the matrix created by createPerspectiveMatrix transforms [near, far] to
[-1, 1].

/org/papervision3d/cameras/Camera3D.as
------------------------------------------------------------------
return new Matrix3D( [
    f/aspect, 0, 0, 0,
    0, f, 0, 0,
    0, 0, -((near+far)/(near-far)), (2*far*near)/(near-far),
    0, 0, 1, 0 
] );

By this, polygons close to the near-plane disappear.
(Not noticeable because transformed z is not linear)

I guess

    0, 0, -(far/(near-far)), (near*far)/(near-far),

would be correct.

Original issue reported on code.google.com by katsuomi...@gmail.com on 25 Aug 2009 at 4:03