Help! Project a 3D Mesh to an image - how to get the corresponding 2d coordinates with 3D points

7 Ansichten (letzte 30 Tage)
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.

Antworten (1)

George Abrahams
George Abrahams am 10 Feb. 2024
Bearbeitet: George Abrahams am 10 Feb. 2024
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.

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by