16 bit MDL models?

Discuss programming topics for the various GPL'd game engine sources.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

16 bit MDL models?

Post by drm_wayne »

Im curious, the blender script for quake models seems to have a 16bit option.
After exporting with the 16bit option enabled the header seems to be different.ß
How can i enable support for this format in my engine (im using joequake).
(i guess it needs more than just support for the MDMD16 header).

Greets. :D
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Post by frag.machine »

Never heard of this format before. Maybe some experimental option ?
What would be the advantages over original MDL ?
EDIT: Maybe it's some option to export to Half Life .mdl format ?
EDIT2: Looks like this thread over QuakeOne has your answer.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

it has 16 bit vertex data, and i want to use it.
But i think it needs more in the engine than just the header.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: 16 bit MDL models?

Post by mh »

Look for everywhere the trivertx_t struct is used in the engine; you'll need to adjust that code to also work with the different vertex type.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

thanks.

Is the format (apart from the MD16 header and the 16 bit verts) similar?
I guess the texture is still stored like in a regular quake mdl.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: 16 bit MDL models?

Post by mh »

I'll be honest - I don't know the format at all.

Reading the description of it in the QuakeOne.com thread, specifically this part:
For anybody worried about vertex wobble: if you use QuakeForge, you can set the "16-bit" option in the object panel in blender and then export. The vertex data will then be 16-bit rather than 8 (that's the only effect of the option).
Indicates that this is indeed the only difference.

I suspect that there should be other differences because if you look at modelgen.c you'll see that there are other places that trivertx_t is used, but you'll need to ask taniwha (or look at the QF code yourself).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

I already looked at QF source, but its totally different how they handle the models..
Oh well :?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: 16 bit MDL models?

Post by Spike »

I had a look at QuakeForge, the 4-byte ident is different, the version is not. the vertex data is doubled-up, with the first set being the high-order data, with the second set being low-order data.
you can should be able to load these by just recognising the header, and skipping over the extra data (just double the vertex count for purposes of on-disk frame size).
the extra data is 'optional' data, in that its all 0, nothing else changes. there's also some extra nomalindex stuff in that data, which should be considered padding.
I've not actually tested this of course as I'm too lazy to figure out how to use the various tools, but it looks fairly simple to load these (actually using the data might be a little more complex if you're making a software renderer, but it should be somewhat easy in gl - especially if you already handle mdl+md2+md3 in a generic way).
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

problem is i dont know much about the model code, and i see that my engine has alot different things like SetupAliasBlendedFrame etc, which isnt
in QuakeForge. I already sended the developers a mail, i hope they can help me adding this stuff.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Post by frag.machine »

TBH I wonder if it's a good idea to work with a model format so obscure. The supposed advantage of avoiding vertex wobbling can be obtained with md3, a fairly well known standard format nowadays, supported by a good number of tools.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

MD3 takes too long to load because of the normal calculating..
Oh well, i think i stay with MD2 then :oops:
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Post by frag.machine »

drm_wayne wrote:MD3 takes too long to load because of the normal calculating..
Oh well, i think i stay with MD2 then :oops:
Not very familiar with MD3 loading, but reading the code snippet below from this link one can have a good idea for why is so slow:

Code: Select all

(Code in q3tools/common/mathlib.c:NormalToLatLong)
lng <- atan2 ( y / x) * 255 / (2 * pi)
lat <- acos ( z ) * 255 / (2 * pi)
You may want to consider using precomputed tables at engine initialization instead calling atan2() and acos() functions for every normal, since the angles are stored as bytes.
This should give you a considerable speed gain, specially if the target hardware isn't great. Of course, as long the problem lies in this part of the code.

For more food for thought: http://stackoverflow.com/questions/7698 ... -functions
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

actually its this part which causes a slowdown (around 8 - 10 seconds per model, way too long)

EDIT: i wonder if its possible to take all the final calculated normals and output it as a file like the old
GLQuake MS2 meshes?

Code: Select all

		{
			float		lat, lng;
			vec3_t		ang;
			md3vert_mem_t	*vertexes = (md3vert_mem_t *)((byte *)header + surf->ofsverts);

			vertexes[j].oldnormal = vert->normal;

			vertexes[j].vec[0] = (float)vert->vec[0] * MD3_XYZ_SCALE;
			vertexes[j].vec[1] = (float)vert->vec[1] * MD3_XYZ_SCALE;
			vertexes[j].vec[2] = (float)vert->vec[2] * MD3_XYZ_SCALE;

			lat = ((vert->normal >> 8) & 0xff) * M_PI / 128.0f;
			lng = (vert->normal & 0xff) * M_PI / 128.0f;
			vertexes[j].normal[0] = cos(lat) * sin(lng);
			vertexes[j].normal[1] = sin(lat) * sin(lng);
			vertexes[j].normal[2] = cos(lng);

			vectoangles (vertexes[j].normal, ang);
			vertexes[j].anorm_pitch = ang[0] * 256 / 360;
			vertexes[j].anorm_yaw = ang[1] * 256 / 360;

			vert++;
		}
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: 16 bit MDL models?

Post by Spike »

what are pitch+yaw for? why do you need those?
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Post by drm_wayne »

This is the original loader from JoeQuake, i didnt added anything. :shock:
Post Reply