Results 1 to 9 of 9

Thread: [CoD] File Formats

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    CoD2 D3DBSP

    Tech: LuaJIT + FFI for C-structs

    Toujane example
    Click image for larger version. 

Name:	codu.jpg 
Views:	161 
Size:	594.7 KB 
ID:	587

    Movement:

    WASD for Position
    Arrow Keys for Camera
    Q/E for Camera Down/Up (like in CoD2)

    PHP Code:
    typedef struct
    {
        
    float position[3];
        
    float normal[3];
        
    int bla[11];
    aDrawVert;

    typedef struct
    {
        
    int length;
        
    int offset;
    aLump;

    typedef struct
    {
        
    char ident[4];
        
    int version;
        
    aLump lumps[100];
    aHeader;

    typedef struct
    {
        
    short index[3];
    aTriangle// depricated

    typedef struct
    {
        
    unsigned short offset;
        
    //unsigned short b;
        //unsigned short c;
    aDrawIndex;

    /*typedef struct
    {
        unsigned short a;
        unsigned short b;
        unsigned short c;
    } aDrawIndex;*/


    // is empty in mp_analyse1
    typedef struct
    {
        
    float position[3];
    aCollisionVert;

    typedef struct
    {
        
    int planeIndex;
        
    int children[2];
        
    int mins[3];
        
    int maxs[3];
    aNode;

    typedef struct
    {
        
    //int cluster; // ???
        //int area; // ???
        //int mins[3]; // ???
        //int maxs[3]; // ???
        //int faceFirst;
        //int faceCount;
        //int brushFirst;
        //int brushCount;
        
    int someA[4];
        
    int firstLeafBrush// lookup in leafbrushes
        
    int numLeafBrushes;
        
    int someB[3];
    aLeaf;

    typedef struct
    {
        
    unsigned short bla;
        
    unsigned short foo;
        
    unsigned int vertexFirst;
        
    unsigned short nVertex;

        
    unsigned short nTriangles;
        
    unsigned int triangleFirst;
    aTriangleSoup
    Draw all triangle faces:
    PHP Code:

    function bspdraw()

        
    colors = {
            {
    000},
            {
    001},
            {
    010},
            {
    011},
            {
    100},
            {
    101},
            {
    110},
            {
    111}
        }

        for 
    0,nTriangleSoups-do
            
    soup triangleSoups i
            
            gl
    .glBegin(gl.GL_TRIANGLES)
            for 
    nTriangles 0soup.nTriangles-do
                
    drawIndex drawIndexes + (soup.triangleFirst nTriangles)
                
                
    co colors[(nTriangles%8) + 1]
                
    gl.glColor3f(co[1], co[2], co[3])
                
                
    a  vertices + (drawIndex.offset soup.vertexFirst)
                
    gl.glVertex3fv(a.position)
            
    end
            gl
    .glEnd()
        
    end
    end 
    Serthy, could you post your full solution of how to use your structs? That would help alot
    Attached Files Attached Files
    timescale 0.01

  2. The Following 2 Users Say Thank You to kung foo man For This Useful Post:

    php (5th January 2014),smect@ (5th January 2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •