Sunday, August 9, 2015

android studio ndk with java 8

You had errors compiling the samples until I append
tasks.withType(JavaCompile) {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}

to build.gradle (app).

ctags for cocos2d-x

find . -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.m" -o -name "*.mm" -o -name "*.java" -o -name "*.py" -o -name "*.lua" > src.files

ctags -R --c++-kinds=+px --fields=+iaS --extra=+q -L src.files

Wednesday, July 29, 2015

cocos2dx, get label from layer

I could keep label reference in a member variable, but I preferred to manage it in the layer structure. So far I found the only api to get children is layer->getChildByXxx.  They all return Node*. I get Label is descendant of Node as it can be added as a child of layer. So I did this.

label->setName("label");
// add the label as a child to this layer

this->addChild(label, 1);

and 

auto label = dynamic_cast<Label*>(this->getChildByName("label"));

It works so far. Correct me if there is a better way.

Sunday, July 26, 2015

cocos2dx + opencv static linking

I spent much time to get it work.

There is a Japanese blog showing how to setup cocos2dx with opencv, but there is one missing part.
http://blog.szmake.net/archives/845

It works for OPENCV_LIB_TYPE:=SHARED. It is also the default option of opencv for android. But it fails on OPENCV_LIB_TYPE:=STATIC and there will be linking errors.

The reason is that cocos2dx uses static linking by default and overrides opencv's libs. So you need to update LOCAL_STATIC_LIBRARIES := cocos2dx_static to LOCAL_STATIC_LIBRARIES += cocos2dx_static. Now the project compiles.

Again, you need 

OpenCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=off
OPENCV_LIB_TYPE:=STATIC

include /path/to/OpenCV.mk

LOCAL_C_INCLUDES+= /path/to/OpenCV/include

LOCAL_STATIC_LIBRARIES += cocos2dx_static

Friday, July 24, 2015

blender to cocos2dx

In the doc of cocos2dx, it is mentioned that you can use blender to export fbx and convert it into c3t/c3b for sprite3D. But it does not say how. I googled around and found a few posts helpful.

http://a2dr.blogspot.com/2015/05/cocos2d-x-converting-fbx-to-c3b.html

I exported my crate, but have not tested animation yet.

Here are the steps
1. Edit your object in blender.
2. Export the selected object to fbx. Check "selected objects" and leave other options default. Some says you need select FBX 6.1 ASCII, but default FBX 7.4 binary works for me.
3. Convert fbx to c3b/c3t with the binary fbx-conv in cocos2dx tools folder.
4. Add c3b/c3t and texture to project Resources folder. This step is critical, the converted fbx or c3b/c3t do not contain texture in them. Some says you need a sub folder named Tex to hold textures, but I just put them under root of Resource.
5. Create your Sprite3D with the converted c3b files.




Tuesday, July 21, 2015

cocos2d-x + eclipse

Although android studio 1.3 rc claims support ndk natively, cocos2d-x does not support it yet. Or I did not find the right doc. I decided to fall back to eclipse+adt.

The official doc is not completed here
http://www.cocos2d-x.org/wiki/Android_with_Eclipse_Installation_and_Setup

After doing so, I got errors in eclipse. I googled, and found out I need to add libcocos2dx from "cocos2d/cocos/platform/android/java" to get rid those errors.  Go to project properties->builders, and check CDT builder.

Leave everything else default.

I do not know how to change target SDK level, e.g. to 22(lollipop) or abi. But I can do that with cmd, e.g., "cocos compile -p android -ap android-22 --app-abi armeabi-v7a".

Thursday, July 9, 2015

build opencv (3.0.0) for android form source

# Set up your NDK path. You also need java 6+, ant 1.8+, and python 2.7 according to opencv doc.
unzip ~/Downloads/opencv-3.0.0.zip
cd opencv-3.0.0/platforms
mkdir build_android_arm
cd build_android_arm
cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake $@ ../..
# If you prefer clang to gcc
# cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.6 $@ ../..
make -j 8

make install
# Till now, opencv is build, you will get a bunch of static libs by default. Everything is under build_android_arm/install

