Offtopic: Into Commodore 64 (6502) coding, pixeling or music?
Xentax is looking for new members for the C64 activities!
Just drop us a message at forum@xentax.com and join the Scene Team!

Forum rules: Click here

[Request]COD3 mesh fix and import script

Post questions about game models here, or help out others!
Post Reply
luxox18
mega-veteran
mega-veteran
Posts: 176
Joined: Fri Jul 29, 2011 9:18 pm
Has thanked: 54 times
Been thanked: 41 times

[Request]COD3 mesh fix and import script

Post by luxox18 » Fri Oct 25, 2013 3:51 am

shakotay2 has found the way for convert the meshes from call of duty 3 to obj with uv, but the face indices are damaged
he say that the models are in half floats

Image

Image

someone knows how to fix this? and... is possible create a importer script?

the eichar.cod contains all data including textures, and the single ps3mesh file is the model:
http://www.mediafire.com/download/m1hvj ... acters.RAR
here other bundles: http://www.mediafire.com/download/1ncp0 ... c/char.rar


thanks

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2819
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 702 times
Been thanked: 1452 times

Re: [Request]COD3 mesh fix and import script

Post by shakotay2 » Fri Oct 25, 2013 12:23 pm

The faces are tri stripped:
Image Image

The problem is to replace the FF FF indices. I used the previous index but this does not seem to be correct.

edit: hmm, yes, the solution seems to be to start a new read of f1 and f2 after encountering FF FF.

edit2: weird. Seems FF FF indicates a change of the faces' orientation. Means half of the texture is outside the other half inside.

So I changed the orientation of the newly read f1,f2,f3 but at no avail.
This seems to be above my imagination. :D
Last edited by shakotay2 on Sat Oct 26, 2013 9:20 pm, edited 1 time in total.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

User avatar
howfie
double-veteran
double-veteran
Posts: 929
Joined: Fri Jul 08, 2011 12:06 pm
Location: Torrance, CA
Has thanked: 9 times
Been thanked: 263 times

Re: [Request]COD3 mesh fix and import script

Post by howfie » Sat Oct 26, 2013 1:25 am

if you are using c++ i can give my strip cut index code. u don't change the winding order on every reset, though I've seen a problem like this before (tekken hybrid). rich though i might have been missing a flag or something but i could never find it so i did what only the desperate would do... the vertex normals were good so based on that i flipped the polygons.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2819
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 702 times
Been thanked: 1452 times

Re: [Request]COD3 mesh fix and import script

Post by shakotay2 » Sat Oct 26, 2013 6:09 am

howfie wrote:if you are using c++ i can give my strip cut index code.
Yep - (it's "normal" C but) that would be very nice.
rich though i might have been missing a flag or something but
this seems to be my problem, too.
i could never find it so i did what only the desperate would do... the vertex normals were good so based on that i flipped the polygons.
Yes, desperate I am... :D
I'm calculating surfcace normals but I have no clue how to decide whether they point into or outside the head.

For example these two having the same direction:
Image

I know "normals point towards the side from which the vertices appear in counterclockwise order"
but seems I'll have to understand back face culling, too?
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

User avatar
howfie
double-veteran
double-veteran
Posts: 929
Joined: Fri Jul 08, 2011 12:06 pm
Location: Torrance, CA
Has thanked: 9 times
Been thanked: 263 times

Re: [Request]COD3 mesh fix and import script

Post by howfie » Sat Oct 26, 2013 3:14 pm

Pseudo-code to convert tristrips with strip-cut indices to triangle lists.

Code: Select all

struct TriangleList {
 boost::shared_array<uint16> data;
 uint32 n_indices;
 uint32 triangles;
};

bool ConvertStripCutToTriangleList(const uint16* src, uint32 n, TriangleList& dst, uint16 terminal = 0xFFFF)
{
 // validate
 if(!src || !n) return false;
 if(n < 3) return false;

 // compute number of triangles
 uint32 n_triangles = 0;
 uint32 a = 0;
 uint32 b = 0;
 for(;;)
    {
     // must stop
     if(b == n) {
        if(src[n - 1] != terminal) {
           uint32 distance = b - a;
           if(distance < 3) return false;
           n_triangles += distance - 2;
          }
        break;
       }

     // hit terminal index
     if(src[b] == terminal) {
        uint32 distance = b - a;
        if(distance < 3) return false;
        n_triangles += distance - 2;
        a = b + 1;
        b = a;
       }
     // non-terminal index
     else
        b++;
    }

 // initialize destination data
 dst.triangles = n_triangles;
 dst.n_indices = n_triangles * 3;
 dst.data.reset(new uint16[dst.n_indices]);

 // initialize second pass data
 uint16* ptr = dst.data.get();
 uint32 dst_index = 0;
 uint32 src_index = 0;

 // second pass through source
 do {

     // keep track of tristrip index
     uint32 tristrip_index = 0;

     // copy first triangle
     uint16 a = src[src_index++];
     uint16 b = src[src_index++];
     uint16 c = src[src_index++];
     ptr[dst_index++] = a;
     ptr[dst_index++] = b;
     ptr[dst_index++] = c;
     tristrip_index++;
    
     // copy other triangles
     while(src_index < n) {
         a = b;
         b = c;
         c = src[src_index++];
         if(c == terminal) break;
         if(tristrip_index % 2) {
            ptr[dst_index++] = a;
            ptr[dst_index++] = c;
            ptr[dst_index++] = b;
           }
         else {
            ptr[dst_index++] = a;
            ptr[dst_index++] = b;
            ptr[dst_index++] = c;
           }
         tristrip_index++;
        }
    }
 while(src_index < n);

 return true;
}

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2819
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 702 times
Been thanked: 1452 times

Re: [Request]COD3 mesh fix and import script

Post by shakotay2 » Sat Oct 26, 2013 9:03 pm

Thank you very much! :)

