Help! Project a 3D Mesh to an image - how to get the corresponding 2d coordinates with 3D points
조회 수: 7 (최근 30일)
이전 댓글 표시
I'm rendering a 3d mesh using opengl as renderer and the trimesh function.
trimesh(... face, mesh(:, 1), mesh(:, 3), mesh(:, 2), ... 'EdgeColor', 'none', ... 'FaceVertexCData', tex/255, 'FaceColor', 'interp', ... 'FaceLighting', 'phong' ... );
set(gca, ... 'DataAspectRatio', [ 1 1 1 ], ... 'PlotBoxAspectRatio', [ 1 1 1 ], ... 'Units', 'pixels', ... 'GridLineStyle', 'none', ... 'Visible', 'off', 'box', 'off', ... 'Projection', 'perspective'... );
then, I want to know the 2d pixel coordinates of every 3D points without any other calculation.
I've been playing with this for a while and am pretty much stumped, any help would be hugely appreciated.
댓글 수: 0
답변 (1개)
George Abrahams
2024년 2월 10일
편집: George Abrahams
2024년 2월 10일
If you're not commited to using the MATLAB axes' camera, my 3D Rendering Toolbox on File Exchange contains the function world2image which will give you the 2D (X,Y) coordinates of every 3D (X,Y,Z) vertex.
N.B. Technically world2image will also give you a Z-coordinate, which is used for Z-buffering if you want to subsequently rasterize/render the mesh, but you can just ignore this.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!