Saturday, 26 February 2011

AutoBFont

AutoBFont is small tool for text rendering on OpenGL(and can be easily ported to DX) with bitmap fonts, providing a way to draw perfectly aligned text with bitmap sheets created in Fireworks/Photoshop/Gimp and Inkscape. The tool is composed by two parts : an generator and a loader class.

The monospace font with and without a drop shadow(effect created in Inkscape) rendered with the help of autobfont
The generator computes each character limits from the character sheet bitmap, which should be a RGBA TGA image with no compression. It should have 16 columns by 16 rows to fill with characters and the size of the image should be power of 2 (1024x1024 for example). If only the first 8 rows are used, the remaining rows can be used to fit a "bold" version of the font.

The generator program requires 3 mandatory arguments :
-i CHARACTER_CONVERSION_MAP.TXT 
-m CHARACTER_BITMAP_SHEET.TGA
-o OUTPUT_MAP.TXT
Optional arguments :
-b Compute the Bold characters in the last 8 rows.
-h VALUE  Set all characters line height (the default value is 3*CELL_SIZE/4).
-t VALUE Set alpha threshold value, improves character boundaries detection (default value is 50, max is 255).

The conversion map is a text file with the ASCII character for each cell in the bitmap sheet, although it's limited to Latin characters, the generator and loader can be changed to use wchar_t structure instead of char for other languages such as japanese. All the characters in the bitmap font should by white (if you want to use color blending in OGL, but isn't mandatory) with a background transparent (below the alpha threshold value).

The loader class is available in the demo.cpp class, which loads the generated output map and the renders the characters with OpenGL.

To convert the SVG to TGA use gimp with no RLE compression and  bottom left origin.

The typical commands to compile and run the generator and demo on linux:
make
./generator -i ct_PT.txt -m font_ubuntu.tga -o font_ubuntu_map.txt
./demo font_ubuntu_map.txt font_ubuntu.tga

DOWNLOAD

Tuesday, 8 February 2011

Logotype

Ok, a little explanation about the logo I finished recently.

For me the demoscene "thing" started around the year 1992 before i even understood what the heck "demoscene" meant or had any skills to do anything with computers beyond playing games. Back then my sister had received her first computer, a 486DX with 4MB of RAM. After some months she got some games from her friends and some of them included some cracktro apps, which back then where a confusing concept for me, since they had no propose beyond showing the artwork and moving letters plus some audio.

NapalmCore logo created with Blender 2.56
The first cracktro i saw was the TEKNO SKULL by TDT / TRSi, which impressed me since I was a little kid and had a particular fear of skeletons. In the course of the time, with the influence of the cyberpunk culture in animes and movies from the 80's & 90's, the fear was lost and this goreish characteristic remained as a symbol from those years and the culture it self.

The logotype creation started back then at the Euskal 2008 for the 3D competition, at the time it only featured the skull. Recently i decided to recycle the model, remaking the skull with better detail and adding the extra details, such as the mechanical stuff and the sun glasses. I also was inspired by latest razor 1911 prods which have an unique new-old-school style, mimicking the 90's hardware with the latest graphics effects, for example, the grid pattern effect can be seen on the "StarCraft 2 cracktro" or the "Pirates of the 777 seas". The sunglasses are due to the influences of Motoko Kusanagi from the ghost in the shell :)

With this, i can finally conclude by saying that the name of this blog/website/demoscene group reflects the unique cyberpunk culture from the last years of the 20 century, plus the cracking culture which evolved to the demoscene which we have currently.

Saturday, 15 January 2011

DIY Pseudo "iMac"

This was the situation : I have an laptop (HP-DV5000) with 5 years which still works pretty well apart from the broken LCD, which was due it had already been at Breakpoint, Inercia, Euskal and almost all the college period in my backpack. So the LCD started to show some weird vertical coloured lines which would require a new LCD, which is almost the price of a new laptop...
After i started my current job, which is purely macintosh based, i noticed the iMac where actually an interesting concept to keep all the cables inside the computer. So i though maybe i can do something similar to my old laptop !

The basic idea was to mount the laptop behind an LCD monitor, my monitor (Sony SDM-S93) had a sliding plate behind which helped to mount the metal holder bars. After that I only needed some sort of electronic connection to power up the laptop, since the power button would be hidden under the lid. 

