the Magicball Network Forums

the Magicball Network Forums (
-   Fan Creations - General (
-   -   How to: coloring/texturing LBA2 models (

solarix 2018-11-10 15:28

How to: coloring/texturing LBA2 models
1 Attachment(s)
Hi folks,

I'm working on my own LBA1/2-Implementation (, but right at the moment: I'm stuck. :mad2:

I simply don't get the coloring/texturing done for lba2 models. I try to understand lba2remake, but JS is (without typeinformation) still hard to read for me. It's difficult to follow the color/texture/uv-information from body.hqr/ress.hqr to the shader. LBA1 is easy, because I can compile, run and debug twin-e and can compare values of single variables with my own implementation.

So, xesf, adrien and all other hackers out there: how did you start with your own lba2 renderer? Is there a twin-e-like reference implementation for lba2? Does anyone have the source code of the "LBA Model Viewer" by yaz0r? The viewer supports lba2 models and looks like C++/Qt...

Thanks for any advice/hint/help!

[Edit] attached printscreen of my own modelviewer. I'm able to load normals, vertices, bones, polygones, but not the colors/textures.

solarix 2018-11-22 00:59

Hi MrQuetch,
thanks for your anwser!


Originally Posted by MrQuetch (Post 458132)
You are doing great things with your knowledge. You look like you're getting very close to fully implementing the models.

Let's see what I can do :). But having an engine supporting LBA1/LBA2 and custom models (3DS, Blender..) would be fun :).
The geometry of the LBA2-models looks complete to me... Just the colors/texturing still don't work. Grrr... :bloated:


Originally Posted by MrQuetch (Post 458132)
I still have yet to load in existing LBA 2 models myself. I've actually been working on a Maxscript to port fully custom models from Autodesk 3DS Max directly into the LBA2 model format. My next step is to create animated models within Unity.

That's great! Looks like we're working both on the same challenge.. Are you going to load original LBA2-Models (direct from body.hqr/ress.hqr) into unity?


Originally Posted by MrQuetch (Post 458132)
Remember that you need to allow the right amount of space - depending on if you want to draw a triangle or a quadrilateral. Also, the colors and material both use their own bytes.

My problem is simple: I don't understand the output of my own "loadPolygon" method (similar to "loadPolygon()" of lba2remake). I mostly get "hasTex == false" and color-indexes for black and violett. Maybe there's a bug in my parser or maybe I don't understand what I get. That's why I'm looking for a debuggable lba2-model loader.


Originally Posted by MrQuetch (Post 458132)
If I may ask a question, how did you get the bones working? I cannot get the vertices' offsets properly. They're supposed to come from the origin on the bone they're attached to.

You're right: the vertices' offsets ("translation") come from the parent(!)-bone.

Let's start at bone 0: parent bone is "-1". So you can't translate bone 0 attached vertices. Bone "1" has (e.g.) parent ID "0". So read the vertex-Index of bone 0, take that vertex from the vertex-list and that's your x/y/z-offset for Bone 1 attached vertices. All offsets are relative, not absolute. If you have a branch with bone 0 -> bone 1 -> bone 2, then the vertices of bone 2 are translated by adding the offset of bone 1 and offset of bone 0.

My implementation (LbaBody::translateVertices()) uses recursion. I start at bone 0 and commit the "current offset" to the next bone in the branch recursively. You can ignore the "rotation"-stuff. That's for animation and not needed for basic bone-translation.

Hope this helps!

All times are GMT +2. The time now is 15:39.

Powered by vBulletin®
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2021, the Magicball Network