Set material and camlight to a specific axis

조회 수: 6 (최근 30일)
Baptiste Ranguetat
Baptiste Ranguetat 2017년 8월 7일
답변: Neil Guertin 2017년 8월 10일
Hi, i got two axes in a figure, and i want to apply a material and a camlight but it's not working. Is there a solution to fix it ? Thank you.
Here is the complete code:
function dessinerSimulation(self)
cla(self.axeSimulation);
%Dessin du robot
repRobot = self.ctrl.getRepresentationRobot();
vertexRobot = zeros(8,3);
for i=1:8
vertexRobot(i,:) = [repRobot(1,i) repRobot(2,i) repRobot(3,i)];
end
facesRobot = [1 2 4 3; 8 7 5 6; 1 2 6 5 ; 3 4 8 7 ; 4 2 6 8 ; 1 3 7 5];
h = patch('vertices',vertexRobot,...
'faces', facesRobot,...
'parent', self.axeSimulation,...
'edgecolor','w',...
'FaceLighting', 'none',...
'FaceColor', 'flat',...
'FaceVertexCData', [0 1 1 0 0.8 0.8;
0 1 1 0 0.8 0.8;
0 1 0 1 0.8 0.8]');
%Dessin de la piscine
[fPiscine,vPiscine] = self.ctrl.getFacesVerticesPiscine();
patch('Faces',fPiscine,'Vertices',vPiscine,...
'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.30,...
'parent', self.axeSimulation);
material dull;
camlight headlight;
grid on;
xlabel(self.axeSimulation, 'X (mm)');
ylabel(self.axeSimulation, 'Y (mm)');
end

답변 (1개)

Neil Guertin
Neil Guertin 2017년 8월 10일
"material dull" combined with "camlight headlight" may result in a patch that looks very similar to the default settings, especially with polyhedral shapes. I suggest you compare the two side by side and rotate the scene and you may notice that some faces actually are slightly shadowed.
Also note that you have disabled lighting on the robot object with 'FaceLighting','none'.
Here is an example with a surf object so you can compare the lighted version to the default.
f1 = figure;
s1 = surf(peaks);
f2 = figure;
s2 = surf(peaks);
material dull
camlight headlight

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by