Exemplo n.º 1
0
int CEQUFile::WriteEQUFile( char* filename, int* motidarray, int motnum, 
	CTreeHandler2* lpth, CShdHandler* lpsh, CMotHandler* lpmh )
{
	m_lpth = lpth;
	m_lpsh = lpsh;
	m_lpmh = lpmh;

	int ret;
	ret = MakeJointArray();
	if( ret ){
		DbgOut( "EQUFile : WriteEQUFile : MakeJointArray error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	if( m_jointnum <= 0 ){
		_ASSERT( 0 );
		return 0;
	}

	m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( m_hfile == INVALID_HANDLE_VALUE ){
		DbgOut( "EQUFile : WriteEQUFile : file open error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	m_mode = EQUFILE_WRITE;	

	ret = Write2File( 0, equheader );
	_ASSERT( !ret );
///////
	ret = Write2File( 1, "<AnimNum>%d</AnimNum>\r\n\r\n", motnum );
	_ASSERT( !ret );

	int motcnt;
	for( motcnt = 0; motcnt < motnum; motcnt++ ){
		int motid = *( motidarray + motcnt );
		if( (motid < 0) || (motid >= m_lpmh->m_kindnum) ){
			DbgOut( "EQUFile : WriteEQUFile : motid error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}

		ret = WriteAnimation( motid );
		if( ret ){
			DbgOut( "EQUFile : WriteEQUFile : WriteAnimation error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
	}
///////

	ret = Write2File( 0, "</EQU>\r\n" );
	_ASSERT( !ret );

	return 0;
}
Exemplo n.º 2
0
int CEQUFile::WriteBoneAnim( int motid, CMotionCtrl* mcptr )
{
	int ret;
   
	ret = Write2File( 2, "<BoneAnim>\r\n" );
	_ASSERT( !ret );

	CTreeElem2* jte;
	jte = (*m_lpth)( mcptr->serialno );
	_ASSERT( jte );
	ret = Write2File( 3, "<BoneName>%s</BoneName>\r\n", jte->name );
	_ASSERT( !ret );

	CMotionInfo* miptr = mcptr->motinfo;
	if( !miptr ){
		DbgOut( "EQUFile : WriteBoneAnim : miptr NULL error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}
	CMotionPoint2* mphead = miptr->GetMotionPoint( motid );

	int mpnum = 0;
	CMotionPoint2* curmp = mphead;
	while( curmp ){
		mpnum++;
		curmp = curmp->next;
	}

	ret = Write2File( 3, "<KeyNum>%d</KeyNum>\r\n", mpnum );
	_ASSERT( !ret );

	int wcnt = 0;
	curmp = mphead;
	while( curmp ){
		ret = WriteAnimKey( curmp );
		if( ret ){
			DbgOut( "EQUFile : WriteBoneAnim : WriteAnimKey error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
		wcnt++;
		curmp = curmp->next;
	}

	if( wcnt != mpnum ){
		DbgOut( "EQUFile : WriteBoneAnim : wcnt error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	ret = Write2File( 2, "</BoneAnim>\r\n" );
	_ASSERT( !ret );


	return 0;
}
Exemplo n.º 3
0
int CEQUFile::WriteAnimation( int motid )
{
	int ret;
 
	CMotionCtrl* mcptr = (*m_lpmh)( 1 );
	if( !mcptr ){
		_ASSERT( 0 );
		return 1;
	}
	CMotionInfo* miptr = mcptr->motinfo;
	if( !miptr ){
		_ASSERT( 0 );
		return 1;
	}
	if( !(miptr->motname) ){
		_ASSERT( 0 );
		return 1;
	}
	char* szName;
	szName = *(miptr->motname + motid );

	int frameleng;
	frameleng = *(miptr->motnum + motid);

	ret = Write2File( 1, "<Animation>\r\n" );
	_ASSERT( !ret );

	ret = Write2File( 2, "<AnimName>%s</AnimName>\r\n", szName );
	_ASSERT( !ret );

	ret = Write2File( 2, "<FrameLeng>%d</FrameLeng>\r\n", frameleng );
	_ASSERT( !ret );

	ret = Write2File( 2, "<BoneAnimNum>%d</BoneAnimNum>\r\n\r\n", m_jointnum );
	_ASSERT( !ret );

	CMotionCtrl* jointmc;
	int jcnt;
	for( jcnt = 0; jcnt < m_jointnum; jcnt++ ){
		int jseri = *( m_jointarray + jcnt );
		jointmc = (*m_lpmh)( jseri );
		_ASSERT( jointmc );

		ret = WriteBoneAnim( motid, jointmc );
		if( ret ){
			DbgOut( "EQUFile : WriteAnimation : WriteBoneAnim error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
	}

	ret = Write2File( 1, "</Animation>\r\n\r\n" );
	_ASSERT( !ret );

	return 0;
}
Exemplo n.º 4
0
int	CVecLine::DumpMem( HANDLE hfile, int tabnum, int dumpflag )
{
	int i;
	int ret;
	int totalnum;
	VEC3F* curvec = 0;
	float tempx, tempy, tempz;

	static int dbgcnt = 0;

	ret = CBaseDat::DumpMem( hfile, tabnum, "3DOBJ" );
	if( ret ){
		DbgOut( "charpos2.cpp : CVecLine : DumpMem : CBaseDat : DumpMem error !!!\n" );
		return 1;
	}

	tabnum++;
	SetTabChar( tabnum );

	if( meshinfo ){
		ret = meshinfo->DumpMem( hfile, tabnum, dumpflag );
		if( ret ){
			DbgOut( "charpos2.cpp : CVecLine : DumpMem : meshinfo->DumpMem error !!!\n" );
			return 1;
		}
			
		if( dumpflag & DISP_VERTEX ){
			// line header
			totalnum = meshinfo->total;
			ret = Write2File( hfile, "%s LINE VEC\n", tabchar );
			_ASSERT( !ret );

			// line vec
			for( i = 0; i < totalnum; i++ ){
				curvec = vec + i;
				tempx = curvec->x;
				tempy = curvec->y;
				tempz = curvec->z;
			
				ret = Write2File( hfile, "%s X : %f, Y : %f, Z : %f\n",
					tabchar, tempx, tempy, tempz );
				_ASSERT( !ret );
			}
		}			
	}else{
		ret = Write2File( hfile, "%s VecLine not created !!! skip dump\n", tabchar );
		_ASSERT( !ret );
	}

	return ret;
}
Exemplo n.º 5
0
int CCameraFile::WriteCameraFile( char* filename, CCameraAnim* srcanim )
{
	m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( m_hfile == INVALID_HANDLE_VALUE ){
		DbgOut( "CameraFile : WriteCameraFile : file open error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	m_anim = srcanim;
	if( !m_anim ){
		_ASSERT( 0 );
		return 1;
	}

	int ret;
	ret = Write2File( strheader3 );
	_ASSERT( !ret );

	ret = WriteAnimInfo();
	if( ret ){
		DbgOut( "CameraFile : WriteCameraFile : WriteAnimInfo error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	int camno;
	for( camno = 0; camno < 3; camno++ ){
		ret = WriteCameraAnim( camno );
		if( ret ){
			DbgOut( "CameraFile : WriteCameraFile : WriteCameraAnim error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
	}

	ret = WriteSWAnim();
	if( ret ){
		DbgOut( "CameraFile : WriteCameraFile : WriteSWAnim error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	ret = Write2File( strendfile );
	_ASSERT( !ret );

	return 0;
}
Exemplo n.º 6
0
int CMeshInfo::DumpMem( HANDLE hfile, int tabnum, int dumpflag )
{
	int	i;
	int	ret;
	char	setchar[3][10] = { "diffuse", "specular", "ambient" };
	CVec3f*	setvec[3] = { diffuse, specular, ambient };
	
	ret = CBaseDat::DumpMem( hfile, tabnum, "MESHINFO" );
	if( ret ){
		DbgOut( "charpos2.cpp : CMeshInfo : DumpMem : basedat dump error !!!\n" );
		return 1;
	}

	tabnum++;
	SetTabChar( tabnum );

	ret = Write2File( hfile, "%sM : %d, N : %d, Total : %d, M_CLOSED : %d, N_CLOSED : %d, skip : %d\n",
		tabchar, m, n, total, mclosed, nclosed, skip );
	_ASSERT( !ret );


	if( (dumpflag & DISP_MATERIAL) && (chkflag & MESHI_MATERIAL) ){
		ret = Write2File( hfile, "%s hascolor %d\n", tabchar, hascolor );
		if( ret ){
			DbgOut( "CMeshInfo : DumpMem : hascolor dump error !!!\n" );
			return 1;
		}

		for( i = 0; i < 3; i++ ){
			ret = Write2File( hfile, "%s %s\n", tabchar, setchar[i] );
			if( ret ){
				DbgOut( "charpos2.cpp : MeshInfo:DumpMem : material dump error !!!\n" );
				return 1;
			}
			ret = setvec[i]->DumpMem( hfile, tabnum, dumpflag );
			if( ret ){
				DbgOut( "charpos2.cpp : MeshInfo:DumpMem : material dump error !!!\n" );
				return 1;
			}
		}
	}
	return ret;
}
Exemplo n.º 7
0
    ///////////////////////////////////////////////////////////////////////
    // Function: 
    //
    //   Author: $author$
    //     Date: 2/21/2012
    ///////////////////////////////////////////////////////////////////////
    virtual EvError CopyFile2File
    (const char* chars,
     const char* chars2) 
    {
        EvError error = EV_ERROR_FAILED;
        bool complete = false;
        bool modified = false;
        const char* fileDir;
        CEvCharFile file, file2;
        LONG length, count;

        DBT("(const char* chars=\"%s\", const chars2=\"%s\")...\n", chars, chars2);

        if (0 < (length = m_filePath.Assign(chars2)))
        if ((fileDir = m_filePath.GetFileDirectory(length)))
        if (!(error = m_fileSystem.MakeDirectory(fileDir)))
        if (!(error = file.Open(chars, EVFILE_MODE_READ_BINARY)))
        {
#if defined(WIN32) 
            if (!(m_targetEntry.TruncateExisting(chars2)))
            if (EvFileSystemEntry::EV_TYPE_FILE & (m_targetEntry.Exists(chars2)))
            if (0 < ((m_targetEntry.GetSize())))
                unlink(chars2);
#else // defined(WIN32) 
#endif // defined(WIN32)
            if (!(error = file2.Open(chars2, EVFILE_MODE_WRITE_BINARY)))
            {
                complete = true;
                modified = false;
                do
                {
                    if (0 <= (length = file.Read
                        (m_blockChars, m_blockSize)))
                    if (length <= (count = Write2File
                        (modified, file2, m_blockChars, length)))
                        continue;
                    complete = false;
                    break;
                }
                while((LONG)m_blockSize <= length);
                file2.Flush();
                file2.Close();
            }
            file.Close();
        }
        if (modified)
            DBI("() CRs removed from \"%s\"\n", chars2);
        else
        if (complete)
            error = m_targetEntry.
            SetExistingTimes(m_sourceEntry, chars2);
        return error;
    }
Exemplo n.º 8
0
int	CExtrude::DumpMem( HANDLE hfile, int tabnum, int dumpflag )
{
	int ret;

	ret = CVecMesh::DumpMem( hfile, tabnum, dumpflag );
	_ASSERT( !ret );

	SetTabChar( tabnum + 1 );			
	ret = Write2File( hfile, "%s ExtrudeVec\n%s X: %f, Y: %f, Z: %f,\n", 
		tabchar, tabchar, exvec.x, exvec.y, exvec.z );
	_ASSERT( !ret );
	
	return ret;
}
Exemplo n.º 9
0
BOOL DumpPE(ULONG_PTR ImageBase, LPCSTR dumpFileName, ULONG_PTR dwEntryPoint, BOOL ImportRec)
{
    PBYTE pDump = NULL;
    ULONG_PTR AllocSize;

    if (PrepareDumpPE(ImageBase, &pDump, &AllocSize) == FALSE) {
        return FALSE;
    }
    FixSectionSizeOffset((ULONG_PTR)pDump);
    FixPEHeader((ULONG_PTR)pDump);
    if (dwEntryPoint) {
        EditPE((ULONG_PTR)pDump, ENTRY_POINT, (PVOID)dwEntryPoint);
    }
    if (ImportRec == TRUE) {
        PrepareReconstruct(&pDump, &AllocSize);
        Write2File(dumpFileName, pDump, (DWORD)AllocSize);
    }
    else {
        Write2File(dumpFileName, pDump, (DWORD)AllocSize);
    }
    VirtualFree(pDump, (SIZE_T)AllocSize, 0);
    return TRUE;
}
Exemplo n.º 10
0
HRESULT CD3D9ExUtils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
  HRESULT hResult = E_FAIL;
  int iStride[2];
  int iWidth;
  int iHeight;

  iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
  iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
  iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
  iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];

  if (pDst[0] && pDst[1] && pDst[2])
    Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight);

  return hResult;
}
Exemplo n.º 11
0
int CBaseDat::DumpMem( HANDLE hfile, int tabnum, char* headerptr )
{
	int ret;
	SetTabChar( tabnum );
	if( (type < SHDTYPENONE) || (type > SHDTYPEMAX) ){
		DbgOut( "CBaseDat : DumpMem : type %d error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	//_ASSERT( (type > SHDTYPENONE) && (type < SHDTYPEMAX) );
	
	ret = Write2File( hfile, "%s%s : type %s,\n", tabchar, headerptr, typechar[type] );
	_ASSERT( !ret );

	return ret;
}
Exemplo n.º 12
0
int CVec3f::DumpMem( HANDLE hfile, int tabnum, int dumpflag )
{

	int	ret;

	SetTabChar( tabnum );

	ret = CBaseDat::DumpMem( hfile, tabnum, "3DOBJ" );
	if( ret ){
		DbgOut( "charpos2.cpp : CVec3f : DumpMem : basedat dump error !!!\n" );
		return 1;
	}

	ret = Write2File( hfile, "%s X : %f, Y : %f, Z : %f\n", tabchar, x, y, z );
	_ASSERT( !ret );

	return ret;
}
Exemplo n.º 13
0
int CCameraFile::WriteAnimInfo()
{
/***
#AnimInfo Start
	name "camera_1"
	frameleng 60
	animtype "CLAMP"		//"STOP", "CLAMP", "ROUND", "INV", "JUMP"
	animstep 1
	motjump 0	
#AnimInfo End
***/

	int ret;
	ret = Write2File( stranimstart );
	_ASSERT( !ret );

	ret = Write2File( "\tname \"%s\"\r\n", m_anim->m_animname );
	_ASSERT( !ret );

	ret = Write2File( "\tframeleng %d\r\n", m_anim->m_maxframe + 1 );
	_ASSERT( !ret );


	int typeindex;
	if( (m_anim->m_animtype >= MOTION_CLAMP) && (m_anim->m_animtype <= MOTION_JUMP) ){
		typeindex = m_anim->m_animtype;
	}else{
		typeindex = 0;
	}
	ret = Write2File( "\tanimtype \"%s\"\r\n", &( stranimtype[ typeindex ][0] ) );
	_ASSERT( !ret );

	ret = Write2File( "\tanimstep %d\r\n", m_anim->m_animstep );
	_ASSERT( !ret );

	ret = Write2File( "\tmotjump %d\r\n", m_anim->m_motjump );
	_ASSERT( !ret );


	ret = Write2File( stranimend );
	_ASSERT( !ret );

	return 0;
}
Exemplo n.º 14
0
int CUtils::Process (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {

  int iRet = 0;

  if (iOSType == OS_UNSUPPORTED) {
    if (pFp && pDst[0] && pDst[1] && pDst[2] && pInfo) {
      int iStride[2];
      int iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
      int iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
      iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
      iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];

      Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight);
    }
  }

#ifdef ENABLE_DISPLAY_MODULE
  else {
    MSG msg;
    ZeroMemory (&msg, sizeof (msg));
    while (msg.message != WM_QUIT) {
      if (PeekMessage (&msg, NULL, 0U, 0U, PM_REMOVE)) {
        TranslateMessage (&msg);
        DispatchMessage (&msg);
      } else {
        HRESULT hResult = S_OK;
        if (iOSType == OS_XP)
          hResult = ((CD3D9Utils*)hHandle)->Process (pDst, pInfo, pFp);

        else if (iOSType == OS_VISTA_UPPER)
          hResult = ((CD3D9ExUtils*)hHandle)->Process (pDst, pInfo, pFp);

        iRet = !SUCCEEDED (hResult);
        break;
      }
    }
  }
#endif

  return iRet;
}
Exemplo n.º 15
0
HRESULT CD3D9ExUtils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
  HRESULT hResult = E_FAIL;
  EBufferProperty eBufferProperty = pInfo->eBufferProperty;
  int iStride[2];
  int iWidth;
  int iHeight;

  if (eBufferProperty != BUFFER_HOST) {
    iWidth = pInfo->UsrData.sVideoBuffer.iSurfaceWidth;
    iHeight = pInfo->UsrData.sVideoBuffer.iSurfaceHeight;
    iStride[0] = iWidth;
    iStride[1] = iWidth / 2;

    if (m_pDumpYUV == NULL) {
      m_pDumpYUV = (unsigned char*)malloc (iWidth * iHeight * 3 / 2 * sizeof (unsigned char));
    }

    if (m_pDumpYUV) {
      void* pSurface = pDst[1];
      pDst[0] = m_pDumpYUV;
      pDst[1] = m_pDumpYUV + iHeight * iStride[0] * sizeof (unsigned char);
      pDst[2] = m_pDumpYUV + iHeight * iStride[0] * 5 / 4 * sizeof (unsigned char);
      hResult = Dump2YUV (pDst, pSurface, iWidth, iHeight, iStride);
    }
  } else {
    iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
    iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
    iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
    iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];
  }

  if (pDst[0] && pDst[1] && pDst[2])
    Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight);

  return hResult;
}
Exemplo n.º 16
0
int CEQUFile::WriteAnimKey( CMotionPoint2* mpptr )
{        
	int ret;
	ret = Write2File( 3, "<AnimKey>\r\n" );
	_ASSERT( !ret );

	ret = Write2File( 4, "<FrameNo>%d</FrameNo>\r\n", mpptr->m_frameno );
	_ASSERT( !ret );

	ret = Write2File( 4, "<Q>%f, %f, %f, %f</Q>\r\n", mpptr->m_q.x, mpptr->m_q.y, mpptr->m_q.z, mpptr->m_q.w );
	_ASSERT( !ret );

	ret = Write2File( 4, "<Scale>%f, %f, %f</Scale>\r\n", mpptr->m_scalex, mpptr->m_scaley, mpptr->m_scalez );
	_ASSERT( !ret );

	ret = Write2File( 4, "<Tra>%f, %f, %f</Tra>\r\n", mpptr->m_mvx, mpptr->m_mvy, -mpptr->m_mvz );
	_ASSERT( !ret );

	ret = Write2File( 3, "</AnimKey>\r\n" );
	_ASSERT( !ret );

	return 0;
}
Exemplo n.º 17
0
int CCameraFile::WriteCameraAnim( int camno )
{
	int ret;

	ret = Write2File( &(strcamstart[camno][0]) );
	_ASSERT( !ret );

	int keynum = 0;
	ret = m_anim->GetCameraKeyframeNoRange( camno, 0, m_anim->m_maxframe, 0, 0, &keynum );
	if( ret ){
		DbgOut( "CameraFile : WriteCameraAnim : ca GetCameraKeyframeNoRange error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	ret = Write2File( "\tkeynum %d\r\n", keynum );
	_ASSERT( !ret );

	if( keynum > 0 ){
		int* keynoarray;
		keynoarray = (int*)malloc( sizeof( int ) * keynum );
		if( !keynoarray ){
			DbgOut( "CameraFile : WriteCameraAnim : keynoarray alloc error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
		ZeroMemory( keynoarray, sizeof( int ) * keynum );

		int getnum = 0;
		ret = m_anim->GetCameraKeyframeNoRange( camno, 0, m_anim->m_maxframe, keynoarray, keynum, &getnum );
		if( ret || (getnum != keynum) ){
			DbgOut( "CameraFile : WriteCameraAnim : ca GetCameraKeyframeNoRange 1 error !!!\n" );
			_ASSERT( 0 );
			free( keynoarray );
			return 1;
		}

		int keyno;
		for( keyno = 0; keyno < keynum; keyno++ ){
			int curframeno;
			curframeno = *( keynoarray + keyno );

			ret = Write2File( "\t%s", strcamkeystart );
			_ASSERT( !ret );

			CCameraKey* ckptr = 0;
			ret = m_anim->ExistCameraKey( camno, curframeno, &ckptr );
			if( ret || !ckptr ){
				DbgOut( "CameraFile : WriteCameraAnim : ca ExistCameraKey error !!!\n" );
				_ASSERT( 0 );
				free( keynoarray );
				return 1;
			}

			ret = Write2File( "\t\tframeno %d\r\n", ckptr->m_frameno );
			_ASSERT( !ret );


			int interpindex, fillupup;
			int divinterp;
			divinterp = ckptr->m_interp / 100;
			if( divinterp == 1 ){
				fillupup = 1;
				interpindex = ckptr->m_interp - 100;
			}else{
				fillupup = 0;
				interpindex = ckptr->m_interp;
			}
			ret = Write2File( "\t\tinterp \"%s\"\r\n", &(strinterp[interpindex][0]) );
			_ASSERT( !ret );

			ret = Write2File( "\t\tCalcUp %d\r\n", fillupup );
			_ASSERT( !ret );

			int looktypeindex;
			if( (ckptr->m_celem.looktype >= CAML_NORMAL) && (ckptr->m_celem.looktype <= CAML_LOCK) ){
				looktypeindex = ckptr->m_celem.looktype;
			}else{
				looktypeindex = CAML_NORMAL;
			}
			ret = Write2File( "\t\tlooktype \"%s\"\r\n", &(strlooktype[looktypeindex][0]) );
			_ASSERT( !ret );

			ret = Write2File( "\t\tpos %f, %f, %f\r\n", ckptr->m_celem.pos.x, ckptr->m_celem.pos.y, ckptr->m_celem.pos.z );
			_ASSERT( !ret );

			ret = Write2File( "\t\ttarget %f, %f, %f\r\n", ckptr->m_celem.target.x, ckptr->m_celem.target.y, ckptr->m_celem.target.z );
			_ASSERT( !ret );

			ret = Write2File( "\t\tup %f, %f, %f\r\n", ckptr->m_celem.up.x, ckptr->m_celem.up.y, ckptr->m_celem.up.z );
			_ASSERT( !ret );

			ret = Write2File( "\t\tdist %f\r\n", ckptr->m_celem.dist );
			_ASSERT( !ret );

			ret = Write2File( "\t\thsid %d\r\n", ckptr->m_celem.hsid );
			_ASSERT( !ret );

			ret = Write2File( "\t\tboneno %d\r\n", ckptr->m_celem.boneno );
			_ASSERT( !ret );

			ret = Write2File( "\t\tnearz %f\r\n", ckptr->m_celem.nearz );
			_ASSERT( !ret );

			ret = Write2File( "\t\tfarz %f\r\n", ckptr->m_celem.farz );
			_ASSERT( !ret );

			ret = Write2File( "\t\tfov %f\r\n", ckptr->m_celem.fov );
			_ASSERT( !ret );

			ret = Write2File( "\t\torthoflag %d\r\n", ckptr->m_celem.ortho );
			_ASSERT( !ret );

			ret = Write2File( "\t\torthosize %f\r\n", ckptr->m_celem.orthosize );
			_ASSERT( !ret );

			ret = Write2File( "\t%s", strcamkeyend );
			_ASSERT( !ret );
		}
		free( keynoarray );
	}
	ret = Write2File( &(strcamend[camno][0]) );
	_ASSERT( !ret );
/***
#Camera0 Start
	keynum	3
	#CameraKey Start
		frameno 0
		interp "LINEAR"		//"LINEAR", "SPLINE"
		looktype "NORMAL"	//"NORMAL", "LOOKONECE", "LOCK"
		pos 0.0, 0.0, 0.0
		target 0.0, 0.0, -5000.0
		up 0.0, 1.0, 0.0
		dist 5000.0
		hsid -1
		boneno -1
		nearz 1000.0
		farz 40000.0
		fov 45.0		
	#CameraKey End

	#CameraKey Start
		...
	#CameraKey End

	#CameraKey Start
		...
	#CameraKey End
#Camera0 End
***/
	return 0;
}
Exemplo n.º 18
0
int CCameraFile::WriteSWAnim()
{
	int ret;

	ret = Write2File( strswstart );	
	_ASSERT( !ret );

	int keynum = 0;
	ret = m_anim->GetSWKeyframeNoRange( 0, m_anim->m_maxframe, 0, 0, &keynum );
	if( ret ){
		DbgOut( "CameraFile : WriteSWAnim : ca GetSWKeyframeNoRange 0 error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	ret = Write2File( "\tkeynum %d\r\n", keynum );
	_ASSERT( !ret );

	if( keynum > 0 ){
		int* keynoarray;
		keynoarray = (int*)malloc( sizeof( int ) * keynum );
		if( !keynoarray ){
			DbgOut( "CameraFile : WriteSWAnim : keynoarray alloc error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}
		ZeroMemory( keynoarray, sizeof( int ) * keynum );

		int getnum = 0;
		ret = m_anim->GetSWKeyframeNoRange( 0, m_anim->m_maxframe, keynoarray, keynum, &getnum );
		if( ret || (getnum != keynum) ){
			DbgOut( "CameraFile : WriteSWAnim : ca GetSWKeyframeNoRange 1 error !!!\n" );
			_ASSERT( 0 );
			return 1;
		}

		int keyno;
		for( keyno = 0; keyno < keynum; keyno++ ){
			int curframeno;
			curframeno = *( keynoarray + keyno );

			CCameraSWKey* cswkptr = 0;
			ret = m_anim->ExistSWKey( curframeno, &cswkptr );
			if( ret || !cswkptr ){
				DbgOut( "CameraFile : WriteSWAnim : ca ExistSWKey error !!!\n" );
				_ASSERT( 0 );
				return 1;
			}

			ret = Write2File( "\t%s", strswkeystart );
			_ASSERT( !ret );

			ret = Write2File( "\t\tframeno %d\r\n", cswkptr->m_frameno );
			_ASSERT( !ret );

			ret = Write2File( "\t\tcamerano %d\r\n", cswkptr->m_camerano );
			_ASSERT( !ret );

			ret = Write2File( "\t%s", strswkeyend );
			_ASSERT( !ret );
		}

		free( keynoarray );
	}

	ret = Write2File( strswend );
	_ASSERT( !ret );
/***
#CameraSwitch Start
	keynum 2
	#SwitchKey Start
		frameno 0
		camerano 0
	#SwitchKey End

	#SwitchKey Start
		frameno 20
		camerano 1
	#SwitchKey End
#CameraSwitch End
***/
	return 0;
}
Exemplo n.º 19
0
Arquivo: dump.cpp Projeto: w4kfu/whook
BOOL DumpPE(HMODULE hModule, LPCSTR dumpFileName)
{
    PIMAGE_DOS_HEADER pDos;
    PIMAGE_NT_HEADERS pNT32;
    PIMAGE_NT_HEADERS64 pNT64;
    PIMAGE_SECTION_HEADER pSection;
    PBYTE pDump = NULL;
    DWORD dwAllocSize = 0;
    DWORD dwFinalSize = 0;
    DWORD NumberOfSections = 0;
    DWORD FileAlignment = 0;
    DWORD dwAlign = 0;

	pDump = AllocEnough(hModule, &dwAllocSize);
	if (!pDump) {
        fprintf(stderr, "[-] AllocEnough failed\n");
        return FALSE;
    }
    
    /* Copy DOS HEADER */
    memcpy(pDump, (LPVOID)hModule, sizeof (IMAGE_DOS_HEADER));
	dwFinalSize += sizeof (IMAGE_DOS_HEADER);
    pDos = (PIMAGE_DOS_HEADER)hModule;
    if (IsPE64Bit(hModule)) {
        pNT64 = (PIMAGE_NT_HEADERS64)((DWORD)hModule + pDos->e_lfanew);
        /* Copy PADDING */
        memcpy(pDump + dwFinalSize, (LPVOID)((DWORD)hModule + dwFinalSize), (DWORD)pNT64 - (DWORD)((DWORD)pDos + sizeof (IMAGE_DOS_HEADER)));
        dwFinalSize += (DWORD)pNT64 - (DWORD)((DWORD)pDos + sizeof (IMAGE_DOS_HEADER));
        /* Copy NT HEADER */
        memcpy(pDump + dwFinalSize, (LPVOID)pNT64, sizeof (IMAGE_FILE_HEADER) + pNT64->FileHeader.SizeOfOptionalHeader + sizeof(DWORD));
        dwFinalSize += sizeof (IMAGE_FILE_HEADER) + pNT64->FileHeader.SizeOfOptionalHeader + sizeof(DWORD);          
        NumberOfSections = pNT64->FileHeader.NumberOfSections;
        FileAlignment = pNT64->OptionalHeader.FileAlignment;
        pSection = (PIMAGE_SECTION_HEADER)((DWORD)pNT64 + sizeof(IMAGE_NT_HEADERS64));
    }
    else {
        pNT32 = (PIMAGE_NT_HEADERS)((DWORD)hModule + pDos->e_lfanew);
        /* Copy PADDING */
        memcpy(pDump + dwFinalSize, (LPVOID)((DWORD)hModule + dwFinalSize), (DWORD)pNT32 - (DWORD)((DWORD)pDos + sizeof (IMAGE_DOS_HEADER)));
        dwFinalSize += (DWORD)pNT32 - (DWORD)((DWORD)pDos + sizeof (IMAGE_DOS_HEADER));        
        /* Copy NT HEADER */
        memcpy(pDump + dwFinalSize, (LPVOID)pNT32, sizeof (IMAGE_FILE_HEADER) + pNT32->FileHeader.SizeOfOptionalHeader + sizeof(DWORD));
        dwFinalSize += sizeof (IMAGE_FILE_HEADER) + pNT32->FileHeader.SizeOfOptionalHeader + sizeof(DWORD);       
        NumberOfSections = pNT32->FileHeader.NumberOfSections;
        FileAlignment = pNT32->OptionalHeader.FileAlignment;
        pSection = (PIMAGE_SECTION_HEADER)((DWORD)pNT32 + sizeof(IMAGE_NT_HEADERS));
    }    
    /* Copy Sections */
	memcpy(pDump + dwFinalSize, (LPVOID)pSection, sizeof (IMAGE_SECTION_HEADER) * NumberOfSections);
	dwFinalSize += sizeof (IMAGE_SECTION_HEADER) * NumberOfSections;  
    dwAlign = AlignSize(dwFinalSize, FileAlignment);
	for (; dwFinalSize < dwAlign; dwFinalSize++)
		*(pDump + dwFinalSize) = 0;  
    for (DWORD i = 0; i < NumberOfSections; i++) {
        printf("%08X\n", pSection[i].VirtualAddress);
        printf("%08X\n", hModule + pSection[i].VirtualAddress);
        printf("%08X\n", pSection[i].SizeOfRawData);
        memcpy(pDump + dwFinalSize, (LPVOID)((DWORD)hModule + pSection[i].VirtualAddress), pSection[i].SizeOfRawData);
        dwFinalSize += pSection[i].SizeOfRawData;
        dwAlign = AlignSize(dwFinalSize, FileAlignment);
        for (; dwFinalSize < dwAlign; dwFinalSize++)
            *(pDump + dwFinalSize) = 0;
    }
    return Write2File(dumpFileName, pDump, dwFinalSize);
}
Exemplo n.º 20
0
void LogFile::Flush( )
{
	// If the file size exceed the limited.
	if (lenLimit)
	{
		if ((totalFileLength/1024+1) >= lenLimit)
		{
			// Add 2006-06-02, by Wu jianjin.
			if (FILENAME == fnMode)
			{
				MovingOldLogFile( );
			}

			ReOpenFile( );
			totalFileLength = 0L;
		}
		else
		{
			Write2File( );
		}
	}
	else
	{
		Write2File( );
	}

	/*
		int fd;

		fd = fileno(fp);
		if (fd != -1)
		{
			struct stat  * statbuf;
			int r;
			r=fstat(fd, statbuf);
			if (r != -1)
			{
				if (((UINT32)(statbuf->st_size/1024)) > lenLimit)
				{
					// Add 2006-06-02, by Wu jianjin.
					if (FILENAME == fnMode)
					{
						MovingOldLogFile( );
					}

					ReOpenFile( );
				}
				// else
				// { // Write data into file.
					Write2File( );
				// }
			}
			else
			{ // Discard current data in buffers.
				ClearBuffer( );
			}
		}
		else
		{ // Discard current data in bufers.
			ClearBuffer( );
		}
	}
	else
	{ // if lenLimit==0, no limit.
		Write2File( );
	}*/
}
Exemplo n.º 21
0
RDBPLUGIN_EXPORT int RDBOnSelectPlugin()
{
	OPENFILENAME ofn;
	char buf[_MAX_PATH];
	buf[0] = 0;
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = NULL;
	ofn.hInstance = 0;
	ofn.lpstrFilter = (LPCTSTR)"TXT FILE (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
	ofn.lpstrCustomFilter = NULL;
	ofn.nMaxCustFilter = 0;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = (LPTSTR)buf;
	ofn.nMaxFile =sizeof(buf);
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle = NULL;
	ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
	ofn.nFileOffset = 0;
	ofn.nFileExtension = 0;
	ofn.lpstrDefExt ="txt";
	ofn.lCustData = NULL;
	ofn.lpfnHook = NULL;
	ofn.lpTemplateName = NULL;
	if( GetSaveFileName(&ofn) == 0 )
		return 0;

	hfile = CreateFile( buf, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( hfile == INVALID_HANDLE_VALUE ){
		RDBDbgOut( "shapeexporter : file open error %s !!!\n", buf );
		return 1;
	}


	int rdb2version;
	RDBGetVersion( &rdb2version );
	Write2File( "RokDeBone2 version : %d\r\n", rdb2version );


	char* dispobjname = 0;
	int* dispobjinfo = 0;
	

	int ret = 0;
	int hsid;
	ret = RDBGetCurrentHSID( &hsid );
	if( hsid >= 0 ){

		RDBCreateProgressBar();
		RDBSetProgressBar( 5 );


		//マテリアルの情報取得
		int matnum;
		ret = RDBGetMaterialNum( hsid, &matnum );
		if( (ret == 0) && (matnum > 0) ){
			RDBMaterial curmat;
			int matno;
			for( matno = 0; matno < matnum; matno++ ){
				ret = RDBGetMaterial( hsid, matno, &curmat );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}

				Write2File( "material %d - %s - %d\r\n", curmat.materialno, curmat.name, curmat.legacyflag );
				Write2File( "\ta : %f, diffuse %f, %f, %f\r\n", curmat.a, curmat.diffuse.r, curmat.diffuse.g, curmat.diffuse.b );
				Write2File( "\ttexture %s\r\n", curmat.tex );
			}
		}
		Write2File( "\r\n" );


		//表示オブジェクトの情報取得
		int dispobjnum;
		ret = RDBGetDispObjNum( hsid, &dispobjnum );
		if( ret ){
			_ASSERT( 0 );
			goto OnSelectExit;
		}
		if( dispobjnum == 0 ){
			Write2File( "dispobj not exist return\r\n" );
			ret = 0;
			goto OnSelectExit;
		}


		int shadertype, overflowtype;
		ret = RDBGetShaderType( hsid, &shadertype, &overflowtype );
		if( ret ){
			_ASSERT( 0 );
			goto OnSelectExit;
		}
		Write2File( "shadertype %d, overflowtype %d\r\n", shadertype, overflowtype );



		dispobjname = (char*)malloc( sizeof( char ) * 256 * dispobjnum );
		if( !dispobjname ){
			_ASSERT( 0 );
			goto OnSelectExit;
		}
		dispobjinfo = (int*)malloc( sizeof( int ) * DOI_MAX * dispobjnum );
		if( !dispobjinfo ){
			_ASSERT( 0 );
			goto OnSelectExit;
		}
		int dispgetnum;
		ret = RDBGetDispObjInfo( hsid, dispobjnum, dispobjname, dispobjinfo, &dispgetnum );
		if( ret ){
			_ASSERT( 0 );
			goto OnSelectExit;
		}

		int dispobjno;
		int partno;
		for( dispobjno = 0; dispobjno < dispobjnum; dispobjno++ ){

			int pbpos = 0;
			if( dispobjnum != 0 )
				pbpos = (int)( (float)dispobjno * 100.0f / (float)dispobjnum );
			RDBSetProgressBar( pbpos );


			partno = *( dispobjinfo + DOI_MAX * dispobjno + DOI_SERIAL );
			_ASSERT( partno > 0 );

			int vertnum;
			ret = RDBGetVertNumOfPart( hsid, partno, &vertnum );
			if( ret ){
				_ASSERT( 0 );
				goto OnSelectExit;
			}
			
			//名前の出力
			Write2File( "\r\n\r\n\r\ndispobjname %s, partno %d, vertex num %d\r\n", (dispobjname + 256 * dispobjno), partno, vertnum );

			int vertno;
			for( vertno = 0; vertno < vertnum; vertno++ ){

				Write2File( "vertexno %d\r\n", vertno );

				//頂点位置の出力
				RDBPoint vpos;
				ret = RDBGetVertPos( hsid, partno, vertno, &vpos );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				Write2File( "position ( %f, %f, %f )\r\n", vpos.x, vpos.y, vpos.z );


				//頂点の色の出力
				int alpha;
				ret = RDBGetAlpha( hsid, partno, vertno, &alpha );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				int dr, dg, db;
				ret = RDBGetDiffuse( hsid, partno, vertno, &dr, &dg, &db );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				int ar, ag, ab;
				ret = RDBGetAmbient( hsid, partno, vertno, &ar, &ag, &ab );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				int sr, sg, sb;
				ret = RDBGetSpecular( hsid, partno, vertno, &sr, &sg, &sb );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				int er, eg, eb;
				ret = RDBGetEmissive( hsid, partno, vertno, &er, &eg, &eb );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				float power;
				ret = RDBGetSpecularPower( hsid, partno, vertno, &power );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				Write2File( "alpha %d\r\n", alpha );
				Write2File( "diffuse (%d %d %d)\r\n", dr, dg, db );
				Write2File( "ambient (%d %d %d)\r\n", ar, ag, ab );
				Write2File( "specular (%d %d %d)\r\n", sr, sg, sb );
				Write2File( "emissive (%d %d %d)\r\n", er, eg, eb );
				Write2File( "specular power %f\r\n", power );

				//影響度の出力
				int infnum;
				ret = RDBGetInfElemNum( hsid, partno, vertno, &infnum );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				int infno;
				for( infno = 0; infno < infnum; infno++ ){
					int boneno;
					float rate;
					ret = RDBGetInfElem( hsid, partno, vertno, infno, &boneno, &rate );
					if( ret ){
						_ASSERT( 0 );
						goto OnSelectExit;
					}
					
					//!!!!!!!! boneno には、-1が、代入されることがある。
					// boneno が -1のときは、無意味なデータであることに注意。

					if( boneno >= 0 ){
						char jointname[2048];//大きめにとってください。
						ret = RDBGetName( hsid, boneno, jointname, 2047 );
						if( ret ){
							_ASSERT( 0 );
							goto OnSelectExit;
						}
						Write2File( "infelem : boneno %d, bonename %s, rate %f\r\n", boneno, jointname, rate );
					}else{
						Write2File( "infelem : boneno %d  invalid data\r\n", boneno );
					}
				}


				//UV情報の出力
				float u, v;
				ret = RDBGetUV( hsid, partno, vertno, &u, &v );
				if( ret ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}
				Write2File( "texture U : %f, V %f\r\n", u, v );
			}

			Write2File( "\r\n\r\n" );

			//法線情報の出力
			if( vertnum > 0 ){
				RDBPoint* normalptr;
				normalptr = (RDBPoint*)malloc( sizeof( RDBPoint ) * vertnum );
				if( !normalptr ){
					_ASSERT( 0 );
					goto OnSelectExit;
				}

				//初期状態の法線は、motidに-1を指定して取得する
				ret = RDBGetNormal( hsid, partno, -1, 0, normalptr, vertnum );
				if( ret ){
					_ASSERT( 0 );
					free( normalptr );
					goto OnSelectExit;
				}

				int vno;
				for( vno = 0; vno < vertnum; vno++ ){
					RDBPoint* curn;
					curn = normalptr + vno;
					Write2File( "normal : vert %d,  ( %f, %f, %f )\r\n", vno, curn->x, curn->y, curn->z );
				}
					
				free( normalptr );
			}


			Write2File( "\r\n\r\n" );


////////////////////

			//面情報の出力
			int facenum;
			ret = RDBGetFaceNum( hsid, partno, &facenum );
			if( ret ){
				_ASSERT( 0 );
				goto OnSelectExit;
			}

			int* ibuf = 0;
			int intnum, setintnum, revflag;
			ret = RDBGetTriIndicesInt( hsid, partno, ibuf, 0, &setintnum, &revflag );
			if( ret ){
				_ASSERT( 0 );
				goto OnSelectExit;
			}
			ibuf = (int*)malloc( sizeof( int ) * setintnum );
			if( !ibuf ){
				_ASSERT( 0 );
				goto OnSelectExit;
			}

			intnum = setintnum;
			ret = RDBGetTriIndicesInt( hsid, partno, ibuf, intnum, &setintnum, &revflag );
			if( ret ){
				_ASSERT( 0 );
				free( ibuf );
				goto OnSelectExit;
			}

			if( setintnum != (facenum * 3) ){
				_ASSERT( 0 );
				free( ibuf );
				goto OnSelectExit;
			}

			Write2File( "facenum %d\r\n", facenum );
			int faceno;
			for( faceno = 0; faceno < facenum; faceno++ ){
				int i1, i2, i3;
				i1 = *( ibuf + faceno * 3 );
				i2 = *( ibuf + faceno * 3 + 1 );
				i3 = *( ibuf + faceno * 3 + 2 );

				int materialno;
				ret = RDBGetMaterialNo( hsid, partno, faceno, &materialno );
				_ASSERT( !ret );

				Write2File( "faceno %d, index ( %d, %d, %d )  materialno(%d)\r\n", faceno, i1, i2, i3, materialno );	
			}
			if( ibuf )
				free( ibuf );
		}
		
		RDBDestroyProgressBar();

	}else{
		Write2File( "model data is not loaded return !!!\r\n" );
	}


OnSelectExit:
	if( dispobjname ){
		free( dispobjname );
		dispobjname = 0;
	}
	if( dispobjinfo ){
		free( dispobjinfo );
		dispobjinfo = 0;
	}


	if( hfile != INVALID_HANDLE_VALUE ){
		FlushFileBuffers( hfile );
		SetEndOfFile( hfile );
		CloseHandle( hfile );
		hfile = INVALID_HANDLE_VALUE;
	}

	MessageBox( NULL, "ShapeExporterの処理を終わりました。", "ShapeExporter", MB_OK );

	return ret;
}
Exemplo n.º 22
0
int CIM2File::WriteIM2File( char* filename, int srcformqo, CTreeHandler2* lpth, CShdHandler* lpsh )
{
	int ret = 0;

	if( !lpth || !lpsh ){
		DbgOut( "IM2File : WriteIM2File : handler NULL error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}
	m_lpth = lpth;
	m_lpsh = lpsh;

	m_formqo = srcformqo;

	//////////////////

	//ボーンが1個も無いときは、出力しない。
	int bonenum = 0;
	ret = lpsh->CheckBoneNum( &bonenum );
	if( ret ){
		DbgOut( "im2file : WriteIM2File : sh CheckBoneNum error !!!\n" );
		_ASSERT( 0 );
		return 1;
	}

	if( bonenum == 0 ){
		DbgOut( "im2file : WriteIM2File : bonenum == 0 : return 0 !!!\n" );

		MessageBox( NULL, "階層構造を持ったジョイントが一つもありません。\nジョイントに階層構造を作ってから、再試行してください。", "階層構造がありません", MB_OK );

		//_ASSERT( 0 );
		return 0;
	}

	///////////////////

	m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( m_hfile == INVALID_HANDLE_VALUE ){
		DbgOut( "IM2File : WriteIM2File : file open error !!!\n" );
		_ASSERT( 0 );
		ret = 1;
		goto im2fexit;
	}

	int sameno;
	sameno = CheckSameName();
	if( sameno >= 0 ){
		DbgOut( "im2file : WriteIM2File : CheckSameName error !!!\n" );
		_ASSERT( 0 );

		char messtr1[1024];
		strcpy_s( messtr1, 1024, "同じオブジェクト名が複数あると、\n正しく、ファイルを作れません。\n名前を変えてから、再試行してください。\n" );

		CTreeElem2* sametelem;
		sametelem = (*m_lpth)( sameno );
		_ASSERT( sametelem );

		::MessageBox( NULL, messtr1, sametelem->name, MB_OK );

		ret = 1;
		goto im2fexit;
	}


	Write2File( fileheaderstr4 );


	int serino;
	CShdElem* selem;
	CTreeElem2* telem;
	//int dispflag, isbone;
	for( serino = 0; serino < m_lpsh->s2shd_leng; serino++ ){

		selem = (*m_lpsh)( serino );
		telem = (*m_lpth)( serino );

		if( !selem || !telem ){
			DbgOut( "IM2File : WriteIM2File : elem error %x %x !!!\n", selem, telem );
			_ASSERT( 0 );
			ret = 1;
			goto im2fexit;
		}		

		if( (selem->type == SHDPOLYMESH) || (selem->type == SHDPOLYMESH2) ){
			ret = WriteIM2( selem, telem );
			if( ret ){
				DbgOut( "IM2File : WriteIM2File : WriteIM2 error %d!!!\n", serino );
				ret = 1;
				goto im2fexit;
			}
		}
	}

	//終わりの目印
	IM2HEADER im2h;
	ZeroMemory( &im2h, sizeof( IM2HEADER ) );
	strcpy_s( im2h.name, 256, im2endmark );
	im2h.vertnum = 0;
	ret = WriteUCharData( (unsigned char*)&im2h, sizeof( IM2HEADER ) );
	if( ret ){
		DbgOut( "im2file : WriteIM2File : endmark write error !!!\n" );
		_ASSERT( 0 );
		ret = 1;
		goto im2fexit;
	}


	goto im2fexit;
im2fexit:
	if( m_hfile != INVALID_HANDLE_VALUE ){
		FlushFileBuffers( m_hfile );
		SetEndOfFile( m_hfile );
		CloseHandle( m_hfile );
		m_hfile = INVALID_HANDLE_VALUE;
	}
	return ret;
}