[Release] GB-Structure C++

Results 1 to 7 of 7
  1. #1
    Account Upgraded | Title Enabled! BakaBug is offline
    MemberRank
    Jul 2006 Join Date
    noitacoLLocation
    1,193Posts

    [Release] GB-Structure C++

    PHP Code:
    #include <iostream>
    #include <iomanip>
    #include <fstream>
    #include <string>
    #include <vector>

    using std::cout;
    using std::cin;
    using std::endl;

    typedef
    #pragma pack(1)
    struct t_Vector3
    {
        
    DWORD x;
        
    DWORD y;
        
    DWORD z;
    Vector3;

    typedef
    #pragma pack(1)
    struct t_gb_ver_08
    {
        
    BYTE    Version;
        
    BYTE    BoneCount;
        
    BYTE    BoneIdentifier;
        
    BYTE    MaterialCount;
        
    //DWORD    CheckSum;
        //char    Name[64];
        
    DWORD    NameLength;
        
    WORD    TotalVertexCount[6];
        
    WORD    TotalIndexCount;
        
    WORD    TotalBoneCount;
        
    WORD    TotalKeyFrameCount;
        
    WORD    Unknown0;
        
    WORD    MaterialDescriptorLength;
        
    WORD    Unknown1;
        
    WORD    KeyFrameTransformationCount;
        
    BYTE    AnimationCount;
        
    WORD    MeshCount;
        
    WORD    Unknown2;
        
    //Vector3    BoundingBoxMin;
        //Vector3 BoundingBoxMax;
        //Vector3    BoundingSphereCenter;
        //float    BoundingSphereRadius;
    GB_V08;

    typedef
    #pragma pack(1)
    struct t_gb_ver_09
    {
        
    BYTE    Version;
        
    BYTE    BoneCount;
        
    BYTE    BoneIdentifier;
        
    BYTE    MaterialCount;
        
    //DWORD    CheckSum;
        //char    Name[64];
        
    DWORD    NameLength;
        
    WORD    TotalVertexCount[12];
        
    WORD    TotalIndexCount;
        
    WORD    TotalBoneCount;
        
    WORD    TotalKeyFrameCount;
        
    WORD    ukwn0;
        
    WORD    MaterialDescriptorLength;
        
    WORD    ukwn3;
        
    DWORD    CollisionSize;
        
    WORD    KeyFrameTransformationCount;
        
    BYTE    AnimationCount;
        
    BYTE    ukwn1;
        
    WORD    MeshCount;
        
    WORD    Unknown2;
        
    //Vector3    BoundingBoxMin;
        //Vector3 BoundingBoxMax;
        
    Vector3    BoundingSphereCenter;
        
    float    BoundingSphereRadius;
    GB_V09;

    typedef
    #pragma pack(1)
    struct t_gb_ver_0a
    {
        
    BYTE    Version;
        
    BYTE    BoneCount;
        
    BYTE    BoneIdentifier;
        
    BYTE    MaterialCount;
        
    DWORD    CheckSum;
        
    //char    Name[64];
        
    DWORD    NameLength;
        
    WORD    TotalVertexCount[12];
        
    WORD    TotalIndexCount;
        
    WORD    TotalBoneCount;
        
    WORD    TotalKeyFrameCount;
        
    WORD    ukwn0;
        
    WORD    MaterialDescriptorLength;
        
    WORD    ukwn3;
        
    DWORD    CollisionSize;
        
    WORD    KeyFrameTransformationCount;
        
    BYTE    AnimationCount;
        
    BYTE    ukwn1;
        
    WORD    MeshCount;
        
    WORD    Unknown2;
        
    //Vector3    BoundingBoxMin;
        //Vector3 BoundingBoxMax;
        
    Vector3    BoundingSphereCenter;
        
    float    BoundingSphereRadius;
    GB_V10;

    typedef
    #pragma pack(1)
    struct t_gb_ver_0B
    {
        
    BYTE    Version;
        
    BYTE    BoneCount;
        
    BYTE    BoneIdentifier;
        
    BYTE    MaterialCount;
        
    DWORD    CheckSum;
        
    //char    Name[64];
        
    DWORD    NameLength;
        
    WORD    TotalVertexCount[12];
        
    WORD    TotalIndexCount;
        
    WORD    TotalBoneCount;
        
    WORD    TotalKeyFrameCount;
        
    WORD    ukwn0;
        
    WORD    MaterialDescriptorLength;
        
    WORD    ukwn3;
        
    DWORD    CollisionSize;
        
    WORD    KeyFrameTransformationCount;
        
    BYTE    AnimationCount;
        
    BYTE    ukwn1;
        
    WORD    MeshCount;
        
    WORD    Unknown2;
        
    Vector3    BoundingBoxMin;
        
    Vector3 BoundingBoxMax;
        
    Vector3    BoundingSphereCenter;
        
    float    BoundingSphereRadius;
    GB_V11;

    typedef
    #pragma pack(1)
    struct t_gb_ver_0c
    {
        
    BYTE    Version;
        
    BYTE    BoneCount;
        
    BYTE    BoneIdentifier;
        
    BYTE    MaterialCount;
        
    DWORD    CheckSum;
        
    char    Name[64];
        
    DWORD    NameLength//includes sizeof(CheckSum)
        
    WORD    TotalVertexCount[12];
        
    WORD    TotalIndexCount;
        
    WORD    TotalBoneCount;
        
    WORD    TotalKeyFrameCount;
        
    WORD    Unknown0;
        
    WORD    MaterialDescriptorLength;
        
    WORD    Unknown1;
        
    DWORD    CollisionSize;
        
    WORD    KeyFrameTransformationCount;
        
    WORD    AnimationCount;
        
    WORD    MeshCount;
        
    WORD    Unknown2;
        
    Vector3    BoundingBoxMin;
        
    Vector3 BoundingBoxMax;
        
    Vector3    BoundingSphereCenter;
        
    float    BoundingSphereRadius;
    GB_V12;

    typedef
    #pragma pack(1)
    struct t_gb_material_header
    {
        
    DWORD    TextureFileNameOffset;
        
    WORD    Unknown0;
        
    DWORD    TextureFileNameLength;
        
    WORD    Unknown1;
        
    WORD    Unknown2;
        
    DWORD    MaterialOffset;
    GB_MATERIAL_HEADER;
    // DWORD WORD DWORD DWORD DWORD
    typedef
    #pragma pack(1)
    struct t_gb_mesh_header
    {
        
    DWORD    NameOffset;
        
    DWORD    MaterialIndex;
        
    BYTE    VertexType;
        
    BYTE    PrimitiveType;
        
    WORD    VertexCount;
        
    WORD    IndexCount;
        
    BYTE    BoneCount;
    GB_MESH_HEADER;

    typedef
    struct  
    {
        
    D3DCOLOR    Ambient;//D3DCOLOR_ARGB
        
    D3DCOLOR    Diffuse;
        
    D3DCOLOR    Specular;
        
    float        Opacity//1 = max
        
    float        Shine;
        
    float        ShineStrength;
        
    float        Transparency;
        
    float        Wiresize;
        
    float        SelfIllum;
    GB_MATERIAL
    It's everything you need to load a GB .. nothing more .. and about where is vertex data where is index data ... HUCH Oo you can load them direct

    PHP Code:
    meshes[i].VertexSize 32+((VertexType 5) * 4);
    ...
    ...
    /* For files with bones FVF = FVF | BONE */
    switch (VertexType)
            {
            case 
    0:
                
    printf("FVF_0\n"); //correct
                
    meshes[i].FVF D3DFVF_XYZ D3DFVF_NORMAL D3DFVF_TEX1;
                break;
            case 
    1:
                
    printf("FVF_1\n");
                
    meshes[i].FVF D3DFVF_XYZ D3DFVF_SPECULARD3DFVF_NORMAL D3DFVF_TEX1;
                break;
            case 
    2:
                
    printf("FVF_2\n"); //correct
                
    meshes[i].FVF D3DFVF_XYZB1 D3DFVF_SPECULAR D3DFVF_NORMAL D3DFVF_TEX1;
                break;
            case 
    3:
                
    printf("FVF_3\n");
                
    meshes[i].FVF D3DFVF_XYZB2 D3DFVF_SPECULAR D3DFVF_NORMAL D3DFVF_TEX1;
                break;
            case 
    4:
                
    printf("FVF_4\n");
                
    meshes[i].FVF D3DFVF_XYZB3 D3DFVF_SPECULAR D3DFVF_NORMAL D3DFVF_TEX1;
                break;
            default:
                
    printf("unknown vertextype\n");
            }

    ...
    ...

    // Create + Initialize vertexbuffer //
            
    D3DDevice->CreateVertexBuffer(
                
    gbMeshHeader->VertexCount meshes[i].VertexSize
                
    0D3DFVFD3DPOOL_MANAGED, &meshes[i].D3DVertexBuffer0);

            
    LPVOID pVertices;
            
    meshes[i].D3DVertexBuffer->Lock(0gbMeshHeader->VertexCount meshes[i].VertexSize, &pVerticesD3DLOCK_NOSYSLOCK);
            
    CopyMemory(pVerticesseekergbMeshHeader->VertexCount meshes[i].VertexSize);
            
    meshes[i].D3DVertexBuffer->Unlock();

            
    seeker += gbMeshHeader->VertexCount meshes[i].VertexSize;
            
    //***********************************
            // Create + Initialize indexbuffer //
            
    D3DDevice->CreateIndexBuffer(
                
    gbMeshHeader->IndexCount sizeof(WORD), 
                
    0D3DFMT_INDEX16D3DPOOL_MANAGED, &meshes[i].D3DIndexBufferNULL);

            
    LPVOID pIndices;
            
    meshes[i].D3DIndexBuffer->Lock(0gbMeshHeader->IndexCount sizeof(WORD), &pIndicesD3DLOCK_NOSYSLOCK);
            
    CopyMemory(pIndicesseekergbMeshHeader->IndexCount sizeof(WORD));
            
    meshes[i].D3DIndexBuffer->Unlock(); 
    as you see .. direct copy from memory into mesh-data..
    it's easy for everyone who knows the basics of GB..
    and 3D programming ! and about material -.- peeh you should know that
    the material-header saves the relative offsets from the footer


  2. #2
    Proficient Member mejniok is offline
    MemberRank
    Sep 2006 Join Date
    PolandLocation
    164Posts

    Re: [Release] GB-Structure C++

    Holy shit, great release :P
    Ty...

  3. #3
    Account Upgraded | Title Enabled! BakaBug is offline
    MemberRank
    Jul 2006 Join Date
    noitacoLLocation
    1,193Posts

    Re: [Release] GB-Structure C++


  4. #4
    Arrogant Wizard DeathArt is offline
    MemberRank
    Mar 2007 Join Date
    StockholmLocation
    2,657Posts

    Re: [Release] GB-Structure C++

    Bakabug you should check the updated spec i my Geometry Binary Viewer dev post, there is a few things changed regarding the unknowns and types ;-)

  5. #5
    Account Upgraded | Title Enabled! mns is offline
    MemberRank
    Sep 2006 Join Date
    Oceanside, California.Location
    502Posts

    Re: [Release] GB-Structure C++

    Code:
    using std::cout;
    using std::cin;
    using std::endl;
    Is the same as:

    Code:
    using namespace std;
    It's shorter and works for all code.

  6. #6
    Account Upgraded | Title Enabled! BakaBug is offline
    MemberRank
    Jul 2006 Join Date
    noitacoLLocation
    1,193Posts

    Re: [Release] GB-Structure C++

    Quote Originally Posted by mns View Post
    Code:
    using std::cout;
    using std::cin;
    using std::endl;
    Is the same as:

    Code:
    using namespace std;
    It's shorter and works for all code.
    Change it when you want.. lol I don't care..

  7. #7
    Proficient Member Mr.wagdy is offline
    MemberRank
    Sep 2006 Join Date
    EgyptLocation
    187Posts

    Re: [Release] GB-Structure C++

    Oo i don't know about that !! but thx anyway ^^



Advertisement