0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
various HMP related MDL7 SDK questions
#388845
12/07/11 23:18
12/07/11 23:18
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
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 ): 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:
// 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
HeelX
OP
Senior Expert
|
OP
Senior Expert
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:
// 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
HeelX
OP
Senior Expert
|
OP
Senior Expert
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
HeelX
OP
Senior Expert
|
OP
Senior Expert
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:
// 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]
#389222
12/11/11 20:12
12/11/11 20:12
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
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
HeelX
OP
Senior Expert
|
OP
Senior Expert
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
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: jcl]
#389379
12/13/11 16:26
12/13/11 16:26
|
Joined: Jul 2001
Posts: 6,904
HeelX
OP
Senior Expert
|
OP
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Thank you very much for the answers! Though, some things are still not clear to me: 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. 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? 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.
|
|
|
|