All pastes #996378 Raw Edit

Anonymous

public text v1 · immutable
#996378 ·published 2008-04-24 22:02 UTC
rendered paste body
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
    Matrix matrix = Matrix.Multiply(Matrix.Multiply(world, view), projection);
    Vector3 vector = Vector3.Transform(source, matrix);
    float a = (((source.X * matrix.M14) + (source.Y * matrix.M24)) + (source.Z * matrix.M34)) + matrix.M44;
    if (!WithinEpsilon(a, 1f))
    {
        vector = (Vector3) (vector / a);
    }
    vector.X = (((vector.X + 1f) * 0.5f) * this.Width) + this.X;
    vector.Y = (((-vector.Y + 1f) * 0.5f) * this.Height) + this.Y;
    vector.Z = (vector.Z * (this.MaxDepth - this.MinDepth)) + this.MinDepth;
    return vector;
}