Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - sbaltes

Pages: [1]
Bugs / Re: Bug in .OBJ format with Colors (v1.15)
« on: December 05, 2007, 01:49:42 pm »
That sounds difficult... so I've implemented a workaround: I parse the .mtl file myself and add the color for each image with the following code:

Code: [Select]
    BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
    int cr = color.getRed();
    int cg = color.getGreen();
    int cb = color.getBlue();
    for (int y = 0; y < image.getHeight(); ++y) {
      for (int x = 0; x < image.getWidth(); ++x) {
        int v = image.getRGB(x, y);
        int r = (v >> 16) & 0xFF;
        int g = (v >> 8) & 0xFF;
        int b = (v >> 0) & 0xFF;
        r = r * cr / 255;
        g = g * cg / 255;
        b = b * cb / 255;
        v = ((255 & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF) << 0);
        result.setRGB(x, y, v);

Then I add the image under the name of the mtl-material to the TextureManager, and I create my own transient .mtl file where each texture has the name of the mtl-material and give that to the Loader.

The result looks the same like in poser.

But I think there is a little bug in Loader.createOBJObject, at the moment it is:

Code: [Select]
tid = tm.getTextureID("mtlName");

if it were

Code: [Select]
tid = tm.getTextureID(mtlName);

then I wouldn't need to create a transient .mtl file.

Bugs / Re: Bug in .OBJ format with Colors (v1.15)
« on: December 04, 2007, 11:15:21 am »
Just one more question, a missing feature: Poser seems to use a .tiff and additional color information for it's textures. The texture is overlaid with some color. JPCT seems to ignore the color information if a bitmap is present. An example from the .mtl-file:

newmtl jacket
Ns 30
Ka 0 0 0
Kd 0.317647 0.317647 0.317647
Ks 0.00784314 0.00784314 0.00784314
map_Kd Biz Man Texture.tif

Would it be a problem to add support for this in JPCT?

Bugs / Re: Bug in .OBJ format with Colors (v1.15)
« on: December 04, 2007, 10:20:20 am »
It works, thank you very much for this super fast reply  :)

I'm sorry that we have to use this strange format, but after all it's working best with poser. Ok, poser itself could be considered a bug ;-)

Bugs / Bug in .OBJ format with Colors (v1.15)
« on: December 03, 2007, 02:13:04 pm »
Hi, I've a problem loading the following .OBJ file:

In this .mtl there is only color information, no texture image. The colors doesn't look right: It should be a blue jacket, but in JPCT it looks a little bit different (more like a teenage rap star, the jacket is white / blue / golden). This is the first time I load a .OBJ from Poser with plain color textures. I can import this file in Milkshape with correct colors so I think it's a JPCT Bug (or a Bug in the .OBJ format that JPCT has no workaround for ;-)

Best Regards

Bugs / Bug in .OBJ Format import (Beta 1.15)
« on: July 25, 2007, 03:26:56 pm »
I was very happy to see that the new version of JPCT can import Wavefront .OBJ files. Sadly it doesn't work with files exported from Poser 6 and / or Milkshape 1.7.9 and 1.8.1a. The first file results in an empty object, the other file results in an object that reminds a little bit of a hedgehog - it's very spiky.

You can download the files from this url - it's the same object, one from poser and the other one from milkshape (it's the poser .obj file loaded in milkshape and saved again as .obj with milkshape):

This is the code I use to load the files:

Code: [Select]
Object3D[] o = Loader.loadOBJ(filename, filename.replaceAll("\\.obj", "\\.mtl"), 100f);
for (int j = 0; j < o.length; j++) {

Thanks for any help!

Pages: [1]