Just to be sure : I need the boost library to use this?

Hopefully it will solve this prob:
Image

It's the "submesh" before the first FF FF separator ("terminal") where I think the normals marked with a thin white line have the wrong direction.
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

User avatar
howfie
double-veteran
double-veteran
Posts: 929
Joined: Fri Jul 08, 2011 12:06 pm
Location: Torrance, CA
Has thanked: 9 times
Been thanked: 263 times

Re: [Request]COD3 mesh fix and import script

Post by howfie » Sun Oct 27, 2013 7:05 am

oh, the geometry even before the first terminal is messed up? you dont need boost, just replace it with you own memory management scheme.

User avatar
Bastien
advanced
Posts: 69
Joined: Sun Apr 15, 2012 1:08 am
Has thanked: 26 times
Been thanked: 12 times

Re: [Request]COD3 mesh fix and import script

Post by Bastien » Sun Oct 27, 2013 10:05 pm

luxox18 wrote:shakotay2 has found the way for convert the meshes from call of duty 3 to obj with uv, but the face indices are damaged
he say that the models are in half floats
Hey, have you checked this blender add-on? it has export-import functions for many COD titles, not entirely sure if COD3 works, but code can help.

https://code.google.com/p/blender-cod/

luxox18
mega-veteran
mega-veteran
Posts: 176
Joined: Fri Jul 29, 2011 9:18 pm
Has thanked: 54 times
Been thanked: 41 times

Re: [Request]COD3 mesh fix and import script

Post by luxox18 » Mon Oct 28, 2013 1:01 am

Bastien wrote: Hey, have you checked this blender add-on? it has export-import functions for many COD titles, not entirely sure if COD3 works, but code can help.

https://code.google.com/p/blender-cod/
This script is for import models to a call of duty format , not for convert the models from COD3 to obj , etc.

Call of duty 3 not use xmodels.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 2819
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 702 times
Been thanked: 1452 times

Re: [Request]COD3 mesh fix and import script

Post by shakotay2 » Mon Oct 28, 2013 3:55 pm

howfie wrote:oh, the geometry even before the first terminal is messed up?
it's the first "submesh" only. Don't think it's messed up but the normals directions are, imho.

Finally I managed to use your code but maybe I did something wrong:
Image

edit: yes, I surely did :D :
Image Very fine!

Few normals at ears and mouth pointing inside. But does not seem to affect the texture.
This is how I used your code (in case someone else faces this prob):

Code: Select all

#include <boost/shared_array.hpp>
const WORD* src ;

struct TriangleList {
boost::shared_array<WORD> data;
DWORD n_indices;
DWORD triangles;
} dst ;

//Modification in ConvertStripCutToTriangleList() due to big endian indices:

     WORD aBE = src[src_index++]; WORD a= (aBE % 256) * 256 + aBE/256 ;
     WORD bBE = src[src_index++]; WORD b= (bBE % 256) * 256 + bBE/256 ;
     WORD cBE = src[src_index++]; WORD c= (cBE % 256) * 256 + cBE/256 ;

     ...
     cBE = src[src_index++]; c= (cBE % 256) * 256 + cBE/256 ;

   main() {
         boost::shared_array<WORD> dst.data(new WORD[65535]);
	// loading of model data at lpFBuf, face indices start address= 0xAB30        // 2* 0x5598 
	 src = (WORD *) lpFBuf ; src += 0x5598 ;
	 ConvertStripCutToTriangleList(src, 4417, dst, 0xFFFF) ;   // 4417= face indices count
}
Thx again, sire! :)
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

luxox18
mega-veteran
mega-veteran
Posts: 176
Joined: Fri Jul 29, 2011 9:18 pm
Has thanked: 54 times
Been thanked: 41 times

Re: [Request]COD3 mesh fix and import script

Post by luxox18 » Mon Oct 28, 2013 11:07 pm

shakotay2 wrote:
edit: yes, I surely did :D :
Image Very fine!
Wow! good news! :)

luxox18
mega-veteran
mega-veteran
Posts: 176
Joined: Fri Jul 29, 2011 9:18 pm
Has thanked: 54 times
Been thanked: 41 times

Re: [Request]COD3 mesh fix and import script

Post by luxox18 » Thu Nov 07, 2013 12:40 am

with the HEX2OBJ tool we can convert all models from this game. viewtopic.php?f=29&t=10894

thanks to shakotay2

this is the results

Image

Post Reply