Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open .mtl file associated to .obj file #140

Open
btchouston opened this issue Nov 25, 2017 · 11 comments
Open

Open .mtl file associated to .obj file #140

btchouston opened this issue Nov 25, 2017 · 11 comments

Comments

@btchouston
Copy link

Hi all,
when i open an .obj file associated to an .mtl file, the mtl file that contain information for texture is not opened. So my mesh file is not textured. Even those inside mesh/textured folder of Meshlabjs does not work.
You can test it by opening this file ( meshlabjs/mesh/textured/texturedknot.obj ) with http://www.meshlabjs.net/ , you will see that texture is not applied, and this message wil appear :

Warning in opening file 'texturedknot.obj': Some materials definitions were not found, a default white material is used where no material was available

Am i missing something ?
What should i do to open an .obj file with texture from .mtl applied ?

Thank you for your help.

@vadnart1
Copy link

Hi everyone, i have the same question. how do you associate the texture material (.mtl) with the .obj file ?
by the way, awesome job with meshlabjs . amazing work, very well done !

thank you,
david

@Gabryxx7
Copy link
Contributor

Gabryxx7 commented Dec 4, 2017

Hello everyone,

I have been working on the texture support for meshlabjs, it has been developed on a separate branch and is currently waiting to be merged into the master branch.

The mesh file and the texture file must be in the same archive (.zip archives support has been added as well).

Although it does not support multiple textures at shader level (only one texture may be displayed), a new panel has been added to the UI where it is possible to check the texture file(s), allowing zoom, pan and display of the unfolded mesh geometry over the texture image.

@btchouston
Copy link
Author

Hi Gabyxx7,
thank you

@Gabryxx7
Copy link
Contributor

Gabryxx7 commented Dec 5, 2017

Unfortunately, I cannot really tell when it will be merged in the master branch to be available for everyone! But you can check out the result in some old screenshots I took while developing the support. Eventually I added many more features, these screenshots are from an early version:

13901673_1758094191100825_175578934_o
13714464_1750977781812466_1042829651_n

@btchouston
Copy link
Author

Please @Gabryxx7 , how can i compile it on my side ?
I tried to switch on the branch textureSupport and compile, but i am getting the following error.

emcc -o Color.bc Color.cpp -I.  -I ../../vcglib/ -s TOTAL_MEMORY=536870912  -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 -O3  --bind 
emcc -o Measure.bc Measure.cpp -I.  -I ../../vcglib/ -s TOTAL_MEMORY=536870912  -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 -O3  --bind 
Measure.cpp:169:7: error: no member named 'BuildMontecarloSampling' in 'vcg::tri::VoronoiVolumeSampling<MyMesh>'; did you mean
      'BuildMontecarloVolumeSampling'?
  vvs.BuildMontecarloSampling(montecarloSampleNum);
      ^~~~~~~~~~~~~~~~~~~~~~~
      BuildMontecarloVolumeSampling
../../vcglib/vcg/complex/algorithms/voronoi_volume_sampling.h:594:7: note: 'BuildMontecarloVolumeSampling' declared here
 void BuildMontecarloVolumeSampling(int montecarloSampleNum)
      ^
Measure.cpp:171:7: error: no member named 'ThicknessEvaluator' in 'vcg::tri::VoronoiVolumeSampling<MyMesh>'
  vvs.ThicknessEvaluator(distThr,16,3,skelM);
  ~~~ ^
Measure.cpp:179:57: error: no member named 'poissonSurfaceMesh' in 'vcg::tri::VoronoiVolumeSampling<MyMesh>'
    tri::Append<MyMesh,MyMesh>::MeshCopy(*surfSamp, vvs.poissonSurfaceMesh);
                                                    ~~~ ^
3 errors generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
MakefileJS:24: recipe for target 'Measure.bc' failed
make: *** [Measure.bc] Error 1

What can i do to build Meshlabjs with this feature ?

@Gabryxx7
Copy link
Contributor

Gabryxx7 commented Dec 5, 2017

I was having the same issue and I had to merge it with the updated master branch. Furthermore, the vcglib has been updated and some functions had a different name or were declared in other classes.

It required way longer than expected but right now it is compiling again on my side and it looks fine, although I am sure there will be issues with the latest changes (e.g unod/redo, even though it looks like is working just fine, the code is not consistent and clean).

Could you please pull and let me know? :)

