文本(x,y,z,'text')在3D空间中工作,但它不是3D空间。有没有一种方法可以在matlab中绘制一个简单的3D文本,就像这样简单:

我不需要阴影或渲染,只是为了能够添加三维文本。
发布于 2012-03-24 01:24:31
使用文本无法做到这一点。您必须拥有文本的图像,并将2-D图像texture map到3-D surface上。默认情况下,图形是使用正交投影在轴上渲染的,因此要创建如上图所示的透视,您必须执行以下任一操作:
通过缩小图像为texture-mapped.
的表面一侧的长度,
下面是一些示例代码来说明上面的内容。我将从创建一个示例文本图像开始:
hFigure = figure('Color', 'w', ... %# Create a figure window
'MenuBar', 'none', ...
'ToolBar', 'none');
hText = uicontrol('Parent', hFigure, ... %# Create a text object
'Style', 'text', ...
'String', 'PHOTOSHOP', ...
'BackgroundColor', 'w', ...
'ForegroundColor', 'r', ...
'FontSize', 50, ...
'FontWeight', 'bold');
set([hText hFigure], 'Pos', get(hText, 'Extent')); %# Adjust the sizes of the
%# text and figure
imageData = getframe(hFigure); %# Save the figure as an image frame
delete(hFigure);
textImage = imageData.cdata; %# Get the RGB image of the text现在我们有了所需文本的图像,下面是如何将其纹理映射到3-D表面并调整视图投影的方法:
surf([0 1; 0 1], [1 0; 1 0], [1 1; 0 0], ...
'FaceColor', 'texturemap', 'CData', textImage);
set(gca, 'Projection', 'perspective', 'CameraViewAngle', 45, ...
'CameraPosition', [0.5 -1 0.5], 'Visible', 'off');这是生成的图像:

https://stackoverflow.com/questions/9843048
复制相似问题