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.

 Accepted Answer

Walter Roberson
Walter Roberson on 19 Sep 2015

0 votes

9 Comments

jiji hr
jiji hr on 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 on 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.
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.
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.
readobj is here
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
What is class(obj.v) and also size()? I wonder if it is []
Gayathri
Gayathri on 27 Jul 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?
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.

Sign in to comment.

More Answers (1)

Mariem Khlifi
Mariem Khlifi on 5 Mar 2022

0 votes

toolbox_graph has a function read_obj that does that.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!