Files
igl/examples/transparency/project.m
T
2013-12-18 13:14:17 +01:00

11 lines
336 B
Matlab

function W = project(V,MV,P,VP)
V = V * MV' * P';
% WTF! Perspective division is not in the documentation for gluProject:
% http://www.opengl.org/sdk/docs/man2/xhtml/gluProject.xml
V = bsxfun(@rdivide,V,V(:,4));
W = [ ...
VP(1) + (VP(3) * (V(:,1)+1))/2, ...
VP(2) + (VP(4) * (V(:,2)+1))/2, ...
(V(:,3)+1)/2];
end