ZBrush Skull Sculpting Study

This last Christmas, my girlfriend bought me ZBrush Core + Wacom Tablet bundle so I’ve finally decided to learn ZBrush!
I’ve never sculpted before so to start I’ve decided to go with studying the skull main features.
Here’s the result of two weeks of studying.
Please enjoy!

Real-time shader recompiling

I’ve added real-time shader recompiling in my 3D engine.
It also returns if the shader has been successfully compiled and if not, it returns the line of the error and what the problem could be.
In the future, I’d like to incorporate my code editor in my Scene Editor so I don’t have to rely anymore on external edtiros (in this video I use Visual Studio Code).

Android OpenGL ES 2.0 Dynamic Lighting (and OBJ Parser/Loader

I’ve started porting my little 3D real-time engine to Android.
I like to keep the code as portable as possible so I tend to reduce at minum the need of libraries.
I only had to modify how I upload vertex data to the GPU because OpenGL ES 2.0 doesn’t support Vertex Array Object (VAO).
And of course I had to rewrite the shaders in GLSL 1.20 (OpenGL ES 2.0 compatible).
Here’s a simple dynamic lighting test using diffuse lighting:

Developing on PSVita

Back in 2014, Sony let user develop on PS Vita using Unity or a more low-level way using C# and the PSM SDK.
Of course, I’ve decided to go with the second option and it was so much fun to try to understand how to get access to the GPU of one of the best mobile console ever created!

iOS OpenGL ES 2.0 drawing and animation

Once I had to develop an application for my job that let the user draw his/her signature and then watching it animate to become straight lines.
The Funny thing at that time was that I had never touched iOS!
So to speed things up I coded all the logic in C++ and then wrap it in C to be able to call it from Objective-C to reduce at minimum the coding in Objective-C.
It worked great!

My own code editor

I’ve started coding my own code editor to include in my Shader Editor I’m currently developing using my little 3D real-time engine: the Mist Engine, cool name isn’t it? 😀
I’ve decided to use Qt Framework because it’s free and most important, it works pretty much on any platform.
I’ve been able to develop and build the thing both on my Windows PC and my MacBook without much of a fuss!
At the time of this writing, it supports:

  • line numbers
  • syntax highlight for multiple languages (C++ and GLSL are the ones I care for)
  • Some sort of auto-indentation when typing
  • Tab indentation

Simple JNI Example with Eclipse CDT

1. Create a new Java Project and create a new class called HelloJNI.java and put this code inside:

public class HelloJNI {

    static {
        System.load(“C:/libHelloJNIC++.dll”);
    }
    
    public native void displayMessage();
    
    public static void main(String[] args) {
        HelloJNI app = new HelloJNI();
        app.displayMessage();
    }
}

2. Open a console and enter in your HelloJNI Project source directory and type:

javac HelloJNI.java
javah HelloJNI

This will return a new file called HelloJNI.h

3. Create a new C++ Shared Library Project in Eclipse and put the HelloJNI.h file inside of it.
Now create a new C++ source file called HelloJNI.cpp and put this code inside:

#include <stdio.h>
#include “HelloJNI.h”

JNIEXPORT void JNICALL Java_HelloJNI_displayMessage
  (JNIEnv *env, jobject obj)
{
    printf(“Hello JNI!\n”);
}

4. Now in the Project Properties go to MinGW C++ Linker –> Miscellaneous –> Linker flags and paste -Wl,–kill-at

5. Finally go to Run configurations –> Arguments –> VM arguments and paste -Djava.library.path= and then in Working directory select other and put ${workspace_loc:HelloJNIC++/Debug}

Build Assimp for Android NDK

1. Download Assimp-2.0 SDK complete source and extract it wherever you want (mine is ~/Desktop/assimp–2.0.863-sdk)
2. Enter into the extracted directory and type: mkdir BUILD and then cd BUILD
3. Run this command: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DENABLE_BOOST_WORKAROUND=ON -DCMAKE_INSTALL_PREFIX:PATH=/assimp-2.0 ..
4. Now run make
5. It will return a lot of errors, so here are the needed corrections:

  • “aiDefines.h” starting from line 237:
    #    if defined(__x86_32__) || defined(__i386__)
    #        define ASSIMP_BUILD_X86_32BIT_ARCHITECTURE
    #    elif defined(__x86_64__)
    #        define ASSIMP_BUILD_X86_64BIT_ARCHITECTURE
    #    elif defined(__ppc__)
    #        define ASSIMP_BUILD_PPC_32BIT_ARCHITECTURE
    #   elif defined(__arm__)
    #       define ASSIMP_ANDROID_ARM_ARCHITECTURE
    #    else
    #        error unknown architecture
    #    endif
    #else
    #    error unknown compiler
    #endif
  • “Importer.cpp” –> starting from line 901
    #if defined(ASSIMP_BUILD_X86_32BIT_ARCHITECTURE)
            << ” x86″
    #elif defined(ASSIMP_BUILD_X86_64BIT_ARCHITECTURE)
            << ” amd64″
    #elif defined(ASSIMP_BUILD_IA_64BIT_ARCHITECTURE)
            << ” itanium”
    #elif defined(ASSIMP_BUILD_PPC_32BIT_ARCHITECTURE)
            << ” ppc32″
    #elif defined(ASSIMP_ANDROID_ARM_ARCHITECTURE)
            << ” arm”
    #else
    #    error unknown architecture
    #endif 

    Once we have put this corrections run make again and it should work!
    Finally run make install!

Setting up Android standalone toolchain for CMake

It took me a while to figure out how to make the Android NDK working with CMake generated makefiles.
Recently I’m trying to port my simple test of character animation with Assimp Library on Android NDK so I needed to build an Assimp version for Android ARM CPU.
I could not find any infos on this topic on the net and officially, it seems that Assimp Library only supports iOS devices.
So I’ve experimented quite a bit and finally I come up with a solution!
Before we start, I have to say that I’ve tested my solution on OSX and probably it will work on Linux too but I seriously doubt that it will work on Windows + cygwin. You have been warned! 😀
Here we go!

1. Set up an Android Standalone Toolchain

Extract the downloaded Android NDK archive wherever you want (mine is ~/android-ndk-r8b)
Enter into this directory:

cd ~/android-ndk-r8b/build/tools

Fromt there run this command:

sh make-standalone-toolchain.sh –platform=android-8 –ndk-dir=/Users/prometheus/android-ndk-r8b –install-dir=/Users/prometheus/android-toolchain –toolchain=arm-linux-androideabi-4.4.3

Now you should have a new directory called android-toolchain.

2. Download the Anroid CMake configuration file
Inside the directory where you have android-ndk-r8b and android-toolchain directories, run this command:

hg clone https://android-cmake.googlecode.com/hg/ android-cmake

Now you should have these three directories: android-ndk-r8b, android-toolchain and android-cmake

3. Setup the needed Environment Variables
Edit your .profile file (if you don’t have it, just create it) as follows:

export PATH=$PATH:$HOME/android-sdk-macosx/tools
export PATH=$PATH:$HOME/android-sdk-macosx/platform-tools
export PATH=$PATH:$HOME/android-toolchain/bin

export ANDROID_NDK_TOOLCHAIN_ROOT=$HOME/android-toolchain
export ANDTOOLCHAIN=$HOME/android-cmake/toolchain/android.toolchain.cmake

4. Test CMake
Go inside this directory:

cd ~/android-cmake/samples/hello-cmake

There run this commands:

mkdir BUILD
cd BUILD
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN ..
make

It should build libhello-cmake.so inside ~/android-cmake/samples/hello-cmake-test/libs/armeabi-v7a

And that’s it!

P.S.
As you’ve probably noticed, we have specified which GCC version we need to use by adding the argument –toolchain=arm-linux-androideabi-4.4.3
At the time of this writing, this is mandatory because if you try to use CMake with GCC-4.6 it won’t work!