The electronic circuit consists in a relay which is activated when we press the front power/iddle button in the monitor, the relay acts as the power switch of the laptop. I could have connected directly the two switches, but that wouldn't be very safe and healthy for both the devices. The circuit steals 12V from the monitor PSU, which is always available whatever the current state(idle or on). On idle state the available current is very low, because the PSU switching circuit is working at a very small duty cycle to use less mains power, so the laptop switching circuit must be power efficient.

Monitor PSU and control circuit plus my circuit in the breadboard The compact version of the laptop switching circuit

After building the circuit I only needed to add some cables to the laptop which would intercept the power button signal, using my trusty Dremel i drilled a path through the plastic and used the hole of one screw to pass the cables. The cables end with a male conector to help mount and unmount the laptop from the suport, or even still use the laptop .. as a laptop :)

Drilled path to pass the cables
The end result isn't a iMac, but still, I managed to recycle old hardware to create a new "computer" which manages to accomplish all my current needs (Blender, development, office and minecraft :P). It was still has some issues due to idle/on/off state of monitor, when it's on iddle mode and we press the power button, it powers up the laptop and powers down the monitor (iddle->off), but pressing it again it powers up the monitor without powering down the laptop. I could easily fix this by intercepting also the monitor power switch and with some extra logic, but for now it's enough ! 

Back view Front view

Sunday, 26 December 2010

Blender Armatures and Exporting


One of the things i have spent many time trying to understand is the Blender animation data for the armatures. Since the quaternions and translation vectors have their own special space, which depends on the bone orientation and roll vector as shown in how armatures work, it isn't always easy to translate the animations to other formats like collada, fbx, bvh or to export the data for real-time applications.

The first thing to take in consideration is the matrix theoretical layout used to describe armature chain, like OpenGL, Blender uses the translation vector in a column, which may create some confusion. One typical example of this issue is the OpenGL (2) and DirectX (1) shaders, at machine level, they are done in the same way (see the gluProject source from Mesa), but from the programmers high level, the syntax is quite the opposite for the following cases :
out.pos = mul(float4(in.vertex,1.0), WorldViewProj ) (1)
gl_Position = WorldViewProj  * vec4(vertex, 1.0) (2)


Keeping this in mind we rewrite the blender armature expression the way i like (3).
b.matrix = IK(b) * Constrains(b) * actions(b) * bonemat(b) * head(b) * tail(b-1) * b.parent.matrix (3)

Ignoring the IK and Constrains we have something similar to what i use for my armatures (4), but still, the action data (quaternions and translations) are affected by the bonemat matrix, which disables the direct use of the animation data from blender.
bone.matrix = Scale(bone.scale) * Rotate(bone.quaternion) * Translate(bone.head+bone.translation) *Translate(bone.parent.tail-bone.parent.head)*bone.parent.matrix (4)


To fix this issue, i found this expression to be the solution to export Blender animation data for my applications and the bXporter API (5).

matArmatureSpace = b.matrix['ARMATURESPACE']
matInvArmatureSpace = Matrix(matArmatureSpace).invert()

rotFixed = (matInvArmatureSpace.rotationPart()* graphQuaternion.toMatrix()*
matArmatureSpace.rotationPart()).toQuat()

posFixed = (matInvArmatureSpace*
TranslationMatrix(graphPosition)*
matArmatureSpace.rotationPart()).translationPart() (5)

This peculiar transformation applies the transformation of the bone rest pose in armature space to the current action data, this way we get the bone animated in armature space, then by applying the inverse bone rest pose matrix, we get the the rotation and translation relative to bone space and independent of the bonemat matrix, enabling the use of the expression (4).

Currently i have even fixed the issue with the animation beziers with another solution which doesn't use Cardano solver like in Blender or ILM ones, which consists in recalculate the bezier coefficients, but that will be another blogpost :)

Thursday, 11 November 2010

Event Report - FIBDA 2010

This year event was dedicated to the 100th birthday of the portuguese republic, with many works related to the satire of portuguese people and the events during the implantation of the republic. It also exhibited some comics with almost 100 years, pretty well conserved!

This year there wasn't an official cosplay event, because there weren't enough conditions to support the event, but still some contestants still appeared. It had some awesome installations with comics and sculptures of some artists but in general it was a bit weaker in relation to last year. The japanese section was a bit short for my taste, but had a huge scroll exposed over the walls with a colab work of many artists. It also featured a video installation with an animation of ancient japanese drawings.

The courageous ones who still came to the event

1/2 of the wall scroll
GUNMM Mangas Collection, 18 books 
I also bought the full collection of the GUNMM manga which I wasn't expecting to find and it was well worth the price, it's an specular cyberpunk story from the 90's, although it's a bit gore'ish :P