To work with resources in Android through ndk – C ++ there are several options:
Use access to the resources of the apk file using AssetManager
Download resources from the Internet and extract them in the application directory, used by standard methods C ++
Combined method – to get access to the archive with resources apk through AssetManager, unpack them in the application directory, then use with standard C ++ techniques
Next, I will describe the combination of access methods using the game engine Flame Steel Engine.
When using SDL can facilitate access to the resources of the apk, library wraps the calls to AssetManager, offering a similar interface to the stdio (fopen, fread, fclose, etc.)
After the file download from the apk to the buffer, you need to change the current working directory to the application directory, it is available to the application without additional permits. For this we use a wrapper on SDL:
Next, write down the file from the clipboard to the current working directory using fopen, fwrite, fclose. After the archive will be available in the directory for C ++, unpack it. Archives zip can extract a combination of two libraries – minizip and zlib, the first structure can work with files, the second decompresses the data.
For more control, simplicity, portability, I realized own archive format with zero compression called FSChest (Flame Steel Chest). This format supports the directory archiving files, and unpacking; Support folder hierarchy is missing, can work only with files.
Connecting the library header FSChest, unpack the archive:
Let’s say we need to implement a simple bytecode interpreter, which approach to the implementation of this task to choose?
Stack data structure provides an opportunity to implement a simple bytecode machine. Features and realization of machines stack described in numerous articles of Western and domestic Internet, just mention that the Java virtual machine is an example of a stack machine.
The principle of operation of the machine is simple, the input is a program containing data and opcodes (opcodes), using the stack manipulations performed realization of necessary operations. Consider the example of the program bytecode my stack machine:
At the output we get the string “Hello StackVM”. Stack machine reads the program from left to right, character by character by uploading data onto the stack, with the appearance of the opcode to symbol – performs implementation team using the stack.
An example of the implementation of the stack machine to nodejs:
Reverse polish notation (RPN)
Also, stacking machine is easy to use for the implementation of calculators, this is done using RPN (postfix notation).
An example of a conventional infix:
Converted into RPN:
To calculate postfix notation use a stack machine:
2 – at the top of the stack (stack 2)
2 – on top of the stack (Stack: 2.2)
* – get the top of the stack twice, multiply the result is sent to the top of the stack (stack of 4)
3 – on top of the stack (the stack 4, 3)
4 – on top of the stack (a stack of 4, 3, 4)
* – get the top of the stack twice, multiply the result is sent to the top of the stack (stack of 4, 12)
+ – get the top of the stack twice, add up the results, go to the top of the stack (stack 16)
As you can see – the result of operations 16 remains on the stack, it can be derived by implementing opcodes stack printing, for example:
П – print start opcode stack, n – opcode closure print stack and sending the final line in rendering.
For conversion from arithmetic operations in postfix infix used Edsger Dijkstra algorithm called “Shunting-yard algorithm”. An example implementation can be found above or in the project repository on the machine stack nodejs below.
Algorithm goes on to describe skeletal animation, as its implementation in the game engine Flame Steel Engine.
Because the algorithm is the most complex of all that I implemented, in the notes on the process of development can occur errors. In the last article of this algorithm, I made a mistake, bone mass is passed to the shader for each mesh separately, rather than for the entire model.
To work correctly you need to model the algorithm contained a link bones together (graph). Imagine a situation in which both played two animations – jumping and raising his right hand. Animation jump should raise the model on the Y axis, the animation show of hands should take this into account and to rise along with the model in a jump, otherwise the hand will remain on its own on the spot.
Describe the relationship of nodes in this case – the body contains a hand. In developing the algorithm will produce bone graph reading, all animations will be included with the correct connections. The memory model graph is stored separately from all animations, just to reflect the connectivity model bones.
Interpolation on CPU
In the last article, I described the principle of rendering skeletal animation – “transformation matrix are transferred from the CPU to the shader when rendering each frame.”
Rendering each frame is processed on the CPU, for each bone mesh engine receives a final transformation matrix by interpolation position, rotation, zoom. During the final interpolation bone matrix produced by extending the tree nodes for all active nodes animations, final matrix is multiplied to the parent, is then sent to the rendering in the vertex shader.
For interpolation position and increasing use of the vector, quaternions are used to rotate because they are very easy interpolated (SLERP) in contrast to the Euler angles, as they are very easy to imagine a transformation matrix.
How to simplify the implementation of
To simplify debugging work vertex shader, I added the simulation work on the vertex shader CPU using FSGLOGLNEWAGERENDERER_CPU_BASED_VERTEX_MODS_ENABLED macro. At NVIDIA graphics cards manufacturer has a tool for debugging the shader code Nsight, perhaps she, too, can simplify the development of complex algorithms vertex / pixel shaders, however, test the functionality I have not had the opportunity, enough simulation on the CPU.
In the next article I plan to describe the mixing of multiple animations, supplement to fill the remaining gaps.
At first I wanted to use the popular ChaiScript library, Duktape or include the Lua, but due to dependencies and possible difficulties in porting to different platforms, it was decided to find a simple, minimal but powerful MIT JS lib, meets these criteria Tiny-JS. The only disadvantage of this library in the absence of support/development from the developer, but it is fairly simple code that allows you to take the support, if required.
In this article I will describe the build process of C++ SDL iOS app on Linux, resign ipa file without a paid subscription to Apple Developer Program and installation on a clean device (iPad) via macOS without Jailbreak.
At this point you need to download Xcode dmg and copy ios sdk to build cctools-port. This stage is easier to pass on MacOS, simply copy of Xcode installed sdk necessary files. After successful build, the terminal will show a path to crosscompiler bin directory.
You can then proceed to the build of SDL applications for iOS. Open cmake and add the necessary changes for C ++ build code:
In my case, SDL library, SDL_Image, SDL_mixer compiled in Xcode on macOS advance for static linking; Frameworks copied from Xcode. Also added libclang_rt.ios.a library, which includes specific runtime iOS calls, e.g. isOSVersionAtLeast. Enabled macros for working with OpenGL ES, disables unsupported features in the mobile platforms, similar to Android.
After the resolving build problems, you must get a binary compiled for the arm. Next, I will describe binary installation and run on the device without Jailbreak.
On macOS make Xcode installation, register on Apple’s website, without having to pay for the development of the program. Add account in Xcode -> Preferences -> Accounts, create an empty application and build for a real device. During assembly, device will be added to a free developer account. After building and running, you need to make an archive of the build, for this select Generic iOS Device and Product -> Archive. By the end of the archive build, copy files called embedded.mobileprovision, PkgInfo. From the build log on the device, find the line codesign with the correct key signature, the path to the file with the extension of entitlements app.xcent, copy it.
Copy the .app from the archive, replace binary in the archive created by cross-compiler in Linux (eg SpaceJaguar.app/SpaceJaguar), further adding to the .app necessary resources to check the safety and PkgInfo embedded.mobileprovision in the .app file from the archive, copy again if needed. Resign .app using codesign command – codesign requires the input argument of the key for the sign, the path to the entitlements file (can be renamed with the extension .plist)
After resign create Payload folder, move to the folder with the .app extension, create a zip file with the Payload directory, rename the file with the extension .ipa. After that, in Xcode, open the list of devices and Drag’n’Drop ipa in the list of device applications; Installation via Apple Configurator 2 for this process does not work. If resign made correctly, a new application is installed with correct binary on iOS device (e.g. iPad) with 7 day certificate for testing period that is sufficient.
The fourth issue of not very consistent category about games Games Vision.
World Of Horror (Crossplatform, panstasz) – roguelike game in the style of early access uh what? Text horror adventure with RPG elements? Graphically, the game resembles the ’80s, is given a choice of a 1-bit or 2-bit palette, with variations.
Controls seems strange at first, but eventually you get used to, because of the fact it roguelike to surprise and be original in every aspect. Stunning chiptune music, Japanese aesthetics of the late 80’s, inspired by the works of visual Junji Ito, strange stories in the style of Lovecraft, almost infinite replayability.
What else do you need?
Eternal Castle [REMASTERED] (PC, Daniele Vicinanzo, Giulio Perrone, Leonard Menchiari) – a modern style game Another World, Flashback. Palette specifically reduced to CGA colors. Description of the game to start with a legend of its creation: Approximately in 1987 one of the developers of children’s Eternal Castle saw the game and remember it for a lifetime, as a result of the game did not come out, but the source was able to find and recover in 2019, releasing an improved version. However, the description on Steam contains information that is remaster bestseller in 1987, but that year a game with this name did not come out, that’s true and what’s not for you to decide.
The graphics and gameplay are clearly sharpened for nostalgia of the good old days, very often there are times when it seems that the game hung, but a fact, you just need to press a button or move the action to see what is happening on the screen. This trick gives rise to a feeling of embarrassment and loss of control, which is often used in older games, what to reject completely modern.
Death & Taxes (PC, Placeholder Gameworks) – Have you ever dreamed to work as a judge and executioner at the same face? Love the long black robes, scythes, crunching his knuckles? Then this is the perfect game for you because “It is impossible to avoid the only two things – death and taxes.”
This is a unique simulator of the angel of death, will choose who should live and who will die. In addition to the killings, or gifts of life, you can read news feeds to your smartphone, see how choices affect peace on earth. You also need to communicate with supervisor named Fate, buy items, and all utensils for the table, for example, I bought a brutal cactus. Do not forget to talk to the mirror, very exciting. Among the few drawbacks is worth noting the overall intimacy of what is happening within a few days of playing the game becomes a bit monotonous.