SAM-Viewer [0.5]

Post Reply
User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

SAM-Viewer [0.5]

by stu » Post

Introducing SAM-Viewer, a simple 3d mesh viewer built with Irrlicht rendering engine.

Nothing really new or exiting here, just a personal project to try and better understand the Irrlicht engine in general and get to the bottom of the attachment glitches with my wield3d mod.

I am sharing this for the benefit of anyone else learning c++ or Irrlicht and thought might be helpful to the MT modding community. If nothing else, it provides a convenient way to check your blender exports with the core rendering engine. You can even use this as a skin editing preview tool, along with your pixel editor of choice.

Some may also notice that the model included with the distribution does not suffer the same 180 degree reversal effects as the current version you get with Minetest Game. This is because if have tweaked the animation bone positions to never perfectly align with the zero axis. I am still unsure if the blender export is at fault or the Irrlicht model loader.

I love to hear from anyone that gets this to build, although it is pretty much linux + openGL only for now. Any help in improving it to make the app more portable would be greatly appreciated.

Constructive code critique is also welcomed as this is the first complete c++ app I have ever publicly released. The code-style is very much my own but just happens to be pretty much the same as that of MTE. If that style diverges in places then meh, I am not fixing that :P

Aside from bug-fixes and the things listed on the official todo list, I am not too sure how much further I will be taking this, however, I will consider any reasonable suggestions that could make the app more useful.

Download/browse code: https://github.com/stujones11/SAM-Viewer

Screenshot:

Image
Last edited by stu on Sun Oct 07, 2018 16:01, edited 1 time in total.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: SAM-Viewer

by GreenXenith » Post

I receive this error when compiling:

Code: Select all

/home/user/SAM-Viewer/src/dialog.cpp: In function ‘void open_url(std::__cxx11::string)’:
/home/user/SAM-Viewer/src/dialog.cpp:19:8: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system((std::string("xdg-open \"") + url + std::string("\"")).c_str());
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/samviewer.dir/all' failed
make[1]: *** [CMakeFiles/samviewer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

GreenDimond wrote:I receive this error when compiling:

Code: Select all

warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
Yeah, I am not really sure about that code, it was adapted from a stack-overflow answer to opening a browser page. However, that is merely a warning. Do you see any other specific error messages in the build log?

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: SAM-Viewer

by GreenXenith » Post

stu wrote:Do you see any other specific error messages in the build log?
Yes.

Code: Select all

make[2]: *** No rule to make target '/usr/local/lib/libIrrlicht.so', needed by 'bin/samviewer'.  Stop.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
Krock
Developer
Posts: 4649
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: SAM-Viewer

by Krock » Post

I'm probably getting the same error, which is caused by the hardcoded path for Irrlicht in this project: "/usr/local/lib/libIrrlicht.so" whereas it should be "/usr/lib/x86_64-linux-gnu/libIrrlicht.so" on my system.

Here's how Minetest does it: https://github.com/minetest/minetest/bl ... ke#L41-L53
Compiling works after adjusting this but it's already late so I'll review it later on :)
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

GreenDimond wrote:

Code: Select all

make[2]: *** No rule to make target '/usr/local/lib/libIrrlicht.so', needed by 'bin/samviewer'.  Stop.
Did you try the suggested:

Code: Select all

cmake . -DIRRLICHT_LIBRARY="/usr/lib/libIrrlicht.so"`
Krock wrote:Compiling works after adjusting this but it's already late so I'll review it later on :)
Thank you so much for showing an interest, I will very much look forward to that :)

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: SAM-Viewer

by GreenXenith » Post

stu wrote:
GreenDimond wrote:

Code: Select all

make[2]: *** No rule to make target '/usr/local/lib/libIrrlicht.so', needed by 'bin/samviewer'.  Stop.
Did you try the suggested:

Code: Select all

cmake . -DIRRLICHT_LIBRARY="/usr/lib/libIrrlicht.so"`
I still get:

Code: Select all

make[2]: *** No rule to make target '/usr/lib/libIrrlicht.so', needed by 'bin/samviewer'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 12%] Building CXX object CMakeFiles/samviewer.dir/src/main.cpp.o
[ 37%] Building CXX object CMakeFiles/samviewer.dir/src/gui.cpp.o
[ 37%] Building CXX object CMakeFiles/samviewer.dir/src/dialog.cpp.o
[ 50%] Building CXX object CMakeFiles/samviewer.dir/src/config.cpp.o
[ 62%] Building CXX object CMakeFiles/samviewer.dir/src/trackball.cpp.o
[ 87%] Building CXX object CMakeFiles/samviewer.dir/src/viewer.cpp.o
[ 87%] Building CXX object CMakeFiles/samviewer.dir/src/scene.cpp.o
/home/user/SAM-Viewer/src/dialog.cpp: In function ‘void open_url(std::__cxx11::string)’:
/home/user/SAM-Viewer/src/dialog.cpp:19:8: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system((std::string("xdg-open \"") + url + std::string("\"")).c_str());
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/samviewer.dir/all' failed
make[1]: *** [CMakeFiles/samviewer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

Sorry, my build script clearly sucks but hopefully those more experienced can help me clean this up.

To fix this you need to replace the path in the cmake option to where that library resides on your own system.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: SAM-Viewer

by GreenXenith » Post

stu wrote:To fix this you need to replace the path in the cmake option to where that library resides on your own system.
Ah, thankyou.

Code: Select all

cmake . -DIRRLICHT_LIBRARY="/usr/lib/x86_64-linux-gnu/libIrrlicht.so"
did the trick.

First look: Works perfectly!
Image
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

GreenDimond wrote:
stu wrote:To fix this you need to replace the path in the cmake option to where that library resides on your own system.
Ah, thankyou.

Code: Select all

cmake . -DIRRLICHT_LIBRARY="/usr/lib/x86_64-linux-gnu/libIrrlicht.so"
did the trick.

First look: Works perfectly!
Nice to see you got it working, although I would be amazed if I had not left at least some bugs in there =)

I have now changed the example path to this as it's the same one that worked for Krock, *buntu based distros maybe? I am using vanilla debian so the defaults work for me. I might add auto detection at some point, though I'd like to understand it rather than just blindly copying MT's build scripts.

User avatar
Krock
Developer
Posts: 4649
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: SAM-Viewer

by Krock » Post

stu wrote:I have now changed the example path to this as it's the same one that worked for Krock, *buntu based distros maybe?
Until the next user with another distribution comes and reports the same issue. It would be helpful to have an auto-detection to ease the compiling process. However, I see that you prefer to first understand what the CMake lines do.
Meanwhile I discovered the Sam steam engine. Why should I change the texture when it looks a bit weird but funny? ;)

Image
Attachments
sam_steam_engine.png
sam_steam_engine.png (32.3 KiB) Viewed 752 times
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

Krock wrote:Meanwhile I discovered the Sam steam engine. Why should I change the texture when it looks a bit weird but funny? ;)
LOL, kinda reminds me of poo-choo train =)

kestral
Member
Posts: 95
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: SAM-Viewer

by kestral » Post

Stu,
I was able to build your program samviewer on Fedora 27 with
-DIRRLICHT_LIBRARY="/usr/lib64/libIrrlicht.so"

On my local copy, I made the following minor changes to allow me to use your program to load model files from any directory:

1. Copied bin/samviewer to ~/bin/

2. Copied asset directory to ~/.local/share/samviewer/assets

3. Copied media/pickaxe* to ~/.local/share/samviewer/assets/

3. Edited src/viewer.cpp and recompiled

From this (starting line 41):

Code: Select all

-   device->getFileSystem()->addFileArchive("../assets/");
-   device->getFileSystem()->addFileArchive("../media/");
-   device->getFileSystem()->changeWorkingDirectoryTo("../media/");
To this:

Code: Select all

+   device->getFileSystem()->addFileArchive("/home/myusername/.local/share/samviewer/assets/");
+// device->getFileSystem()->addFileArchive("../media/");
+// device->getFileSystem()->changeWorkingDirectoryTo("../media/");
Your program looks very interesting.
I plan on using it to help me learn about how minetest character files and the player_api work.

[edited for clarification]
Last edited by kestral on Tue Jul 03, 2018 17:23, edited 1 time in total.

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: SAM-Viewer

by ExeterDad » Post

This is win, win. We get a useful (and cool) tool, and you get to learn what few seem to understand. Thanks for your efforts :)

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer

by stu » Post

ExeterDad wrote:This is win, win. We get a useful (and cool) tool, and you get to learn what few seem to understand. Thanks for your efforts :)
Thanks for the kind words, I certainly did learn a lot by making this, however one thing is for sure, I would never use Irrlcht's gui for anything more complex. If I was making this again, I would probably use QT for the gui with an embedded Irrlicht viewport.

@kestral, thanks for letting me know you got it working. I am not sure why the code change should be necessary. I will look into that. The Irrlicht file browser is rather 'basic' to put it nicely =)

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: SAM-Viewer [0.5]

by stu » Post

After finding this application very useful when re-mastering some old meshes where the .blend files were no longer available, I decided to give it bit of love. Version 0.5 now features simple lighting and static mesh export options, along with a number of bug-fixes and improvements like better file browsing.

Image

Of course, this is nothing you can't do with Blender but then you could say the same for a lot of things :D

Note that the above is a Wavefront (.obj) mesh exported without scaling. To make it the correct size for Minetest you should set the export scale to 10%. Don't ask me why, that's just MT for ya!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests