Showing posts with label Game Development. Show all posts
Showing posts with label Game Development. Show all posts

Monday, June 13, 2022

How to fill Data Safety form in App Content section in Play Console when using AdMob only?

PlayStore requires Data safety form submission for all apps and violation of it can cause problem. Below is example of what to fill in the form when you use only Admob. This setting is because i use it in my apps and i only use AdMob SDK for ads.


Open Play console & login.

 

All Apps -> Select an app -> Policy  -> App Content -> Data Safety


Does your app collect or share any of the required user data types?
Yes

Is all of the user data collected by your app encrypted in transit?
Yes 

Do you provide a way for users to request that their data is deleted?
Yes


More information can be found at this link https://developers.google.com/admob/android/play-data-disclosure


Data Collected settings

- No, this collected data is not processed ephemerally
- Data collection is required (users can't turn off this data collection)
- Collected for Advertising or marketing


Data Sharing settings

Location -> Approximate location
Collected & Shared -> Advertising or marketing

 

App info and performance -> Crash logs, Diagnostics
Collected & Shared -> Advertising or marketing


App info and performance -> Diagnostics
Collected & Shared -> Advertising or marketing

 

App activity -> App interactions
Collected & Shared -> Advertising or marketing

 

Device or other IDs -> Device or other IDs
Shared -> Advertising or marketing



The user data can be deleted or prevented from targeted sharing from Android device system settings.


Got to system settings -> Google (Services & preferences) -> Ads -> Reset ad ID & opt out of Ads personalization.





Thursday, July 29, 2021

Enhanced version of BeepFX 1.12 with export WAV and raw formats.

 The original version BeepFX 1.11 which is

"Beeper sound effects cross editor for ZX Spectrum 48K. Generates sound effects using small set of parameters, also has sample support. Source code included."

available at http://shiru.untergrund.net/software.shtml.

 

Original version is limited to ZX Spectrum users only however audio effects produced using just 1bit sound can be used in modern games also. The problem is it doesn't saves audio in wav etc format. For the same i edited the source and added Export RAW & WAV formats in batch. Editing source was not easy because i couldn't install Borland Studio 2006 on both Windows and Linux. So had to install VirtualBox with windowsXP and worked inside it. The source along with the BeepFX 1.12 binary is available below link -

https://drive.google.com/file/d/1b4A5NSbx5Nye2BuPHsM_lCIxEKkgbc7K/view?usp=sharing

 

There is also online version of similar software capable of producing nice audio effects.

Link - https://zx.remysharp.com/audio

 

Tuesday, February 7, 2017

Useful Collection of Public Domain, Creative Commons, Free sounds and graphics for commercial use

As an Indie developer i required lot of free sound, music and game art for commercial use. Internet is huge but it still lacks resources with permissible license. Looking for free stuff is not bad but also not great because every work has value and in real life there is no free meal. There are very helping people who offer their work for free to ease development work of indie workers. Below are links to such useful assets.



opengameart.org

http://www.opengameart.org

A website with lots of free multimedia resources. Contains 2D, 3D, music, sound etc stuff with search and page wise browsing. It includes resources with multiple types of open licenses.



Kenney Vleugels website:

http://kenney.nl/


"We've created over 35,000 images, audio files and 3D models for you to use in your projects. Thanks to our public domain license you're even allowed to use them in commercial projects!"

220+MB of arts and sounds.




Glitch Game Art

https://www.glitchthegame.com/public-domain-game-art/

"The collaborative, web-based, massively multiplayer game Glitch began its initial private testing in 2009, opened to the public in 2010, and was shut down in 2012. It was played by more than 150,000 people and was widely hailed for its original and highly creative visual style.

The entire library of art assets from the game, has been made freely available, dedicated to the public domain. Code from the game client is included to help developers work with the assets. All of it can be downloaded and used by anyone, for any purpose. (But: use it for good.)"


Huge collection of arts. Don't miss it!



The Last Door Game Assets

http://thelastdoor.com
http://opengameart.org/content/the-last-door-season-one-complete-assets-pack

"Hey pals! We have a special gift for you! Today, in commemoration of Alan Turing, father of modern computing, all of Season One's assets will become open source! Also, we want to commemorate you, as the great community we proudly have. Thank you so much! Now you can create your own 'The Last Door' content by using the original graphics and sounds! Create videos, animate gifs or develop your won 'The Last Door' game! The assets are under Creative Commons Attribution 4.0 license, so you can spread your passion in all formats and ways."



https://kronbits.itch.io/matriax-free-assets

"Hi! I'm Davit Masia, I create a lot of graphics for fun, mockups,etc... that usually ends lost on my folders. So i decided upload and share with everybody all that stuff so people can use in their projects. Assets are free but any donation will be welcomed and motivate me to add more and more"

Around 30MB of free arts.



https://github.com/sparklinlabs/superpowers-asset-packs

https://sparklinlabs.itch.io/superpowers

"The assets in this repository are created at Sparklin Labs by Pixel-boy.
They are released under the Creative Commons Zero (CC0) license.

You can use the assets found in this repository in your own games, even commercial ones. Attribution is not required but appreciated. Placing a link to http://superpowers-html5.com/ somewhere would be awesome :)"



http://www.gameart2d.com/

"GameArt2D.com is a place to buy royalty free 2D game art assets. It contains more than 50 items, from platformer & top down tileset, side scrolling & top down character spritesheet, game GUI, space shooter asset, and many more.

Who's the guy behind this site?
I'm Zuhria Alfitra a.k.a pzUH. A lone wolf indie-gamedev-wannabe from Yogyakarta, Indonesia."



http://www.wpclipart.com/downloads.html

Huge collection of cliparts, images of animals, plants, education, shapes etc. It can be very helpful to make a derivative art. Get a simple shape and enhance it to something more beautiful. ~1GB of images. Public Domain.



https://openclipart.org/

"Unlimited Commercial Use

We try to make it clear that you may use all clipart from Openclipart even for unlimited commercial use. ... We use the Creative Commons Zero 1.0 Public Domain License every time an artist uploads a piece of clipart to Openclipart to make it clear the artist is releasing the creative work for anyone to use for any reason, even commercially."




https://github.com/saniv/free-game-art

Very good collection of collections!. This is a MUST visit page. However the repository is big and sometimes you might want to download only few folders from github. For example we want to download a CC0 or non GPL licensed assets. If you know how to use command line then a single folder can be exported from github. GUI based software can also do that.

For example you want to download https://github.com/saniv/free-game-art-unsorted/tree/master/oblique/DCGames_stuff folder but there is no option on that page. Start command shell like bash on Linux or cmd.exe on Windows. Install SVN subversion software and run this command -


Firstly copy the link

https://github.com/saniv/free-game-art-unsorted/tree/master/oblique/DCGames_stuff

Then replace tree/master by trunk. It becomes like this -

https://github.com/saniv/free-game-art-unsorted/trunk/oblique/DCGames_stuff


Now run

svn export https://github.com/saniv/free-game-art-unsorted/trunk/oblique/DCGames_stuff

This will download only the DCGames_stuff folder. If you don't like command line then try a GUI software like TortoiseSVN and export the url above as example.




https://craftpix.net/freebies/


Freebies license:

"You are permitted to use the resources in any number of personal and commercial projects for yourself or a client.
You can modify the resources according to your requirements and include them into works such as websites, applications, printed materials and others."









Textures:



Blender Texture Disc

Public domain textures pack in a CD.


Sweet home 3D texture packs

https://sourceforge.net/projects/sweethome3d/files/SweetHome3D-textures/Textures-1.1/

Contains some useful texture packs.



http://unluckystudio.com/

Owned by Sujit Yadav. He has shared some useful vector arts.



NOTE:
To get more images and textures one can use public domain or CC0 like licensed photos or videos.





3D models:


http://telias.free.fr/

"Hi there. 'Free the models' is a site dedicated to provide free content for 3d applications and 3d/game engines. The license of the content is that what you download from here is one step away from public domain. So, everything you download from here is free for any use EXCEPT it cannot be included in another free web or cd collection and it cannot be sold separately. Otherwise you can use it in your commercial game, 3d application or render work. You don't have to provide credit but It would be nice if you do. Thank you. Elias Tsiantas /Herakleion/Greece."




https://sourceforge.net/projects/sweethome3d/files/SweetHome3D-models/3DModels-1.5.1/

Lots of 3D models in sh3f format. Its like zip file and can be extracted.






Free Sounds:



http://www.99sounds.org

A very useful and huge collection of high quality audios. Below are some sound files i downloaded from this website.

[99Sounds] 99 Drum Samples
[99Sounds] Atmospherik Mekanisms
[99Sounds] Cinematic Sound Effects
99Sounds Drones
[99Sounds] InterSpace
[99Sounds] Magnetic Fields
[99Sounds]_Massamolla
[99Sounds] Percussa Toolbox by Richard Gould
[99Sounds] Project Exodus
[99Sounds] Project Pegasus
[99Sounds] Punching Percussion
99Sounds Radiophonic Atmospheres by Red Sky Lullaby
[99Sounds] Rain And Thunder
[99Sounds] Sound Design Tools
[99Sounds] The Warehouse


The files are very big and i have compressed them to very low size still maintaining quality. Due to their license restriction i cannot share those compressed ogg files. Please visit their site and download them all. Many of these audio have 96KHz sample rate. Do read the download resume technique at end of this article to download from this site because the big files many times stop resuming.



https://www.freesound.org/

Various licenses and huge collection of user submitted sounds.


www.pacdv.com/sounds/

Another good site i used.
Search "free sounds" on Google. There are many sites like this.





Get sound samples from sound pack formats

One best way to get sounds is packed, synth sound formats. Sound formats like SoundFont SF2, Downloadable Sound DLS, Patch (pat files). There are many sites which offer these files. Below are some valuable sound collections or packs.


cybernetik_mayhem_samplepack_-_by_cybernetika

Big collection of sound sample. Uncompressed size 844 MB



DrumKits from Hydrogen DrumMachine app

The drumkit files are zip files with sample configuration. Extract audio files from them and use in any DAW. Drumkits names:

3355606kit, ColomboAcousticDrumkit, HardElectro1, Synthie-1, BJA_Pacific, DeathMetal, HipHop-1, TD-7kit, Boss_DR-110, EasternHop-1, HipHop-2, Techno-1, circAfrique v4, ElectricEmpireKit, K-27_Trash_Kit, TR808909, Classic-626, ErnysPercussion, Millo-Drums_v.1, VariBreaks, Classic-808, ForzeeStereo, Millo_MultiLayered2, YamahaVintageKit




http://www.rhythm-lab.com

Many free sound samples.




Download some free Digital Audio making software and many of them offer free sound packs inside them. Linux Multimedia Studio is among them. Download tracker music software and their XI instruments which can be converted to wav or flac.






List of CC0 websites for images, wallpapers, photos

https://www.pexels.com/
https://freeimages.red/
https://stocksnap.io/
http://skitterphoto.com/
https://pixabay.com/



https://blog.wikimedia.org/2017/02/07/the-met-public-art-creative-commons/


"The Metropolitan Museum of Art makes 375,000 images of public domain art freely available under Creative Commons Zero"

As it says huge collection of museum art can be used for even commercial purpose. Deriving these arts to make new things can be very useful.




How to get more multimedia assets with lesser effort?


I spent lot time in learning programming, music, sound effects, digital arts and some more skills. Now i can make games alone. However i realized one must rather invest time in one skill they love most and Master that skill ( I love all but music is at top :) ). What about those technologies where skill is not enough to complete a work faster? There are many ways to do it. You can pay to a freelancer and get your work done. What if you don't have much money?. This is where free stuff comes to help. Some very useful links have been shared above. But now i will share techniques to get free stuff with little effort.

A video is a sequence of pictures. Therefore an open licensed movie is also bundle of same license image assets. With this idea i downloaded open source videos like BigBuckBunny. ElephantsDream, Sintel etc. There are lots of effects, textures, sounds etc in these videos. Extract data from these videos and use them wherever needed. But don't forget to follow the license honestly!.


Here are links of some public domain, Creative Commons videos:


Blender Movies:

https://www.blender.org/features/projects/


Other:

https://en.wikipedia.org/wiki/List_of_animated_films_in_the_public_domain_in_the_United_States

http://tvtropes.org/pmwiki/pmwiki.php/Main/PublicDomainAnimation

https://en.wikipedia.org/wiki/List_of_open-source_films


WARNING:


There are many resources which are public domain but can still cause copyright issues. For example old SuperMan cartoons are public domain but the SuperMan himself is not!. Please be careful for these type of things.






How to resume downloads which expires if stopped?

Many websites generate download links which expire after some time or fail if multiple connections are created. I use UGET on linux. Windows version of this software is also available. Simply add a URL and start downloading. When a new url is created go to properties of the download item and replace the old url by new url. Another way is to use KGET. Its also a Linux app. It can add mirror links. Add whenever a new link is created.


Download link:
http://ugetdm.com/ 




The links shared here can be very helpful to many indie and non-indie developers. Please submit links in comments i will add here.

Monday, May 23, 2016

Play midi files without midi driver using soundfonts on Android

Audience: Normal user
Platform:  Android


After trying to setup midi in Linux i decided to use Software Synthesis based players with custom soundfonts. Before that i will give basics of midi. Skip to APPs section if you don't want to read about midi system below.


How MIDI works?
Suppose you have memorized a pattern on piano notes and playing it on piano. Unfortunately there is no synthesizer (synth) & speaker attached. So before setting it up with synth you wrote every piano key activity on a paper or a file. You saved it like "C4 C4 D4# ... PITCH_WHEEL ... VOLUME_UP etc". Now you know the pattern, raga or rhythm of your music. Midi file is exactly this saved record!. Means there is no SOUND DATA. You write on paper that you payed a sitar or guitar. But how does that sound? To save that we really need sound file itself. That is the reason midi files are very small because there is no sound data inside mid files.

Now we know what is MID file. Now comes Synthesizer. That missing sound is produced by synth that is why the name. Midi tells a synth to play an instrument named guitar. Therefore depending upon a synth midi sound different. The big problem is that we create a music with our instruments and assume mid file will play same but if instruments are of low quality or even different in timbre may give totally different music. There are many solutions to this. Easiest solution is to produce stream music like mp3 ogg. However what is there are 1000 midi musics but very less disk space?. Its always recommended to keep midi files with original set of instruments so that in future we can reuse them for editing, remixing or other work. What we do is collect all the instruments sounds recorded and save in a bundle called SoundFont. Just like a font which contains set of Alphabets of a language.



So we have a solution.
Midi + SoundFont = Low size & preserved quality of OST (original sound track). 
More details about the topics covered can be found on wiki or tutorials on web.



APPs:

For windows, Mac related midi can be found on this link http://adamrehn.com/articles/playing-midi-soundfonts/


Android Version:
There are some apps which play midi using soundfont viz -

DroindSound, Timidity AE Player, LiveMidi, Midi Voyager, SoundFont-Midi-Player


SoundFont-Midi-Player is my own player i developed to play midi files with different soundfonts fast. It can change soundfonts easily and fast!. Do try it here -

https://play.google.com/store/apps/details?id=org.greh.soundfontmidiplayer

  • Switches between SoundFonts fast
  • Test SoundFont instruments using piano & USB MIDI Keyboard
  • Play Piano together with Midi music. However it also changes the instrument being played in Midi music.
  • Supports USB MIDI keyboard. Supports PITCH BEND messages, Pedal, Volume, Key events. AFAIK not all android apps do this. Tested M-AUDIO KeyRig 49 on Moto-G phone. Doing pitch bend on Android phone using USB Midi keyboard needs good response. I tested this app on some low end phones and it works fine.
  • Samplerates from 22050 to 96000Hz
  • Reverb & Chorus effects
  • Crystalizer audio effect. (Currently disabled)
  • FluidSynth is powerful and i think my app is the only one using latest FluidSynth 1.1.6 with GLIB Android build. Powered by Unmodified FluidSynth 1.1.6 Android Version. If modified source is used i will make the source available here.
  • More features described in PlayStore page.


Features to add:
- Hack Soundfont instrument without altering soundfont files to test midi music


Pro version i am planning to build with more useful features:
- Export as streaming music to ogg- Export self contained midi music i.e. rmid, (mod?)

Friday, March 11, 2016

Compiling FreeType (2.6.3) using Android NDK.

My setup:

  • OpenSuse Linux Leap 42.1.20151028 x86_64 (64Bit), AMD Athlon X2
  • Android NDK r10e-rc4 (64-bit). Directory name android-ndk-r10e-linux
  • Terminal / Bash shell. On Windows one needs to install binutils, development environment. Just install CodeBlocks windows or other such compiler. They contain most of needed tools.


Before starting please read setup and brief of how libpng is compiled. It is a waste if I write same thing repeatedly.

Link: http://www.ourinnovativemind.in/2016/03/how-to-compile-libpng-using-android-ndk.html


Starting steps same as libpng project:
  • Download Android NDK and extract/install to a path without containing space or special characters. If using Linux then make symbolic link to home.
  • Download FreeType package version 2.6.3
  • Create a working directory where package will be compiled. Extract package.


# AndroidBuild.sh START

#!/bin/sh
# http://www.ourinnovativemind.in
# http://www.gamesgreh.in

# Add configure options here
export CONFIGURATION_OPTIONS="--enable-static --disable-shared --with-bzip2=no"

# use custom build environment

# installation directory
export PREFIX=`pwd`/prefix

# Path of NDK. For simplicity make symlinks in home directories
export NDK=/mnt/work/SDK_IDE/android-ndk-r10e-linux/

# processor specific libraries and includes.
# Suffix for arch-???. arch-arm arch-arm64 arch-mips arch-mips64 arch-x86 arch-x86_64
export ARCH=arm

# compiler for processor
export CROSS_COMPILE=arm-linux-androideabi

# Android platform version
export PLATFORM=android-8

# GCC compiler version
export GCC_VERSION=4.8


# Getting toolchain directory inside NDK from variables set above
# Hardcoded for linux running on x86 cpu 64-Bit
export ANDROID_PREFIX=${NDK}/toolchains/$CROSS_COMPILE-$GCC_VERSION/prebuilt/linux-x86_64

# SYSROOT. usr dir i.e. usr/include, usr/lib
export SYSROOT=${NDK}/platforms/$PLATFORM/arch-$ARCH
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}

# Some compiler and binutils. More might be needed depending on source.
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib

# package configuration file save location
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

# Flags for compiler
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"

#$@
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" $CONFIGURATION_OPTIONS
make
make install

# AndroidBuild.sh END








Copy all lines above and paste in a new file AndroidBuild.sh and save. Then change the variables valid for your system. Create folder prefix or whatever name you like. Change NDK=/mnt/work/SDK_IDE/android-ndk-r10e-linux/ and compiler related values as per your system. This script copied from web can cause error due to removal of newlines for strange reasons. Ensure # is ahead of comments. Now run sh AndroidBuild.sh. It should end without errors. This will install all built files in prefix directory.

Links:
Script file http://txt.do/5vi0z or http://textuploader.com/5vi0z!



Below is output of console if you want to compare it with yours:





bindesh@linux-k2zc:/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3> sh AndroidBuild.sh

FreeType build system -- automatic system detection

The following settings are used:

platform unix
compiler /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
configuration directory ./builds/unix
configuration rules ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `make' again to build the library,
or `make refdoc' to build the API reference (this needs python >= 2.6).

cd builds/unix; \
./configure '--host=arm-linux-androideabi' '--with-sysroot=/mnt/work/SDK_IDE/android-ndk-r10e-linux//platforms/android-8/arch-arm' '--prefix=/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix' '--enable-static' '--disable-shared' '--with-bzip2=no'
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking for arm-linux-androideabi-gcc... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes
checking for /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.24... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
checking if the linker (/mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm
checking the name lister (/mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r
checking for arm-linux-androideabi-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for arm-linux-androideabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-androideabi-ar... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking for archiver @FILE support... @
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for arm-linux-androideabi-ranlib... /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
checking for gawk... gawk
checking command to parse /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm output from /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok
checking for sysroot... /mnt/work/SDK_IDE/android-ndk-r10e-linux//platforms/android-8/arch-arm
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for arm-linux-androideabi-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
checking if /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
checking if /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag -static works... yes
checking if /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes
checking if /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
checking whether the /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for x86_64-pc-linux-gnu-gcc... no
checking for gcc... gcc
checking for gcc... (cached) gcc
checking for suffix of native executables...
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking size of int... 4
checking size of long... 4
checking whether cpp computation of bit length in ftconfig.in works... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... no
checking for working mmap... no
checking for memcpy... yes
checking for memmove... yes
checking gcc compiler flag -pedantic to assure ANSI C works correctly... ok, add it to XX_ANSIFLAGS
checking gcc compiler flag -ansi to assure ANSI C works correctly... ok, add it to XX_ANSIFLAGS
checking for ZLIB... yes
checking for LIBPNG... yes
checking for HARFBUZZ... yes
configure: creating ./config.status
config.status: creating unix-cc.mk
config.status: creating unix-def.mk
config.status: creating ftconfig.h
config.status: executing libtool commands
configure:

Library configuration:
external zlib: yes (pkg-config)
bzip2: no
libpng: yes (pkg-config)
harfbuzz: yes (pkg-config)

make: Nothing to be done for 'unix'.
make: Nothing to be done for 'all'.
rm -rf /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2
rm -f /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/ft2build.h
/usr/bin/mkdir -p /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/pkgconfig \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/freetype/config \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/bin \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/share/aclocal \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/share/man/man1
./builds/unix/libtool --mode=install /usr/bin/install -c \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/objs/libfreetype.la /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib
libtool: install: /usr/bin/install -c /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/objs/.libs/libfreetype.lai /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/libfreetype.la
libtool: install: /usr/bin/install -c /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/objs/.libs/libfreetype.a /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/libfreetype.a
libtool: install: chmod 644 /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/libfreetype.a
libtool: install: /mnt/work/SDK_IDE/android-ndk-r10e-linux//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/libfreetype.a
for P in /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/tttables.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftoutln.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftstroke.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/t1tables.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/fterrors.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftcid.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftbitmap.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftmodapi.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftsystem.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftcffdrv.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftautoh.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftsynth.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftlcdfil.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftpfr.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftsizes.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftrender.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftlzw.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftfntfmt.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftglyph.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftlist.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftincrem.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftchapters.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftbdf.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftcache.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ttnameid.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftgzip.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftbzip2.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftmac.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/freetype.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftwinfnt.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/fttypes.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftotval.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftbbox.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftmm.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftadvanc.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftttdrv.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftmoderr.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftgasp.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftgxval.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftsnames.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/tttags.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ttunpat.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/fterrdef.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/fttrigon.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/ftimage.h ; do \
/usr/bin/install -c -m 644 \
$P /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/freetype ; \
done
for P in /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/config/ftstdlib.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/config/ftconfig.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/config/ftmodule.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/config/ftoption.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/freetype/config/ftheader.h /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/objs/ftmodule.h ; do \
/usr/bin/install -c -m 644 \
$P /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/freetype/config ; \
done
/usr/bin/install -c -m 644 /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/include/ft2build.h \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/ft2build.h
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/freetype/config/ftconfig.h
/usr/bin/install -c -m 644 /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/objs/ftmodule.h \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/include/freetype2/freetype/config/ftmodule.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/lib/pkgconfig/freetype2.pc
/usr/bin/install -c -m 644 /mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/docs/freetype-config.1 \
/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3/prefix/share/man/man1/freetype-config.1
bindesh@linux-k2zc:/mnt/work/work/programming/Android/00_libraries/freetype/freetype-2.6.3>

Thursday, March 10, 2016

How to compile libpng using Android NDK?

To build libpng 1.6.28 with Android Studio 2.2 based tools like CMake, Ninja please look at this article.

http://www.ourinnovativemind.in/2017/02/new-building-libpng-1628-using-android.html



Below method uses ndk-build to build libpng.


This page is for you if want to compile libpng for Android or just got a warning mail from Google PlayStore regading libpng vulnerability issue of old versions. "Google Play warning: You are using vulnerable version of libpng". This article/tutorial is about compiling libpng 1..6.19 for Android.



My setup:
  • OpenSuse Linux Leap 42.1.20151028 x86_64 (64Bit), AMD Athlon X2
  • Android NDK r10e-rc4 (64-bit). Directory name android-ndk-r10e-linux
  • Terminal / Bash shell. On Windows one needs to install binutils, development environment. Just install CodeBlocks windows or other such compiler. They contain most of needed tools.


Because my setup is Linux with disk limit due to 128GB SSD i have not installed 2 set of tools for each OS i.e. Linux and Windows. However it will not take more than minute to change the scripts to Windows. Most of my scripts are hard-coded for 64Bit Linux. Kindly change the variables to your NDK to let the scripts run bug free. Or for a person who just needs Android.mk file simply copy the content from end of this article.


Starting steps:
  • Download Android NDK and extract/install to a path without containing space or special characters. If using Linux then make symbolic link to home.
  • Download libpng version 1.6.19 (November 12, 2015)
  • Create a working directory where libpng will be compiled. Extract libpng.

Extracted libpng contains many files like README, TODO etc. One should read them as they contain important information. Before compiling libpng must be made aware of where compiler, other compiler related tools, headers and objects (compiled code) are saved. This information is collected by configure script. If interested open “configure” file in text editor and scroll to end. There are below lines -



# Assembler program.
AS=$lt_AS


# DLL creation program.
DLLTOOL=$lt_DLLTOOL

# Object dumper program.
OBJDUMP=$lt_OBJDUMP

# Whether or not to build shared libraries.
build_libtool_libs=$enable_shared

# The PATH separator for the build system.
PATH_SEPARATOR=$lt_PATH_SEPARATOR

# The host system.
host_alias=$host_alias
host=$host
host_os=$host_os



SED, GREP, FGREP, ECHO etc near end of file. These are the stuff configure script requires to build the final Makefile. We have to provide these things to configure script. After I started building libraries like libpng, FreeType, ImageMagick, GraphicsMagick etc for Android I collected some scripts from various sources like stackoverflow and build this script. It contains some hard-coded values but that takes minute to change as per system.


If project is small and contains few files we can build source without configure script or even Makefile. It is recommended that we understand the basics of this system. For example look at scripts directory there are many makefile.PLATFORM files where PLATFORM = msys, linux etc. We can use those makefiles to build a working Makefile or get information about build flags etc. But that's not easier than configure script.


Android Script

# AndroidBuild.sh START
#!/bin/sh
# remove flag for non neon ARM processors.

export HAS_NEON="--enable-arm-neon"
export CONFIGURATION_OPTIONS="--disable-shared $HAS_NEON"

# use custom build environment
# installation directory
export PREFIX=`pwd`/prefix

# Path of NDK. For simplicity make symlinks in home directories
export NDK=/mnt/work/SDK_IDE/android-ndk-r10e-linux/

#export NDK=/home/bindesh/bin/ndk (SYMLINK)
# processor specific libraries and includes.
# Suffix for arch-???. arch-arm arch-arm64 arch-mips arch-mips64 arch-x86 arch-x86_64
export ARCH=arm
 

# compiler for processor
export CROSS_COMPILE=arm-linux-androideabi

# Android platform version
export PLATFORM=android-8

# GCC compiler version
export GCC_VERSION=4.8

# Getting toolchain directory inside NDK from variables set above
# Hardcoded for linux running on x86 cpu 64-Bit
export ANDROID_PREFIX=${NDK}/toolchains/$CROSS_COMPILE-$GCC_VERSION/prebuilt/linux-x86_64

# SYSROOT. usr dir i.e. usr/include, usr/lib
export SYSROOT=${NDK}/platforms/$PLATFORM/arch-$ARCH
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}

# Some compiler and binutils. More might be needed depending on source.
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib

# package configuration file save location
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

# Flags for compiler
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"

export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"

./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" $CONFIGURATION_OPTIONS

make
make install
 

# AndroidBuild.sh END



Copy all lines above and paste in a new file AndroidBuild.sh and save. Then change the variables valid for your system. Create folder prefix or whatever name you like. Change NDK=/mnt/work/SDK_IDE/android-ndk-r10e-linux/ and compiler related values as per your system. This script copied from web can cause error due to removal of newlines for strange reasons. Ensure # is ahead of comments.

Now run sh AndroidBuild.sh. It should end without errors. This will install all built files in prefix directory. Now we can copy libpng16.a renamed to libpng.a and headers directory.

Links: Script file http://txt.do/5vb70 Or http://textuploader.com/5vb70


Above script is common to most of tasks and is best for building most of C libraries. To add C++support more variables are needed. Some possible errors:

  • Error in running compiler tools. This can be due to incorrect final paths of build tools. Look at config.log and cross check if resulting paths are correct.
  • Error in finding libraries. This can be because of wrong names of libraries and -l parameter to compiler. Ensure path and names are correct. Configure script runs a lot of tests which tests each used libraries with a small sample code. Check the results of these sample codes in config.log.

If everything seems not working then ensure the installation of tools is correct and they do their job. Make simple programs and test them. Test NDK with Android Studio or Eclipse. Do these types of tests. I myself have spent time frustrated with these types of problems. In Linux i even suffered problems like executable flag of executable files were removed due to unknown reason!.



Android.mk


LOCAL_PATH := $(call my-dir)

# $(call my-dir) return path of this Android.mk directory

PNG_SRC_PATH    :=
INC_PNG                := $(LOCAL_PATH)/


include $(CLEAR_VARS)

LOCAL_MODULE    := libpng
LOCAL_CFLAGS    :=
LOCAL_CPPFLAGS  := ${LOCAL_CFLAGS}

LOCAL_C_INCLUDES  :=  \
    ${INC_PNG} \
       
LOCAL_SRC_FILES := \
    ${PNG_SRC_PATH}pngerror.c \
    ${PNG_SRC_PATH}pngwio.c \
    ${PNG_SRC_PATH}pngwrite.c \
    ${PNG_SRC_PATH}pngwutil.c \
    ${PNG_SRC_PATH}pngwtran.c \
    ${PNG_SRC_PATH}pngset.c \
    ${PNG_SRC_PATH}pngtrans.c \
    ${PNG_SRC_PATH}example.c \
    ${PNG_SRC_PATH}png.c \
    ${PNG_SRC_PATH}pngrtran.c \
    ${PNG_SRC_PATH}pngmem.c \
    ${PNG_SRC_PATH}pngpread.c \
    ${PNG_SRC_PATH}pngrutil.c \
    ${PNG_SRC_PATH}pngrio.c \
    ${PNG_SRC_PATH}pngget.c \
    ${PNG_SRC_PATH}pngread.c
   
   
   

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)

  LOCAL_SRC_FILES += ${PNG_SRC_PATH}arm/arm_init.c
  LOCAL_SRC_FILES += ${PNG_SRC_PATH}arm/filter_neon.S
  LOCAL_SRC_FILES += ${PNG_SRC_PATH}arm/filter_neon_intrinsics.c
endif


LOCAL_LDLIBS    := -llog -L../lib
# -lz -lm

include $(BUILD_STATIC_LIBRARY)

Monday, December 7, 2015

BVHUtil - A multi-platform BVH MoCap utility (Like BVH Hacker)


Update 28-Feb-2017:

Due to lack of fund, time and reason i quit gaming this project was suspended. However even after ~1.5yrs no BVH viewer on android exists. I thought someone might make one. So may be i will try to re-build a simple bvh viewer to keep an option for some users. The download link to PlayStore is dead because i disabled the BVH Viewer app but many apk sites maintain a copy of it. Please download from these sites. I will update link if i could.




I am working on 3d games like Tekken 3, Dear Or Alive using unity3d and some other engines/libraries. Soon i started working got stuck in making models and their animations. While making 2d games i could make graphics alone but in this case its way more harder and time consuming. I make human models using OpenSource software MakeHuman and then import them into Blender 3D to do rest of work. However there is a method called Animation Re-targeting which can use external animation to be applied to acompatible model. A compatible model means they must have same skeletal architecture no matter what design of mesh they have. Fortunately one can use BVH MoCap files. Many of them are freely downloadable. Carnegie-Mellon Graphics Lab Motion Capture Database offers lots of free BVH files.



There is already an editor called BVH Hacker which can do most of tasks anyone needs. However i tried to find, as much as i can, a software which can edit REST POSE of BVH file without affecting the motion data. I could not find any & there were methods which were time consuming and not for anyone who doesn't know how to use Blender3D. So i made Rest Pose editor* myself and it works well.


