Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, dr_panther, TedMar, vicknick), 833 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
various HMP related MDL7 SDK questions #388845
12/07/11 23:18
12/07/11 23:18
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi,

I am currently working with the MDL7 SDK and I am writing HMP7 files. Two questions (prepare for further questions in the near future smile):

1.) In the demo application for writing a HMP7 file, you are setting the member flags of HMP5_HEADER once to 1 and once to 0. I noticed no difference, but from the function name you use there, I guess it has something to do with a complete planar surface... is this flag really used?? What effect does it have?

2.) It seems to me that the name parameter of the ::Skin method has no effect with HMPs... I do the following:

Code:
// determine skin type
int skinType = s->isExtern ? M7SKINTYP_EXT_FILE : 0;

// create new skin
hmp.Skin(skinType, "test123");



So, it should have the name "test123" in the skin manager, but when I open the generated HMP in MED, it is named "Skin0" and I even can't edit it. Is this done by purpose or a bug?

Last edited by HeelX; 12/08/11 00:26.
Re: HMP5_HEADER flags, skin name [Re: HeelX] #388857
12/08/11 00:03
12/08/11 00:03
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
3.) Can you imagine any reason, why MED shows the HMP correct with external texture, but when I load it in the engine I see nothing? Here is my source:

Code:
// save skins
if (h->numSkins > 0)
{
    for (int i = 0; i < h->numSkins; i++)
    {
        // get skin
        HmpSkin* s = (h->skins)[i];

        // determine skin type
        int skinType = 0;
        {
            if (s->isExtern)
                skinType = M7SKINTYP_EXT_FILE;

            if (s->mat)
                skinType |= M7SKINTYP_MATERIAL;
        }

        // create new skin
        hmp.Skin(skinType, s->name);

        // prepare skin size parameters
        int sizex = s->isExtern ? (int)strlen(s->externFile)+1 : 0;
        int sizey = s->isExtern ? 1 : 0;
        int bypp = s->isExtern ? 1 : 0;
        bool mips = false;

        // set skin size
        hmp.SkinSize(sizex, sizey, bypp, mips);

        // skin bits
        if (s->isExtern)
            hmp.SkinBits((BYTE*)s->externFile, 0, 0, 0);

        // material, if any
        if (s->mat)
        {
            // convert bgr var colors from material to rgb float triplets
            float diffuse[3], ambient[3], specular[3], emissive[3];
            rgbForBgrVar(diffuse, &(s->mat->diffuse_blue));
            rgbForBgrVar(ambient, &(s->mat->ambient_blue));
            rgbForBgrVar(specular, &(s->mat->specular_blue));
            rgbForBgrVar(emissive, &(s->mat->emissive_blue));

            // transfer rgb triplets to skin
            hmp.SkinMaterial(diffuse, ambient, specular, emissive, _FLOAT(s->mat->power));
        }

        // finish skin
        hmp.SkinDone();
    }
}



It is almost the same procedure you do as in the example. I also placed it before writing the height values, etc...???

[EDIT]

I only see an external texture in the engine, when I add in MED a new skin, while all faces are selected and I press "set skin"...?

Last edited by HeelX; 12/08/11 00:10.
various HMP related MDL7 SDK questions [Re: HeelX] #388858
12/08/11 00:06
12/08/11 00:06
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
4.) Can you please explain .SkinBits, it is not very well documented.

Last edited by HeelX; 12/08/11 00:25.
Re: various HMP related MDL7 SDK questions [Re: HeelX] #388879
12/08/11 11:02
12/08/11 11:02
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
3) FIXED

I messed up with the scale and offset transformation from world space to data space. This is how it is correctly done:

Code:
// get lowest and highest height
float lowest, highest;
hmp_minmaxz(h, &lowest, &highest);

// magnitude is height distance between lowest and highest
float magnitude = highest - lowest;

// z values have to be between 0...65535, so we have to set
// implicit scale and offset parameters

float lowerBound = 0.0f, upperBound = 65535.0f;

// scale
{
	hmp.Head().scale[0] = h->width / upperBound;
	hmp.Head().scale[1] = h->height / upperBound;
	hmp.Head().scale[2] = magnitude / upperBound;
}

// offset
{
	hmp.Head().scale_origin[0] = -h->width/2;
	hmp.Head().scale_origin[1] = -h->height/2;
	hmp.Head().scale_origin[2] = lowest;
}



My previous mi/max values were wrong, so it was so ackwardly stretched, that I didn't saw it.

Re: various HMP related MDL7 SDK questions [Re: HeelX] #389025
12/09/11 17:25
12/09/11 17:25
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
5.) What means the M7SKINTYP_RGBFLAG flag?

Re: various HMP related MDL7 SDK questions [Re: HeelX] #389221
12/11/11 20:10
12/11/11 20:10
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
6.) when I want to use a BMAP* in the engine as image, which I want to save as intern texture into a HMP, should I just write the RGB or RGBA data via SkinBits into a HMP or do I have to generate the next 3 mipmaps on my own and pass them as the next three parameters? What happens when I pass NULL?

Re: various HMP related MDL7 SDK questions [Re: HeelX] #389222
12/11/11 20:12
12/11/11 20:12
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
7.) depending on 6.): how do I calculate the boolean for mips in .SkinSize? Is it always false for DDS and palette images? If it is for external textures: enforces it (during HMP loading in-engine) mipmap generation when it is true or prohibits mipmap generation when it is false? Is it always true for all other internal texture formats?

Last edited by HeelX; 12/11/11 20:13.
Re: various HMP related MDL7 SDK questions [Re: HeelX] #389224
12/11/11 20:18
12/11/11 20:18
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
8.) if it is an internal DDS file, how do I calculate the dds file size which I obviously have to pass as width-parameter to SkinSize? If I loaded a DDS as BMAP* in-engine, how do I calculate it on-the-fly, can I use

Code:
long width,height; // original size of the bitmap
long bytespp; // original bytes per pixel (1..4)



from the BMAP struct for that?

9.) What happens if a DDS has mipmaps stored? Do I have to turn on the previously mentioned mips flag anywhere?

Re: various HMP related MDL7 SDK questions [Re: HeelX] #389376
12/13/11 15:20
12/13/11 15:20
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Ok, I'll try to answer back to front:

9) DDS mipmaps have no mips flag and are handled automatically.
8) For DDS skins, bytespp = 1 and with = the DDS file size.
7) the mips flag means that 3 mipmaps are stored following the image, each with 1/4 the size.
6) You must generate the 3 mipmaps when you set the mips flag.
5) and 1) I have no idea.
3) The usual reason is a full transparent image.
2) Yes, skin names have no effect in a HMP.

Re: various HMP related MDL7 SDK questions [Re: jcl] #389379
12/13/11 16:26
12/13/11 16:26
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Thank you very much for the answers! Though, some things are still not clear to me:

Quote:
8) For DDS skins, bytespp = 1 and with = the DDS file size.
What do you mean? That bytespp stores for DDS images the filesize? --> YES; bytespp stores the filesize.

Quote:
7) the mips flag means that 3 mipmaps are stored following the image, each with 1/4 the size.
What happens, if I leave it off: will the engine calculate then the mipmaps itself upon loading the HMP?

Quote:
5) and 1) I have no idea.
So, what are you doing in MED; are you just setting them to a default variable?

Last edited by HeelX; 12/16/11 13:19.
Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1