Monday, March 8, 2010

m3_viewer Star Craft 2 build 0.02.

m3_viewer has updated. download_link
In this release :
          - convert to .obj file;
          - normal show turn on\off;
          - light turn on\off.
 

  

 

.gEngine with .m3 model

I post screenshots from my game engine "gEngine". I develop it 1.5 year. GAPI is DirectX 9.0. 

Development :
       Scene:
            Chancked terrain ( realtime preload in second thread);
            StaticMeshes;
            DynamicMeshes ( only morph animation);
            SkyDome ( atmospheric scattering);
            WaterPlane ( reflection );
            Dynamic Grass;
            LevelManager ( manage level resource for instancing render );
            ResourceService : ( services for managing game resources );
                              ShaderService;
                              TexturesService;
                              StaticModelService;
                              DynamicModelService;
                              MapChankPreloadService;
       FileFomat's :
            .md2 ( Quake 2 morph animation );
            .m2   ( World of Warcraft static models );
            .m3   ( Star Craft 2 static models );
       Shaders :
            Lighting ( diffuse, specular, self shadowing);
            Parallax Mapping ( static models, terrain );
           
Atmospheric Scattering ( for SkyDome );
            Reflection Mapping ( for water plane );
            Shadow Mapping ( only for terrain );
            Post Effect Bloom;

Some screenshots from gEngine:








m3_viewer Star Craft 2 build 0.01.

I upload some tool to view .m3 mesh. I'll plan add converter to .obj file format. You can download binary file's from download_link .

struct M3VertexBlock
{
    D3DXVECTOR3 position;
    short value[12]; // array of unknown values. I try cast it's to normal and texture coordinates, but does't work. 6,7 - are texture coordinates /2048.
};

struct M3Header
{
        char id[4];// id for file format.
        uint32 tagsOffset;// offset to array of the tags.
        uint32 nTags;// number of tags.
        uint32 unknownValue_01;
        uint32 unknownValue_02;
};

struct M3Tag
{
        char tagName[4];// name ot the current tag.
        uint32 blockOffset;// offset reference to the block with some data.
        uint32 blockSize; //  count of the block.
        uint32 version;
};

void ReadFile(char* name)
{
         char *fileData;

         ifstream inStream;
         inStream.open(name,ios::in | ios::binary);
         inStream.seekg (0, std::ios::end);
         int fileSize = inStream.tellg();
         inStream.seekg (0, std::ios::beg);
         fileData= new char[fileSize];
         inStream.read(fileData,fileSize);
         inStream.close();

         M3Header headed;
         memcpy(&header, fileData, sizeof(M3Header));

         tags = (M3Tag *)(fileData+ header.tagsOffset);

         M3VertexBlock* vertexBlock;
         unsigned int nVertecesM3 = 0;
         unsigned int nIndicesM3 = 0;
         unsigned short * indexBlock;
         bool firstIndexTag = false;

         for(int i = 0; i < header.nTags; ++i)
        {
                if( tags[i].tagName[2] == '8') && (tags[i].tagName[3] == 'U') // __8U - reference to vertex data.
               {
                      nVertecesM3 = (tags[i].blockSize)/sizeof(M3VertexBlock);
                      vertexBlock= (M3VertexBlock*)(fileData+ tags[i].blockOffset);
               }

               if((tags[i].tagName[1] == '6') && (tags[i].tagName[2] == '1') && (tags[i].tagName[3] == 'U'))  // _61U - reference to index data.
              {
                    if(firstIndexTag) continue;
                    firstIndexTag = true;
                    nIndicesM3 = tags[i].blockSize;
                    indexBlock = (short*)(fileData+ tags[i].blockOffset);
             }
      }
}