hi friends, I want to view an .obj file on a 3D plot with matlab, not displaying the content, it is been 3 day i search but worthless. Thank you for help.

 Réponse acceptée

Walter Roberson
Walter Roberson le 19 Sep 2015

0 votes

9 commentaires

jiji hr
jiji hr le 19 Sep 2015
in fact it doesn't really answer my question because i don't have texture in my object files but i don't know if i can adapt it to my case (i am a biginner with matlab). any way i will try with. and thank you a lot for your answer.
jiji hr
jiji hr le 19 Sep 2015
if i understood the source code very well i think it takes an image then it parses it in an .obj file, but my problem is that i have an .obj file and i want to know how can i get the 3D model from. This .obj file does not contain texture.
Walter Roberson
Walter Roberson le 19 Sep 2015
The readobj will return an empty .vt field if the .obj file has no texture information. It will not be a problem.
If I understand the code it looks to me as if you could use
obj = readobj('FileName.obj'); %use appropriate file
patch('vertices', obj.v, 'faces', obj.f.v);
shading interp
colormap(gray(256));
lighting phong
camproj('perspective');
axis square
axis off
axis equal
axis tight
cameramenu
However I do not know how the color will come out.
Here readobj is the code from the first of the two links above.
Image Analyst
Image Analyst le 19 Sep 2015
I don't have readobj(). What toolbox is it in? What program created the obj file in the first place? I know Visual Studio creates obj files but I doubt you'd want to open them in MATLAB.
Walter Roberson
Walter Roberson le 20 Sep 2015
readobj is here
Somendra Meena
Somendra Meena le 27 Fév 2020
lineno:2 is giving me an error
Error using patch
Value must be of numeric type and greater than 1
Error in read3dModel (line 13)
patch('Faces', obj.f.v, 'vertices', obj.v);
I'm using this model for sample : https://free3d.com/3d-model/hand-v1--945174.html
Walter Roberson
Walter Roberson le 27 Fév 2020
What is class(obj.v) and also size()? I wonder if it is []
Gayathri
Gayathri le 27 Juil 2022
Hi Roberson,
In relation to this question, I want to know how to detect a new object and validate(extract features like colour, dimensions, texture etc; compare and validate) it with a reference obj file using the above set of code?
How can I give the colour of the new object and how similar it is with the reference obj file.
Can I say how much does the material resemble with mtl file of the reference obj file?
Walter Roberson
Walter Roberson le 28 Juil 2022
I do not understand about "detect a new object" ? The above code is for reading and displaying whatever is in a .obj file, not for deciding which entry has what meaning.

Connectez-vous pour commenter.

Plus de réponses (1)

Mariem Khlifi
Mariem Khlifi le 5 Mar 2022

0 votes

toolbox_graph has a function read_obj that does that.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by