1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
public function computePlanes( nAspect:Number, fNear:Number, fFar:Number, nFov:Number ):Void
{
var yNear:Number = (Math.tan (nFov / 2 * 0.017453292519943295769236907684886)) * fNear;
var xNear:Number = yNear * nAspect;
var yFar:Number = yNear * fFar / fNear;
var xFar:Number = xNear * fFar / fNear;
//fNear = -fNear;
//fFar = -fFar;
var p:Array = aVertex;
p[0] = new Vector(xNear, yNear, fNear); // Near, right, top
p[1] = new Vector(xNear, -yNear, fNear); // Near, right, bottom
p[2] = new Vector(-xNear, -yNear, fNear); // Near, left, bottom
p[3] = new Vector(-xNear, yNear, fNear); // Near, left, top
p[4] = new Vector(xFar, yFar, fFar); // Far, right, top
p[5] = new Vector(xFar, -yFar, fFar); // Far, right, bottom
p[6] = new Vector(-xFar, -yFar, fFar); // Far, left, bottom
p[7] = new Vector( -xFar, yFar, fFar); // Far, left, top
aPlanes[0] = PlaneMath.computePlaneFromPoints( p[2], p[3], p[6] ); // Left
trace("Plan gauche : "+aPlanes[0]);
aPlanes[1] = PlaneMath.computePlaneFromPoints( p[0], p[1], p[4] ); // right
trace("Plan droit : "+aPlanes[1]);
aPlanes[2] = PlaneMath.computePlaneFromPoints( p[0], p[7], p[3] ); // Top
trace("Plan sommet : "+aPlanes[2]);
aPlanes[3] = PlaneMath.computePlaneFromPoints( p[1], p[2], p[5] ); // Bottom
trace("Plan sol : "+aPlanes[3]);
aPlanes[4] = PlaneMath.computePlaneFromPoints( p[0], p[2], p[1] ); // Near
trace("Plan proche : "+aPlanes[4]);
aPlanes[5] = PlaneMath.computePlaneFromPoints( p[4], p[5], p[6] ); // Far
trace("Plan lointain : "+aPlanes[5]);
for( var i:Number = 0; i < 6; i++ )
PlaneMath.normalizePlane( aPlanes[i] );
} |
Partager