Gildor's Forums

English Forum => UE Viewer source code => Topic started by: Gildor on July 16, 2014, 17:40



Title: Umodel source code
Post by: Gildor on July 16, 2014, 17:40
Hi all,

Today I've posted an Umodel source code on GitHub - https://github.com/gildor2/UModel

The source code license wasn't chosen yet. Feel free to post any questions/comments here (on this board).

Thanks,
Konstantin


Title: Re: Umodel source code
Post by: VendorX on July 16, 2014, 23:51
Thanks for your trust - I will check the source right now ...  ;D


Title: Re: Umodel source code
Post by: warrantyvoider on September 20, 2014, 00:02
so you finally did it?! congratz! and thanks alot!  ;D

greetz WV


Title: Re: Umodel source code
Post by: Gildor on September 23, 2014, 20:30
I wrote some build instructions, available here:
https://github.com/gildor2/UModel/blob/master/README.md


Title: Re: Umodel source code
Post by: switchit on November 25, 2014, 13:50
I am trying to compile the source on Linux but it doesn't work so well...

I actually just wanted to use the UmdExtract Tool, so I tried to to compile only that first:

g++ Main.cpp -o umdextract

But I got a bunch of errors saying stuff like:

Code:
UnGnuG.h:20:3: error: #error Unsupported platform.
  #error Unsupported platform.

In file included from Core.h:29:0,
                 from Main.cpp:1:
UnGnuG.h:254:15: warning: missing terminating " character [enabled by default]
  asm volatile("
               ^

/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:212:23: error: ‘size_t’ has a previous declaration as ‘typedef long unsigned int size_t’
 typedef __SIZE_TYPE__ size_t;
                       ^
UnTemplate.h: In member function ‘void TMapBase<TK, TI>::Rehash()’:
UnTemplate.h:1390:46: error: ‘HashCount’ was not declared in this scope
   INT* NewHash = new(TEXT("HashMapHash"))INT[HashCount];

Since I could not get that to work I tried compiling Umodel but that didnt work either...

make -f makefile-linux

Then I got this:

Code:
gcc -pipe -c -msse -std=c++0x -fno-strict-aliasing -fno-stack-protector -Wno-invalid-offsetof -Os -I . -I ./Core -I ./Unreal -I ./libs/include -I ./libs/nvtt -I ./libs/PowerVR -I UmodelTool -I UI -o ./obj/umodel-unix/Exporters.o Exporters/Exporters.cpp
Exporters/Exporters.cpp: In member function ‘int ExportedObjectEntry::GetHash() const’:
Exporters/Exporters.cpp:64:18: error: cast from ‘const UnPackage*’ to ‘int’ loses precision [-fpermissive]
   return ( ((int)Package >> 3) ^ ExportIndex ^ (ExportIndex << 4) ) & (EXPORTED_LIST_HASH_SIZE - 1);
                  ^
make: *** [obj/umodel-unix/Exporters.o] Error 1

Finally I tried just running the executable directly in Linux...

./umodel
Code:
./umodel: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory

After giving up on getting it to work in Linux, I installed VirtualBox and Windows XP and tried to run the application there.

But when I select my umd file and try to export it I get this error message:

Code:
Fatal Error

Wrong tag in package: 16F5489A

I don't think there is anything else I can try to do to get Umodel to work for me, but could someone please help me to extract the content of my umd file if I send it to you?






Title: Re: Umodel source code
Post by: Gildor on November 25, 2014, 14:05
I am trying to compile the source on Linux but it doesn't work so well...

I actually just wanted to use the UmdExtract Tool, so I tried to to compile only that first:

g++ Main.cpp -o umdextract
This will not work - a long list of defines etc is required, that's why makefile exists.

Quote
Since I could not get that to work I tried compiling Umodel but that didnt work either...

make -f makefile-linux

Then I got this:

Code:
gcc -pipe -c -msse -std=c++0x -fno-strict-aliasing -fno-stack-protector -Wno-invalid-offsetof -Os -I . -I ./Core -I ./Unreal -I ./libs/include -I ./libs/nvtt -I ./libs/PowerVR -I UmodelTool -I UI -o ./obj/umodel-unix/Exporters.o Exporters/Exporters.cpp
Exporters/Exporters.cpp: In member function ‘int ExportedObjectEntry::GetHash() const’:
Exporters/Exporters.cpp:64:18: error: cast from ‘const UnPackage*’ to ‘int’ loses precision [-fpermissive]
   return ( ((int)Package >> 3) ^ ExportIndex ^ (ExportIndex << 4) ) & (EXPORTED_LIST_HASH_SIZE - 1);
                  ^
make: *** [obj/umodel-unix/Exporters.o] Error 1
Very strange error. I'm building with GCC too, but have no such kind of problem. May be your compiler tries to build 64-bit code? (I don't know which gcc switches required for that)

Quote
Finally I tried just running the executable directly in Linux...

./umodel
Code:
./umodel: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
You should install libsdl2 package.

Quote
After giving up on getting it to work in Linux, I installed VirtualBox and Windows XP and tried to run the application there.

But when I select my umd file and try to export it I get this error message:

