Jump to content

mesh file format


photo

Recommended Posts

Hello,

Trying to load *.mesh files with 4cc ms11 and found there https://developer.unigine.com/ru/docs/2.9/code/formats/file_formats actually old format description

  1. File format identifier (int32 "ms11" ('m' | ('s' << 8) | ('1' << 16) | ('0' << 24))

I can successfully load vertices but cant find out triangle index format, could you actualize format info ?

Edited by lightmap
Link to comment

Hi lightmap,

All in all the description is up-to-date, but there were the following errors in it:

1. File format identifier in all three cases (items 1, 9, 13 in the list) for mesh must be  (int32 "ms11" ('m' | ('s' << 8) | ('1' << 16) | ('1' << 24)))

     Note: for animation the 10th version is used: (int32 "an10" ('a' | ('n' << 8) | ('1' << 16) | ('0' << 24)))

2. Color values in 12 should be (unsigned char[4]).

3. Both Сoordinate and Triangle indices for each vertex of the surface (if num_vertices > 65536)  should be (unsigned short[length]).

Please note that:

  • All data is in the little-endian notation.
  • float is a 32-bit IEEE754 floating-point type. It has a range of 3.4 e-38 to 3.4 e+38.
  • int here is a compact signed integer.
    So, to read / write compact integer values use readInt2() / writeInt2() methods respectively.
  • int32 is a signed 32-bit two's complement integer. It has a range of –2,147,483,648 to 2,147,483,647.
  • unsigned short is an unsigned 16-bit integer. It has a range of 0 to 65,535.
  • char is a signed 8-bit two's complement integer. It has a range of -128 to 127.
  • unsigned char is a 8-bit unsigned integer. It has a range of 0 to 255.
  • string must be null terminated. The string size should include this terminating null character.
  • All formats allow multiple surfaces.

We'll update the documentation, sorry for the inconvenience caused!

Thanks!

  • Like 1
Link to comment

Thank you!,

so readint2() is something like ((unsigned char)buf[0]) | ((unsigned char)buf[1] << 6) ?

if vertices count 24 then it contained in single (unsigned char), if 200 then in two uchars ?

Link to comment

Here, please have a look at the readInt2 implementation for better understanding:

int ret = readChar();
int sign = ret & 0x40;
if ((ret & 0x00000080) == 0)
{
	ret &= 0x3f;
	if (sign)
		return -ret;
	return ret;
}
ret = (ret & 0x0000003f) | (readChar() << 6);
if ((ret & 0x00002000) == 0)
{
	if (sign)
		return -ret;
	return ret;
}
ret = (ret & 0x00001fff) | (readChar() << 13);
if ((ret & 0x00100000) == 0)
{
	if (sign)
		return -ret;
	return ret;
}
ret = (ret & 0x000fffff) | (readChar() << 20);
if ((ret & 0x08000000) == 0)
{
	if (sign)
		return -ret;
	return ret;
}
ret = (ret & 0x07ffffff) | (readChar() << 27);
if (sign)
	return -ret;
return ret;

Thanks!

  • Like 1
Link to comment
×
×
  • Create New...