Details:
However i am using it for personal use and willing to release it on stores. At present BVHUtil works on its own format which is nothing but extension of BVH replacing Euler rotations channels by Quaternion.


Features:
- BVH viewer with interpolation of animation.


WIP features for updates to come:
- Frame control for viewing. View any frame like seeking a video frame.
- Remove frames
- Edit Frame animation data i.e. rotation of joints/bones.
- Export* interpolated frames to enhance animation smoothness within file.
- Export* any part of skeleton. E.g. export right hand as bvh.
- Edit rest pose* without affecting a single animation frame. This feature is rare and i will take some time to make it available. This feature is complete and ready but is not exposed in UI. More info at bottom.
- Animation re-targeting to embed animation in a model? I myself need this and will make it anyhow.


* mark is for features which are available in my own BVH2 format. This is extension of bvh format where Euler rotations are replaced by Quaternions. Once i make precise port of these features to bvh format i will update this app. * features will be available once i finish BVH2 to BVH export. BVH2 format name can probably be changed with something else.


Download:
I have only released Android version yet. PC version will be released after i am done with mobile builds.


https://play.google.com/store/apps/details?id=org.greh.bvhutil


Key words:
Edit Mocap BVH rest pose, rest pose editor, android bvh viewer, android mocap viewer

Thursday, November 7, 2013

Differentiate rotation and pinch gesture





For guessing gestures manually in programming i have found by logging how IOS sdk does it internally. As we can see in the below picture -





















Gesture is decided by first motion of fingers. But in many cases a blended approach can also be used. Means on X-axis motion doing rotation and Y-axis motion doing Pinch.

There is nothing more to write because other methods can use filtering and algorithm to smartly differentiate gestures.  Like managing a Rectangular band over the two touch points and calculating the motion of fingers strictly inside rectangular boundaries.

We know, if we don't use first motion, then there will be delay in gesture recognition.


Automatic Rectangle-Rectangle collision and response using sweep

I love side-scrolling platformers and have built my game engine, GrehGameEngine, focusing it. We all know first layer of collision detection is always rectangle based because its faster than other geometrical shapes.

While developing games I tried to Google as much as I can regarding rectangle collisions. But I couldn't find single-complete algorithm for finding collisions and deciding response. So after many models and calculations in 2012 I developed this method. It is actually a sweep collision method. So will be helpful for most of game developers.

Using the following illustration I will describe the method.



We have a player R1 and a platform R2. R1 has to move dx,dy from START (x1,y1) and reach STOP ( x2,y2 ). But collision with R2 must stop it to remain at EXPECTED (x3,y3).

Here we have constructed a situation, but in reality we don't know where expected would be. This is what this method is for. Below is the step-wise approach to calculate x3,y3.


STEP #1:
Get the distance between R1 & R2 and also check which projection axis already collides. In our case, no axis collides. What does this mean? Look from any sides around these rectangles they will not be overlapping. They are separate.

Distance has to be calculated between their sides which face each other. In our case R1.right and R2.left face each other.

DistX = R2.left – R1.right , DistY = R2.top – R1.bottom



STEP #2:
Convert the distance into rational values by dividing them with their DELTA movement values. In our case it will be.

distX_percent = DistX / dx , distY_percent = DistY / dy
NOTE: handle divide by zero dx = 0, dy = 0 before it.

Why rational / percent?, have a look at this -



























STEP #3:
Check which projections were colliding. If both projections were already colliding then R1 and R2 are already collided, STUCK situation!, what is the point of moving dx,dy now. Figure out how to avoid this stuck state!, it happens when R1 is created overlapped with R2 OR a failed last collision response which should not happen.


STEP #4:
Now the final step. Look again at figure 2, and then figure 1. Assume Point A of figure one as EXPECTED position in figure 1. Means db = DistX, dp = DistY and dh = EXPECTED delta move.

Imagine R1 is slowly moving towards R2 with dx,dy and collides with R2 at expected. This is visual!, how to get it by maths?. The answer is already in our hands. We have to test which projection satisfies collision in both axis.


We take the DistX_percent values first and apply the formula dp% = db% = dh%.

new_DistX = DistX_percent * DX. (Its not needed because new_DistX = DistX already)
new_DistY = DistX_percent * DY. ( db% = dp%, getting db% of DY ).

Translate R1 to the new values and check if it collides with R2. If collides then expectedXY = new_DistXY. If it doesn't collides. Try DistY_percent to get new_DistX.

new_DistY= DistY_percent * DY. (Its not needed because new_DistY = DistY already)
new_DistX= DistY_percent * DX. ( db% = dp%, get dp% of DX ).

Again translate R1 to these new X,Y, if it collides with R2 then expectedXY = new_DistXY. If it doesn't collides. This means there is no collision in this delta move.



Here is the method in action. Its HTML5 version which can easily be converted to C++/Java etc. Whole code can be found inside the JavaScript section of this html file.

Download Or Open rect-collision.html


In the above demo, Green rectangle is R1 (start), Blue rectangle is platform R2, Brown is STOP and red is the expected result rectangle. Left click / Drag to move STOP position and Right click to set START position.



Cleaner illustration:














Figure 3


In above figure, we can see the distance between R1 (green) and R2 (blue). How do we calculate EXPECTED position i.e. DistH.

We take DistX as our dx delta move and find dy using db% = dp% relation.
new_DX = DistX% * DX
new_DY = DistX% * DY

