Set material and camlight to a specific axis

3 vues (au cours des 30 derniers jours)
Baptiste Ranguetat
Baptiste Ranguetat le 7 Août 2017
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

Réponses (1)

Neil Guertin
Neil Guertin le 10 Août 2017
"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

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by