Forum

16 bit MDL models?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

16 bit MDL models?

Postby drm_wayne » Wed Jun 24, 2015 12:43 pm

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
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby frag.machine » Wed Jun 24, 2015 9:17 pm

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)
User avatar
frag.machine
 
Posts: 2069
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Postby drm_wayne » Thu Jun 25, 2015 1:25 pm

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.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby mh » Thu Jun 25, 2015 4:59 pm

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
User avatar
mh
 
Posts: 2287
Joined: Sat Jan 12, 2008 1:38 am

Re: 16 bit MDL models?

Postby drm_wayne » Thu Jun 25, 2015 5:06 pm

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.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby mh » Fri Jun 26, 2015 8:02 am

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
User avatar
mh
 
Posts: 2287
Joined: Sat Jan 12, 2008 1:38 am

Re: 16 bit MDL models?

Postby drm_wayne » Sat Jun 27, 2015 4:41 pm

I already looked at QF source, but its totally different how they handle the models..
Oh well :?
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby Spike » Sat Jun 27, 2015 5:07 pm

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).
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: 16 bit MDL models?

Postby drm_wayne » Sat Jun 27, 2015 7:09 pm

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.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby frag.machine » Sun Jun 28, 2015 3:13 pm

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)
User avatar
frag.machine
 
Posts: 2069
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Postby drm_wayne » Sun Jun 28, 2015 4:03 pm

MD3 takes too long to load because of the normal calculating..
Oh well, i think i stay with MD2 then :oops:
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby frag.machine » Mon Jun 29, 2015 3:12 am

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/769836/efficiency-speed-for-trigonometric-functions
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2069
Joined: Sat Nov 25, 2006 1:49 pm

Re: 16 bit MDL models?

Postby drm_wayne » Mon Jun 29, 2015 2:04 pm

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++;
      }
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: 16 bit MDL models?

Postby Spike » Mon Jun 29, 2015 2:57 pm

what are pitch+yaw for? why do you need those?
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: 16 bit MDL models?

Postby drm_wayne » Mon Jun 29, 2015 3:07 pm

This is the original loader from JoeQuake, i didnt added anything. :shock:
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest