Load models (.obj/.mtl) blender in LWJGL 3

Started by begin, October 29, 2018, 16:37:31

Previous topic - Next topic

begin

Hello!

Sorry for my speak, My English is not native
Okey, I need create load/parser of models for my project (library LWJGL 3)
Formats .mtl file and .obj.

I'm just starting to use the LWJGL library, so I do not know much.
But I have been looking for an answer to this question for a very long time - Where I can to find this is load/parser?
Now I ussing this engine - https://github.com/LWJGL/lwjgl3-demos

But have problem.
This engine dont't hold loading mtl format, i.e his don't can load texture (.mtl) of my model.
(Sorry for my speak. Hes very complicated for me  :) )

I aldready looked all sites with this loader,
but they were all used for LWJGL2 and the smaller version or they gave me a lot of errors.

Okey, now I ask your help me!  :'(

KaiHH

This demo https://github.com/LWJGL/lwjgl3-demos/blob/master/src/org/lwjgl/demo/opengl/assimp/WavefrontObjDemo.java#L240 uses Assimp to load both the geometry in the .obj file as well as the material from the .mtl file. It renders a red magnet.

begin

I already looked this, but I could not  sort out with shaders..
Is it possible to simplify an example? I could not make out the work of shaders

KaiHH

What exactly are you asking for? If you just want to know how to extract the information from an .obj and .mtl file and render that however you want, then just look at these lines: https://github.com/LWJGL/lwjgl3-demos/blob/master/src/org/lwjgl/demo/opengl/assimp/WavefrontObjDemo.java#L380-L397
and the methods/constructors they call.
Just ignore the fact that this demo uses shaders to render the model. You can just as well use the fixed-function pipeline to render the model. Every information of the imported model is available through the AIScene instance.

begin

Good, but I getting it:



Must be:



I can't understand, what me to do...
I think that problem in my code mtl and obj (OR shaders):

.mtl format

# Blender MTL File: 'None'
# Material Count: 3

newmtl Material.001
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.047609 0.042289 0.236911
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.002
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.678536 0.710339 0.647579
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.003
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.010962 0.254837 0.181573
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2




KaiHH

You cannot really expect to export a model from Blender, use any arbitrary OpenGL demo program, which just happens to load a .obj/.mtl model, and get the same result compared to what Blender's 3D view shows you.
You HAVE TO learn about OpenGL/GLSL and shading models if you want that.

Quote from: begin on October 29, 2018, 19:57:47
I can't understand, what me to do...
Learn Graphics Programming with OpenGL and GLSL:
1. read lots of articles, books, tutorials about OpenGL and GLSL
2. write lots of example/demos/throw-away programs
3. iterate between 1. and 2.

begin

Okey, Сan you recommend something from the study material?


begin

I already look ThinMatrix, but thank you for material :)