Wednesday, December 31, 2014

Put you app on jailbreak iOS devices.

It is not necessary, but I want to save $100 for now and pay it same time later.

I followed method 2 this tutorial.
http://iphonedevwiki.net/index.php/Xcode

Note:
ldid, in its git repo, does not contain some head files. I found them in "https://github.com/linusyang/opencl-test-ios". Remember update the SDK version. For me, they are xcode 6 and iOS 8.1.

game dev solution(incompleted)

I am focusing on cross-platform game dev, majorly mobile.

Graphics engine

Ogre3d.
Ogre3d is promising. It is a commercial standard lib with MIT license. There exist successful game like torchlight based on it. It starts from desktops and officially supports main stream mobile platforms. I verified android and iOS. The performance are good enough on built in samples. On my One Plus phone, everything is 60 fps. On iPad mini2, samples with 20000 triangles run at around 27 fps, while simpler samples can hit the 30 fps cap easily. Ogre 3d is the best free graphics solution so far.

You might also check irrlicht. It supports mobile in dev branch.


Physics

Input

Network

To be updated.

Wednesday, December 3, 2014

MyGUI mit now

It was LGPL. Now there is one more option other than librocket.

Wednesday, November 19, 2014

smoothmouse is so cool, making mac playable

http://smoothmouse.com/forum/
This guy fixes mac mouse lag. Now mac is playable.

Sunday, November 9, 2014

blender video editor, adding without scaling

blender video editor will try to scale and fit the output size default. To turn this off, chose image offset or image crop in strip input.

Saturday, November 8, 2014

hostname got overridden

My hostname got overridden by dhclient on archlinux. The hostname might cause some Xauthority fail. NetworkManager wiki on arch explains how to setup static host name. However, it does not work for me. keyfile setting, dhclient conf, switching to dhcpd. Nth worked. Finally I added post script in /etc/NetworkManager/dispatcher.d/ to reset my hostname manually.

Friday, October 31, 2014

hp chromebook 14 and archlinux

1. Replace a larger ssd. (It is complicated. You have to remove everything under hood to replace the ssd.)

2. Install archlinux by following the wiki.

3. 3G sim card work out of box with networkmanager its plugins.

4. Use tlp and acpid for power management.

5. Disable power button in systemd.

6. Closing lid suspends it but opening lid does not resume some usb devices with default usb auto suspend setting. Removing xhci_hcd and re-modprobing it solves the problem for me. (I added these to handler.sh of acpid but it crashed my machine. I removed them then and re-add module manually.)

Monday, August 11, 2014

mibox install/uninstall apps

./adb install <-r> blablabla

./adb shell
pm list packages|grep <your app keyword>

./adb shell am start -a android.intent.action.DELETE -d package:<your package name>

Sunday, August 3, 2014

msysgit ssh mintty hang when password required

It works find in windows cmd, but not in mintty. I change the following config.
git config --global core.askpass "git-gui--askpass"

This workaround makes git-gui prompt.

Tuesday, July 15, 2014

google play services kill battery

Setting -> privacy -> privacy guard -> setting -> show built-in apps -> long press google play services -> deny keep awake

It saves my battery.

evo 3d cdma switch between stock and custom roms

Assume you have your phone  unlocked and s-off on it.

Back to stock

Get imgs here, http://forum.xda-developers.com/showthread.php?t=1447839.

(hboot 1.40 one is broken, won't unzip, 1.58 one works fine)

relock your phone.(you need driver in window. I just use linux as everything works out of box)

adb reboot bootloader
fastboot oem lock
adb reboot bootloader (shows relocked)
put your PG86IMG.zip at the root of your sd card. Let it update.
adb reboot bootloader
fastboot flash unlocktoken Unlock_code.bin

stock kernel needs hboot 1.58, custom ones need hboot <= 1.4.

flash custom roms
flash hboot first, using PG86IMG.zip with hboot only in it.
reboot to recovery, flash roms.

kindle fire hd 7 custom recovery

1 root "Root_with_Restore_by_Bin4ry_v33"
2 flash recovery with  "Fire Flash"

No factory cable required, but you might need it in case.