Code:
Fatal Error

Wrong tag in package: 16F5489A
Are you trying to open UMD file in umodel or with UnUmd?


Title: Re: Umodel source code
Post by: Gildor on November 25, 2014, 20:59
I think you wasn't able to build UModel for Linux because you used Linux x64 while UModel wasn't prepared for 64-bit builds. I've fixed all 64-bit issues and was able to build Win64 version of UModel. Most likely these fixes enough to compile UModel under Linux x64. Please try updated code.

Unfortunately I can't check Linux x64 build right now by myself because I have x86 Linux installed under VMware. Making a working Linux under VMware wasn't easy task for me - I was forced to find and install a working kernel (the kernel shipped with latest kubuntu isn't supported by this system, so hardware rendering acceleration and shared folders didn't work), etc. Also, setting up everything in Linux isn't a quick task either.


Title: Re: Umodel source code
Post by: gf1593 on May 13, 2017, 17:28
Can't set it up for windows visual studio 2015. :'(
After all files been put in the right directory, and run the build.sh, I get this message:
Generating makefile from UmodelTool/umodel.project ...
Gathering dependency info ...
Makefile generated.
Using Visual C++ 11 (32 bit) found at "C:/Program Files (x86)/microsoft visual studio 11.0/vc" ...
CALLING jom makefile-vc-win32
Core.cpp
GlWindow.cpp
d:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\libs\includewin32\SDL2/SDL_syswm.h(58) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
Core/Core.cpp(12) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\Core.obj] Error 2
CoreWin32.cpp
Core/CoreWin32.cpp(8) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
TextContainer.cpp
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\CoreWin32.obj] Error 2
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\GlWindow.obj] Error 2
Build time: 0.5 sec


Title: Re: Umodel source code
Post by: Gildor on May 13, 2017, 18:19
I've re-uploaded BuildTools.zip, please try it. Changed "vc32tools" file. Now VS2015 should compile UModel.
You shouldn't use MSVCRT.lib for the build. Most likely you didn't use it anyway, but just in case - set "OLDCRT" variable in common.project to 0. OLDCRT is supported up to VS2013 build.


Title: Re: Umodel source code
Post by: gf1593 on May 16, 2017, 10:26
I started over from the beginning...
I do notice something in the message:
Code:
Using Visual C++ 11 (2012) [32 bit] found at "C:/Program Files (x86)/microsoft visual studio 11.0/vc" ...
This is some remaining files from uninstalled Visual C++ I think, not my vs 2015 folder, it's in my "E" disk.
Code:
Cannot open include file: 'GL/gl.h': No such file or directory
Missing gl.h, I found it in the "MSVCRT.zip" file, and copied it into "Core/Gl" folder, but of course it led more problems :-\
Sorry I just can't get it right
Code:
../Shaders.h does not exists, creating ...
Generating makefile from UmodelTool/umodel.project ...
Gathering dependency info ...
Makefile generated.
Using Visual C++ 11 (2012) [32 bit] found at "C:/Program Files (x86)/microsoft visual studio 11.0/vc" ...
CALLING jom makefile-vc-win32
Export3D.cpp
Exporters.cpp
ExportMaterial.cpp
d:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\Core\CoreGL.h(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory
d:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\Core\CoreGL.h(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory
d:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\Core\CoreGL.h(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\Exporters.obj] Error 2
ExportMd5.cpp
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\Export3D.obj] Error 2
d:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\Core\CoreGL.h(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\ExportMd5.obj] Error 2
jom: D:\My Documents\Visual Studio 2015\Projects\GitHub\UModel\makefile-vc-win32 [.\obj\umodel-win32\ExportMaterial.obj] Error 2
Build time: 0.6 sec


Title: Re: Umodel source code
Post by: Gildor on May 16, 2017, 10:33
Try setting Visual Studio version in build.sh: see line 47, "export vc_ver=2010".


Title: Re: Umodel source code
Post by: mirzu42 on July 06, 2018, 04:25
hi, im trying to build it on linux but it doesent seem to work at all. i have gcc and sdl2 2.0.7 installed but it just says error everytime when i try. any help?


Title: Re: Umodel source code
Post by: Gildor on July 06, 2018, 10:45
What problem do yo have? You provided zero information for being able to answer.

I'd suggest you reading this thread, just in case:
http://www.gildor.org/smf/index.php/topic,2493.0.html


Title: Re: Umodel source code
Post by: mirzu42 on July 08, 2018, 00:38
What problem do yo have? You provided zero information for being able to answer.

I'd suggest you reading this thread, just in case:
http://www.gildor.org/smf/index.php/topic,2493.0.html



yea i got it to work.
you should add somewhere that you need to git clone it because if you just download zip it wont work for some reason. a gui would be nice but its not needed tho.


Title: Re: Umodel source code
Post by: Gildor on July 08, 2018, 12:17
I've fixed build without use of "git clone".


Title: Re: Umodel source code
Post by: GambitAnimating on July 10, 2018, 05:12
Hey Gildor, I’m trying to use #include <iostream> and other c++ libs but umodel doesnt seem to let me do this, if I wanted to use the iostream would I need to include it after certain code was called or how could I do this? Thanks for your time :) (I’m building for windows 32 bit)


Title: Re: Umodel source code
Post by: Gildor on July 10, 2018, 07:24
I'm not using STL, and even disabled C++ exceptions in project's settings. UModel's Core has everything what's needed.


Title: Re: Umodel source code
Post by: GambitAnimating on July 10, 2018, 20:15
I see, is there any way to use tge STL if I wanted to though? Currently it seems to allow most c headers but not many C++ headers, is this a setting I can maybe change so I can add things and learn for personal use or is it not possible? Thanks


Title: Re: Umodel source code
Post by: Gildor on July 10, 2018, 20:40
What happens when you're trying to include STL headers?
Do you use MSVCRT library for building UModel? (this MSVCRT build should not be compatible with STL)


Title: Re: Umodel source code
Post by: GambitAnimating on July 10, 2018, 22:15
I get this error when I try to use #include <iostream> or any other STL header - https://i.imgur.com/0emTCAj.png (if I take out the STL it builds fine) in common.project I have commented out #OLDCRT = 1 and changed LIBC to static so I don't believe I'm using the MSVCRT library for building. If I was however, how would I build with something other than it to get STL headers to work?


Title: Re: Umodel source code
Post by: Gildor on July 10, 2018, 22:37
The problem here is conflict with my "operator new" and STL's one. There's nothing related to compiler, CRT library etc.
Probably you should include STL header AFTER my headers. Or may be disable STL's operator new in some way.


Title: Re: Umodel source code
Post by: GambitAnimating on July 10, 2018, 23:13
So like after all the headers you include in UmodelTool/main.cpp or is that not the last of your includes? Because if I include it after all your headers in main.cpp I get this error https://i.imgur.com/zphKFF9.png can I edit your "operator new" in some way to get it to work, or any idea what I might do to get it working?


Title: Re: Umodel source code
Post by: Gildor on July 11, 2018, 11:18
You can disable STL's "operator new" by defining _NEW_ constant - this is a hack which will prevent including file "new" (with no extension).

Actually it is very very hard to replace or override STL's operator new in any application, so I'd rather recommend you using my API or CRT instead of STL. You can't disable my "operator new" because my UE framework relies on it. For instance, my memory allocation function clears allocated memory with zeros, and most of code expects this behavior.


Title: Re: Umodel source code
Post by: Gildor on July 11, 2018, 11:38
Probably it would be possible to make operator new/delete non-inline and put them to cpp (I didn't try that by myself)


Title: Re: Umodel source code
Post by: GambitAnimating on July 11, 2018, 12:04
Would making the operator non-inline effect the conflict even? Also if that wouldnt really effect it, can you further explain the hacky was, what do you mean by “dedining _NEW_ constant? Thanks for your time


Title: Re: Umodel source code
Post by: Gildor on July 11, 2018, 12:12
I didn't try to mix UModel with STL code, so these are just my assumptions.

Defining _NEW_ constant will do the following: in "new" header, there's include guards:
Code:
#ifndef _NEW_
#define _NEW_
...
#endif
So, for Visual Studio this will exclude this header from processing. Of course, this is a hack.

Trying to move operator new implementation from header to cpp MAY help, and this is an alternative solution. Probably compiler will use declaration from #include <new>, but implementation will be mine.


Title: Re: Umodel source code
Post by: GambitAnimating on July 14, 2018, 04:40
Defining NEW didn't work btw because then it had other conflict errors and I'd most likely have to keep defining those plus changing some other code while not even knowing if in the end it would work, haha so I stuck to C programming :P


Title: Re: Umodel source code
Post by: Gildor on July 14, 2018, 09:10
"Not using STL" doesn't mean "C programming".


Title: Re: Umodel source code
Post by: GambitAnimating on July 14, 2018, 12:40
No I meant I only did c functions for the things I needed, haha I know that much, STL is just Standard Library Headers :P I know I coupd if still used C++ things


Title: Re: Umodel source code
Post by: Gildor on July 14, 2018, 12:48
If you need a particular STL feature, you may ask if something similar is implemented with UModel's framework. I'm trying to keep framework's API similar to UE4 one. The only thing which is really missing is std::map (TMap).


Title: Re: Umodel source code
Post by: GambitAnimating on July 14, 2018, 20:38
Ah okay, thanks  :) I was kinda wondering why you chose to not use the STL at all and rewrite some of the functions it uses.


Title: Re: Umodel source code
Post by: Gildor on July 14, 2018, 20:42
That wasn't a choice "not to use STL". I just didn't do a "chose to use it" :)
Personal preference. And no needs for STL when use UE-like API.
At work, when I have to use STL, I mostly use STL containers, and sometimes algorithms (only std::sort). But nothing else. Everything else is for "next generation programmers" who doesn't know how to use printf :)


Title: Re: Umodel source code
Post by: GambitAnimating on July 15, 2018, 00:39
Aha I'm kinda from next generation programming but I wanna learn and I know how to use printf at least, haha. Only 17


Title: Re: Umodel source code
Post by: Gildor on January 07, 2022, 12:21
Added MIT license to the source code.