I also uploaded a build.bat file I use to compile, along with a texture.zip file in mesh/textured/textured.zip where you will find this cute bulbasaur mesh with its material and texture file. I created the .zip archive with winrar, no special options.

As you can see the texture panel works fine, you can enable/disable the texture in the rendering panel (where you also find smooth/flat rendering).

As I previously mentioned, multi texture is not supported yet, even though the texture files are properly read and extracted, I still couldn't figure out a way to render them both in a mesh.
You may check that by zipping TextureDouble.ply with TextureDouble_A.png and TextureDouble_B.png all together. Once loaded, in the texture panel you will be able to select both textures A and B, but only one of them will appear on the mesh.

test

@btchouston
Copy link
Author

Thank you @Gabryxx7
i made the pull and compiled successfully. I used this version of vcglib, and changed muparserLib.bc to muParserLib.bc inside MakefileJS file.

screenshot from 2017-12-05 21-12-24

I also tried my personal .obj file with texture, and i worked fine.
Thank you ! :) 👍

@Gabryxx7
Copy link
Contributor

Gabryxx7 commented Dec 5, 2017

You're welcome @btchouston ! :)

I hope this branch will eventually be merged in the master branch; Along with the undo/redo, I think is a quite interesting and requested feature!

@4zuko
Copy link

4zuko commented Jan 2, 2018

Hi @Gabryxx7,

I am getting the following error when I try to generate MeshLabCppCore.js:

➜  sources git:(textureSupport) ✗ make -f MakefileJS clean
rm -f *.bc MeshlabGenJs.js ../../vcglib/wrap/ply/plylib.bc 
➜  sources git:(textureSupport) ✗ make -f MakefileJS      
emcc -c -o Color.bc Color.cpp -I.  -I ../../vcglib/   -I ../../vcglib/eigenlib -s TOTAL_MEMORY=536870912  -std=c++11 -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 --bind  -s LINKABLE=1 -Os
emcc -c -o Measure.bc Measure.cpp -I.  -I ../../vcglib/   -I ../../vcglib/eigenlib -s TOTAL_MEMORY=536870912  -std=c++11 -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 --bind  -s LINKABLE=1 -Os
emcc -c -o Decorator.bc Decorator.cpp -I.  -I ../../vcglib/   -I ../../vcglib/eigenlib -s TOTAL_MEMORY=536870912  -std=c++11 -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 --bind  -s LINKABLE=1 -Os
emcc -c -o CppMesh.bc CppMesh.cpp -I.  -I ../../vcglib/   -I ../../vcglib/eigenlib -s TOTAL_MEMORY=536870912  -std=c++11 -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 --bind  -s LINKABLE=1 -Os
emcc -c -o Meshing.bc Meshing.cpp -I.  -I ../../vcglib/   -I ../../vcglib/eigenlib -s TOTAL_MEMORY=536870912  -std=c++11 -s PRECISE_F32=1 -s DEMANGLE_SUPPORT=1 --bind  -s LINKABLE=1 -Os
Meshing.cpp:195:6: error: no member named 'BuildVisitTree' in
      'vcg::tri::CoM<MyMesh>'
  cc.BuildVisitTree(poly);
  ~~ ^
Meshing.cpp:196:12: error: no member named 'OptimizeTree' in
      'vcg::tri::CoM<MyMesh>'
  while(cc.OptimizeTree(poly));
        ~~ ^
Meshing.cpp:197:33: error: no viable conversion from 'MyMesh' to 'bool'
  cc.MarkFauxEdgeWithPolyLine(m,poly);
                                ^~~~
../../vcglib/vcg/complex/algorithms/curve_on_manifold.h:187:53: note: passing
      argument to parameter 'markFlag' here
  bool MarkFauxEdgeWithPolyLine(MeshType &poly,bool markFlag=true)
                                                    ^
3 errors generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
make: *** [Meshing.bc] Error 1

I am not sure how to solve the issue. Could you please push the content of folder meshlabjs/js/generated/ or provide me a link to it?

I tried to use MeshLabCppCore.js file from https://github.com/cnr-isti-vclab/meshlabjs/tree/gh-pages/js/generated. If I try to import .zip file I am getting following error:

Uncaught BindingErrormessage: "function CppMesh.openMeshZip called with 2 arguments, expected 1 args!"name: "BindingError"stack: "BindingError: function CppMesh.openMeshZip called with 2 arguments, expected 1 args!↵    at BindingError.<anonymous> (http://localhost:1008/meshlabjs/js/generated/MeshLabCppCore.js:1:30189)↵    at new BindingError (eval at createNamedFunction (http://localhost:1008/meshlabjs/js/generated/MeshLabCppCore.js:1:29895), <anonymous>:4:34)↵    at throwBindingError (http://localhost:1008/meshlabjs/js/generated/MeshLabCppCore.js:1:30634)↵    at CppMesh$openMeshZip [as openMeshZip] (eval at new_ (http://localhost:1008/meshlabjs/js/generated/MeshLabCppCore.js:1:170570), <anonymous>:5:1)↵    at FileReader.fileReader.onloadend (http://localhost:1008/meshlabjs/js/mlj/core/File.js:90:38)"__proto__: Error

If I try to import .obj file I am getting following error:

Layer.js:148 Uncaught TypeError: cppMesh.getWedgeTextureCoordinates is not a function
    at MLJ.core.Layer.updateMeshBufferData (Layer.js:148)
    at MLJ.core.Layer.initializeRenderingAttributes (Layer.js:91)
    at Object.addLayer (Scene.js:575)
    at HTMLDocument.<anonymous> (Scene.js:426)

@4zuko
Copy link

4zuko commented Jan 4, 2018

Hi @Gabryxx7, @btchouston. I managed to solve the issue with build but when I access index page I am getting errors:

THREE.WebGLRenderer 71
THREE.WebGLRenderer 71
missing function: _ZNSt3__16locale7classicEv
-1
-1
[Console - before import]
Uncaught abort(-1) at Error
    at jsStackTrace (http://localhost:1016/js/generated/MeshLabCppCore.js:1:17016)
[Console - after import]
Uncaught UnboundTypeError {name: "UnboundTypeError", message: "Cannot call CppMesh.setMeshName due to unbound typ…c_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE", stack: "UnboundTypeError: Cannot call CppMesh.setMeshName …http://localhost:1016/js/mlj/core/File.js:116:19)"}

and I am not able to import .zip file or .obj file as well:

screen shot 2018-01-04 at 16 02 42

Have you had similar issue? Please suggest.

P.S. I've pulled vcglib/master and meshlabjs/textureSupport branches.

➜  sources git:(textureSupport) ✗ python --version
Python 2.7.10
➜  sources git:(textureSupport) ✗ node --version  
v6.11.3
➜  sources git:(textureSupport) ✗ git --version
git version 2.15.1
➜  sources git:(textureSupport) ✗ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
➜  sources git:(textureSupport) ✗ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
➜  sources git:(textureSupport) ✗ g++
clang: error: no input files
➜  sources git:(textureSupport) ✗ cmake
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

➜  sources git:(textureSupport) ✗ 

Could you please check your versions? I would like to compare my versions with yours. Thanks.

@avnermosh
Copy link

avnermosh commented Jan 12, 2018

Hi @Gabryxx7

Thanks for adding texture support.
I built and ran the branch in 2 machines (both machines have similar package versions - see below).
In the first machine I can see textured.zip rendered with texture (although the "Texture" tab is empty, i.e. there is no texture 2d image or information like what is shown in your comment above (first comment on Dec 5) )

In the other machine I'm getting an error before the model is even loaded (i.e. when typing "localhost" in the web browser)
missing function: _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc
Other people are seeing this missing symbol together with many other missing symbols, and mention that the reason is missing linked library (e.g. libcxx)
(see here emscripten-core/emscripten#5143)
But in my case only the mentioned symbol is missing.
This [post] https://groups.google.com/forum/#!topic/emscripten-discuss/llX0HtHyxN8 hints that maybe the problem is in emscripten
The solution for now was to remove the target muParserLib.bc in MakefileJS. After doing it, the branch builds and textured.zip is displayed with texture overlay, in both machines.

Both machines have the same following components:

  • Ubuntu 16.04 OS
  • Firefox 57.0.4 (64-bit)
  • emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.28
    clang version 4.0.0 (emscripten 1.37.28 : 1.37.28)
    Target: x86_64-unknown-linux-gnu
  • nodejs -v v4.2.6

I ran the build with
VERBOSE = 1
EMCC_DEBUG=1

The missing symbol is coming from muParserLib.bc
llvm-nm -a ../sources/lib/muParserLib.bc | grep _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc
U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc

Do you have an idea what could be the problem?
Thanks,
Avner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants