new (experimental) feature: embedding blend-files

new (experimental) feature: embedding blend-files

Postby dertom » Wed Sep 26, 2012 7:31 pm

Ok, I implemented the possibility to embed blend-files into the executable in order to have a way to protect your blend-files from unwanted eyes :D
To do this the blends are converted to arrays by the template-generator (like embedded fonts
compositor.zip and such...). You only have to include the inline-file and use the method gkBlendLoader::loadFromMemory(void*,size*)

As an example you have the option to use this feature in cpp-demo by using SAMPLES_CPPDEMO_BUILD_BLENDS with cmake-gui.

Here are the steps to use this feature:
1) cmake Part I (done in CMake/ConfigOgrekit.cmake)
enable ogrekit_generate_buildin_res and ogrekit_disablezip to true:
Code: Select all
   if (SAMPLES_CPPDEMO_COMPILE_BLEND)
      set(OGREKIT_DISABLE_ZIP FALSE CACHE BOOL "Force GZ to enabled" FORCE)
      set(OGREKIT_GENERATE_BUILTIN_RES TRUE CACHE BOOL "Set GENERATE_BUILTIN_RES to true to enable the add_template-command" FORCE)
   endif()   


You have to do this to enable the template-generator and support for compressed blend-files.

2) CMAKE-Part2 (done in you project's CMakeLists.txt)

Code: Select all
f (SAMPLES_CPPDEMO_COMPILE_BLEND)
   message(STATUS "CPPDEMO: Compile Blend-Resources!")

   add_definitions(-DOGREKIT_CPPDEMO_COMPILE_BLEND)
   
   set(BLEND_TMPL
      ./Maps.blend
      ./Momo.blend
      ./Rat.blend
   )   
   add_templates(1 GEN_BLEND_OUT Generated/gkInlineBlendFiles.inl ${BLEND_TMPL})
   LIST(APPEND SRC   ${GEN_BLEND_OUT})
endif()



With this setup all blends are packed into one file. If you want to create seperate files just split the call into three calls.

3) Load from Memory. (see Engine/Samples/CppDemo/gkGameLevel.cpp)
Here you see both versions, so you can mainly develop with external blend-files and only if you want
to embed the blends in the distribution set the certain switch cause it needs some time to compile these...
Code: Select all
#ifndef OGREKIT_CPPDEMO_COMPILE_BLEND
   gkBlendFile* mapData = gkBlendLoader::getSingleton().loadFile(gkUtils::getFile(GK_RESOURCE_MAPS), "Pickup", LEVEL_GROUP_NAME);
#else
   gkBlendFile* mapData = gkBlendLoader::getSingleton().loadFromMemory(MAPS,MAPS_SIZE,gkBlendLoader::LO_ALL_SCENES, "Pickup", LEVEL_GROUP_NAME);
#endif


As said, consider this feature for now as experimental...

Also see: http://code.google.com/p/gamekit/source/detail?r=1201

EDIT: Ok, tested now on Linux32/64 and win7 and all worked as intended.
Check out my first android-game 'Wood Games 3D' Actually not a gamekit game (not yet :D)
https://market.android.com/details?id=org.tt | twitter
dertom
 
Posts: 497
Joined: Fri Apr 01, 2011 11:56 am
Location: Germany

Re: new (experimental) feature: embedding blend-files

Postby syckodelicus » Thu Sep 27, 2012 12:20 am

-
Last edited by syckodelicus on Sat Sep 07, 2013 8:20 pm, edited 1 time in total.
syckodelicus
 
Posts: 69
Joined: Tue Dec 13, 2011 4:42 am

Re: new (experimental) feature: embedding blend-files

Postby dertom » Thu Sep 27, 2012 12:31 am

Well, that features works for everything where you usually loaded the blend-file via c++. Didn't think about how
to use these memory-blends in lua yet (but shouldn't be a problem).
Afaik at the moment you have to write c++-listeners for librocket but kizan told me today that we had some kind of
lua-wrapper that let you map clicks and such to lua-calls and he wants to provide these patches...
Check out my first android-game 'Wood Games 3D' Actually not a gamekit game (not yet :D)
https://market.android.com/details?id=org.tt | twitter
dertom
 
Posts: 497
Joined: Fri Apr 01, 2011 11:56 am
Location: Germany

Re: new (experimental) feature: embedding blend-files

Postby DiThi » Fri Sep 28, 2012 7:42 pm

I think that approach has a flaw: the entire .blend is loaded in RAM with the binary code. Once the .blend is loaded, that's wasted space. I think it's much better the approach in BGE: just append the file and add some bytes at the end with information about where the .blend starts. I did a patch 10 months ago that added a seek parameter for loadFile(), it should work (but it didn't because I patched FBT while I was using bParse). The patch would not just allow reading the .blend from the executable, but from android's APK's too.
DiThi
 
Posts: 125
Joined: Fri Sep 02, 2011 12:19 pm

Re: new (experimental) feature: embedding blend-files

Postby dertom » Sun Sep 30, 2012 9:33 am

Well, sounds goods to me. Looking forward to see it done...
Check out my first android-game 'Wood Games 3D' Actually not a gamekit game (not yet :D)
https://market.android.com/details?id=org.tt | twitter
dertom
 
Posts: 497
Joined: Fri Apr 01, 2011 11:56 am
Location: Germany

Re: new (experimental) feature: embedding blend-files

Postby rraallvv » Tue Dec 02, 2014 9:55 pm

What about compresing the blend files using encryption, and/or other compression formats like AES, I thing you can compress the uncompressed blend files with a password, without the need to add that compression format to blender too.
rraallvv
 
Posts: 15
Joined: Tue Feb 05, 2013 5:36 am

Re: new (experimental) feature: embedding blend-files

Postby dertom » Wed Dec 03, 2014 12:07 am

Yes, encrypting the blend-file shouldn't be a problem. Since there is also gzip-in fbt(which is basically the raw-reader of blend-files) you should have a look where this is done and modify that place to do the decryption before going on with reading the blender-datablocks.
Check out my first android-game 'Wood Games 3D' Actually not a gamekit game (not yet :D)
https://market.android.com/details?id=org.tt | twitter
dertom
 
Posts: 497
Joined: Fri Apr 01, 2011 11:56 am
Location: Germany

Re: new (experimental) feature: embedding blend-files

Postby rraallvv » Wed Dec 03, 2014 12:40 am

@dertom Yes gzip seems strait straightforward, also other formats shouldn't be difficult.
rraallvv
 
Posts: 15
Joined: Tue Feb 05, 2013 5:36 am

new experimental feature embedding blend files

Postby FrankgexGuru » Fri Dec 23, 2016 11:33 am

I think this would be really helpful. Also my project has a few external files which I could hide inside the resource file.
Would those files be read-only?
FrankgexGuru
 
Posts: 1
Joined: Sat Dec 17, 2016 12:01 pm
Location: Madagascar

Re: new (experimental) feature: embedding blend-files

Postby dertom » Fri Dec 23, 2016 11:56 am

Yes
Check out my first android-game 'Wood Games 3D' Actually not a gamekit game (not yet :D)
https://market.android.com/details?id=org.tt | twitter
dertom
 
Posts: 497
Joined: Fri Apr 01, 2011 11:56 am
Location: Germany


Return to Gamekit Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron