Motion2 to motion3 help

06/08/2022 11:06 zahter55#1
I found what i look for. So as before on my searching post DOS wrote structure and hex editing method. But hex editing motion2 to motion3 doesnt work on me. How can i convert this motion2 file to 3. Is there an easy way? How can i use structure? Thx for any help
[IMG=expandable: 1][Only registered and activated users can see links. Click Here To Register...][/IMG]
06/12/2022 12:41 zahter55#2
if u wanna look inside share any process pls
virustotal
[Only registered and activated users can see links. Click Here To Register...]
06/12/2022 21:48 RHNbaskan#3
bu nedir dostum
06/25/2022 20:08 lnwnuyhodd#4
some bone is not not working
Code:
#ifndef halloc
#define halloc( size ) HeapAlloc( GetProcessHeap(), 0, size )
#endif
#ifndef hfree
#define hfree( ptr ) if( ptr ){ HeapFree( GetProcessHeap(), 0, ptr ); ptr = NULL; }
#endif
#define TRACE()
class FHandle
{
public:
    HANDLE hFile;
    FHandle( char* tFileName )
    {
        hFile = CreateFileA( tFileName, 0x40000000u, 2u, 0, 2u, 0x80u, 0 );
    }
    ~FHandle()
    {
        if (hFile)
            CloseHandle(hFile);
        hFile = NULL;
    }    
    BOOL Write( void* value, int len )
    {
        if( !value || len < 1 ) return FALSE;
        if( hFile == INVALID_HANDLE_VALUE ) return FALSE;

        DWORD n;
        BOOL ret = WriteFile( hFile, value, len, &n, 0 );
        return ret && (int)n == len;
    }
};
class ZCompress
{
public:
    BYTE* tOriginal;
    DWORD tOriginalSize;
    BYTE* tCompress;
    DWORD tCompressSize;
    ZCompress()
    {
        tOriginal = 0;
        tOriginalSize = 0;
        tCompress = 0;
        tCompressSize = 0;
    }
    BOOL CreateOriginal( int size  )
    {
        tOriginalSize = size;
        tOriginal = (BYTE*)halloc( tOriginalSize );
        if( !tOriginal )
            return 0;
        return 1;
    }
    BOOL CreateCompress()
    {
        if( !CGXD::GetCompressSize( tOriginalSize, tOriginal, &tCompressSize ) )
            return 0;
        tCompress = (BYTE*)halloc( tOriginalSize );
        if( !tCompress )
            return 0;
        return 1;
    }
    ~ZCompress()
    {
        hfree(tOriginal);
        hfree(tCompress);
    }
};
BOOL GXD_SaveToMOTION3( MOTION_FOR_GXD* This )
{
    MOTION_FOR_GXD::Init(This);
    MOTION_FOR_GXD::Load(This, "G03_GDATA\\D03_GMOTION\\001\\C002001085_old.MOTION");

    TRACE();
    if (!This->mCheckValidState)
        return 0;
    TRACE();
    if (This->mFrameNum<1||This->mBoneNum < 1)
        return 0;

    TRACE();
    FHandle f("G03_GDATA\\D03_GMOTION\\001\\C002001085.MOTION");
    TRACE();
    char sig[] = { 'M', 'O', 'T', 'I', 'O', 'N', '3', 1, 1, 0, 0 };
    if( !f.Write( sig, sizeof(sig) ) )
        return 0;
    TRACE();
    
    printf( "%d:%d\n",This->mFrameNum, This->mBoneNum );

    int matrixSize = (This->mBoneNum * This->mFrameNum);
    int saveSize = 28 * matrixSize;
    ZCompress z;
    if( !z.CreateOriginal( 4 + 4 + saveSize ) )
        return 0;
    memcpy( &z.tOriginal[0], &This->mFrameNum, 4 );
    memcpy( &z.tOriginal[4], &This->mBoneNum, 4 );

    D3DXQUATERNION pOut;
    D3DXVECTOR3 pTrans;
    D3DXVECTOR3 pScale;
    D3DXMATRIX* mx;
    int pos = 8;
    for (int i = 0; i < matrixSize; i++ ) {
        mx = &This->mKeyMatrix[i];
        D3DXMatrixDecompose( &pScale, &pOut, &pTrans, mx );
        //D3DXQuaternionRotationMatrix( &pOut, mx );
        memcpy( &z.tOriginal[pos], &pOut, 16 );
        memcpy( &z.tOriginal[pos+16], &mx->_41, 4 );
        memcpy( &z.tOriginal[pos+20], &mx->_42, 4 );
        memcpy( &z.tOriginal[pos+24], &mx->_43, 4 );
        pos += 28;
    }

    if( !z.CreateCompress() )
        return 0;
    TRACE();

    BOOL ret = CGXD::Compress( z.tOriginalSize, z.tOriginal, z.tCompressSize, z.tCompress );
    if ( ret )
    {
        TRACE();
        return f.Write( &z.tOriginalSize, 4 ) && f.Write( &z.tCompressSize, 4 ) && f.Write( z.tCompress, z.tCompressSize );
    }

    TRACE();
    return 0;
}

//usage
MOTION_FOR_GXD mot;
BOOL GXD_SaveToMOTION3(MOTION_FOR_GXD* This);
GXD_SaveToMOTION3(&mot);