Now translate R1 to this new position and check collision If it collides then this is our DistH. Otherwise we take DistY as dy delta move and find dx using distY.
new_DX = DistY% * DX
new_DY = DistY% * DY

Then same collision check again. if collides we get DistH => new_DX, new_DY.
If it doesn't collide again then the DX,DY delta move is considered safe delta move without collision.


Below is HTML5 collision in action. Mouse input was getting lost so i coded rect movement around corners. Green is start. Blue is obstacle. Dark red is target position where green has to reach. Light red is auto-calculated position if collided.

Saturday, July 6, 2013

Power of Two image resizer

This java app automatically resizes images to closest power of two making them suitable for OpenGL/GLES. Useful for mobile developers using OpenGLES.


Usage: java -jar ClosestPOTResizer.jar in.png OR in.jpg


Its just 7KB app. Runs on java 1.2 or above. The download package contains source code of the app and inside distributable folder the executable jar is present.

Download: ClosestPOTResizer.7z


Source code:

/* ##################################################### */

package closestpotresizer;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
import javax.imageio.stream.ImageOutputStream;

/**
 *
 * @author Bindesh Kumar Singh
 * @contact bindeshkumarsingh@gmail.com
 * @website http://www.ourinnovativemind.in
 */

public class ClosestPOTResizer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
//        System.out.println("" + POTResizer.getClosestPOT(500, false));
//        System.out.println("" + POTResizer.getClosestPOT(500, true));
        try {
            if (args.length < 1) {
                System.out.println("Usage: java -jar ClosestPOTResizer.jar \"in.png OR in.jpg\"");
                return;
            }
            POTResizer r = new POTResizer();
            r.resize(args[0]);
        } catch (Exception ex) {
            Logger.getLogger(ClosestPOTResizer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

class POTResizer {
   
    public void resize(final String infile) {
        try {
            BufferedImage img = ImageIO.read(new FileInputStream(infile));
           
            // get extension
            int len = infile.length();
            String extension = infile.substring( infile.lastIndexOf('.') + 1, len );
            String outfile = "POT_" + infile;
           
            // get current size
            int w = img.getWidth();
            int h = img.getHeight();

            // closest POT
            int potW = getClosestPOT(w, true);
            int potH = getClosestPOT(h, true);

            // resize to POT
            img = getScaled(img, potW, potH);

            // save resized image
            storeImage(img, new File(outfile), extension, 0.9f);

        } catch (Exception exp) {
            Logger.getLogger(POTResizer.class.getName()).log(Level.SEVERE, null, exp);
        }
    }

    public boolean storeImage(BufferedImage bi, File outputFile, String extension, float quality) {
        // e.g. storeImage( image, new File( "file.png" ), BufferedImageUtil.IMAGETYPE_PNG, 0.8f);
        try {
            //reconstruct folder structure for image file output
            if (outputFile.getParentFile() != null && !outputFile.getParentFile().exists()) {
                outputFile.getParentFile().mkdirs();
            }
            if (outputFile.exists()) {
                outputFile.delete();
            }
            //get image file suffix
            //get registry ImageWriter for specified image suffix
            // BufferedImageUtil.IMAGETYPE_PNG, 0.8f)
            Iterator writers = ImageIO.getImageWritersBySuffix(extension);
            ImageWriter imageWriter = (ImageWriter) writers.next();
            //set image output params
            ImageWriteParam params = new JPEGImageWriteParam(null);
            params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
            params.setCompressionQuality(quality);
            params.setProgressiveMode(javax.imageio.ImageWriteParam.MODE_DISABLED);
            params.setDestinationType(new ImageTypeSpecifier(IndexColorModel
                    .getRGBdefault(), IndexColorModel.getRGBdefault()
                    .createCompatibleSampleModel(16, 16)));
            //writer image to file
            ImageOutputStream imageOutputStream = ImageIO
                    .createImageOutputStream(outputFile);
            imageWriter.setOutput(imageOutputStream);
            imageWriter.write(null, new IIOImage(bi, null, null), params);
            imageOutputStream.close();
            imageWriter.dispose();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    static public int getClosestPOT(int number, boolean higher) {
        int ret = 2;
        while (ret < number) {
            ret *= 2;
            if (!higher && ret > number) {
                ret /= 2;
                return ret;
            }
        }
        return ret;
    }

    static public BufferedImage getScaled(BufferedImage img,
            int targetWidth,
            int targetHeight) {

        BufferedImage scaledImage = new BufferedImage(
                targetWidth, targetHeight, img.getType());// BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = scaledImage.createGraphics();
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.drawImage(img, 0, 0, targetWidth - 1, targetHeight - 1, null);
        return scaledImage;
    }
   
   
}

/* ################################################### */



TAGS:
Power of two image converter resizer POT

Monday, July 1, 2013

Make sprite sheet from frame files with auto-crop and merge.

My another tool for GrehGameEngine Tools Collection.

It takes all user provided images then auto-crops them and merges to build a sprite sheet. It also exports frame information file containing frames information in % of sheet size.

USAGE:
java -jar SpriteSheetFromPNGs.jar "1st.png" "2nd.png" "3rd.png" "#.png" ...  more files, file names are not fixed you can use any png files.

OUTPUT:
"sheet.png" with all images cropped and merged. "sheet.png.conf" with frames position and size data relative to "sheet.png". i.e. x, y, w, h of frames in % of sheet's size.


Download:
SpriteSheetFromPNGs.7z


Requirements:
It is a java app and needs Java 5.


Tags: sprite, sprite sheet,  auto crop and merge