nex_smd_mesh_export.py and zmodel problems

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators


  • I used nex_smd_mesh_export.py to export a player model from Blender to smd format and the zmodel program to compile a zym from the smds. Some bugs and problems I ran into:

    1. Off-by-1 bug in nex_smd_mesh_export.py
    The script does'nt export animations correctly. Line 809 of nex_smd_mesh_export.py should be:
    Code: Select all
    self.file.write( '%i "%s" %i\n' % ( bone.index, bone.name, bone.parent.index ) )

    instead of
    Code: Select all
    self.file.write( '%i "%s" %i\n' % ( bone.index, bone.name, bone.parent.index + 1 ) )


    2. Wrong error message in zmodel

    zmodel is reporting a wrong bone name on certain errors with the sceleton definition. Line 484 should be
    Code: Select all
    printf("warning: duplicate global bone definition ...", bone[i].name, bone[i].parent, parent);

    instead of
    Code: Select all
    printf("warning: duplicate global bone definition ...", name, bone[i].parent, parent);


    3. Animation names messed up

    The animation names/names of the smd files are not correct. For me, the following smd files are mapped to thes animations:

    backleft.smd -> backleft
    backright.smd -> backright
    dead1.smd -> dead1/2
    dead2.smd -> dead1/2
    die1.smd -> draw
    die2.smd -> duck
    draw.smd -> duckwalk
    duckidle.smd -> jump
    duckjump.smd -> idle
    duck.smd -> duckjump
    duckwalk.smd -> duckidle
    forwardleft.smd -> forwardleft
    forwardright.smd -> forwardright
    idle.smd -> die/1/2
    jump.smd -> pain1/2
    pain1.smd -> pain1/2
    pain2.smd -> shoot
    runbackwards.smd -> runbackwards
    run.smd -> die1/2
    shoot.smd -> ? (taunt is the only one left, but I didn't see anything)
    strafeleft.smd -> strafeleft
    straferight.smd -> straferight
    taunt.smd -> run

    4. Weights other than 0/1?

    The sources of zmodel say that it would be the smd format which only knows weights 1 and 0 of vertixes being assigned to bones:
    zmodel.c wrote:// the origin is relative to the bone and scaled by percentage of influence (in smd there is only one bone per vertex, so that would be 1.0)

    But that's not true: One vertex in an smd file (or at least the smd file the smd exporter creates) is given in the following way:

    Code: Select all
    1 -39.999996 40.000000 0.000000 0.000000 0.000000 40.000000 0.502972 0.502972 2 1 0.600000 0 0.400000

    Where the columns are:

    1: BoneID
    2-4: Coords
    5-7: Normal coords
    8-9: UV coords
    10: Number of Bones this vertex belongs to
    11+: Bone ID/weight pairs

    The zmodel reads only the columns 1-9, thus no weights. Or at least that's what I can find in the zmodel source, line 639. Now the question is: Can the zym format handle weights? The comment in zmodel.c sort of gave me hope that such a thing could be possible...
    Rebecca
    Member
     
    Posts: 29
    Joined: Thu May 08, 2008 5:31 pm


  • Rebecca wrote:The zmodel reads only the columns 1-9, thus no weights. Or at least that's what I can find in the zmodel source, line 639. Now the question is: Can the zym format handle weights? The comment in zmodel.c sort of gave me hope that such a thing could be possible...

    I guess not (you should talk to LordHavoc about this, he's probably the only one who knows for shure), but it looks like dpmodel ( http://svn.icculus.org/twilight/trunk/dpmodel/ replace http:// with svn:// for svn clients) can.

    Since 2.4 all model formats supported by darkplaces (mdl, md3, zym, dpm, psk and i'm shure i forgot some...) can be used for player models, if you add an .animinfo file (a template can be found in data*.pk3/models/player)
    User avatar
    KadaverJack
    Site admin and forum addon
     
    Posts: 1102
    Joined: Tue Feb 28, 2006 9:42 pm

Sat May 24, 2008 5:27 pm

  • this is great work rebecca, getting all the snags out of the blender -> nexuiz tool chain would be really helpful.
    zuriastrad
    Alien
     
    Posts: 169
    Joined: Thu May 15, 2008 4:13 am

Sun May 25, 2008 1:10 am

  • IMHO a proper SDK should be a higher priority for developers now.
    I'm not good enough with programming to do much more than the simple hack that the weapon exporter is.
    I'm not sure how a proper animation exoprter for nexuiz zym would look (and work) but it is definitely needed.
    User avatar
    ihsan
    Alien trapper
     
    Posts: 305
    Joined: Fri Mar 03, 2006 3:33 pm
    Location: Trinidad (Where Obama met Chavez)

Sun May 25, 2008 8:57 am

  • ihsan- you mean something like a script that exports directly to zym without the zmodel compiling stage?

    rebecca- nice fix for the exporter. the bones in the animation are ok now.
    zuriastrad
    Alien
     
    Posts: 169
    Joined: Thu May 15, 2008 4:13 am

Sun May 25, 2008 11:16 am

Sun May 25, 2008 8:06 pm

  • KadaverJack, thanks for pointing me towards dpmodel, I will try it.

    Actually, I'm more a programmer than a modeller, and I've even done some Blender scripting. So if there's something I could do...
    Rebecca
    Member
     
    Posts: 29
    Joined: Thu May 08, 2008 5:31 pm

Thu May 29, 2008 6:31 pm

  • i've just noticed something seriously broken with the animation export. i've got a model with 12 animations and i just want to export animations 5-12, but it keeps on exporting all of them. since the script doesn't ask which animations to export i'd assumed that the start/finish numbers in the anim box might define which got exported, but that doesn't seem to be the case.

    this is a horrible mess. i have to open up the smd in a text editor, figure out which animations i want to keep, delete the rest and then edit the lines with time in it.

    i'm using the nex_smd_mesh_export.py with rebecca's fix (line 809). i'll try finding a halflife2 smd exporter and seeing if that works better.


    **edit**

    nope, same problem. it could be that i'm using an svn build of blender. i'll try it with a more stable version and see what happens.

    **edit**

    tried it with the stable version of blender that comes with ubuntu 8.04 and i had the same problem.
    zuriastrad
    Alien
     
    Posts: 169
    Joined: Thu May 15, 2008 4:13 am



Return to Nexuiz - Development




Information
  • Who is online
  • Users browsing this forum: No registered users and 1 guest