Exemple #1
0
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertAnsiStringToGeneric()
// Desc: This is a UNICODE conversion utility to convert a CHAR string into a
//       TCHAR string. 
//       cchDestChar is the size in TCHARs of tstrDestination.  Be careful not to 
//       pass in sizeof(strDest) on UNICODE builds
//-----------------------------------------------------------------------------
HRESULT DXUtil_ConvertAnsiStringToGenericCch( TCHAR* tstrDestination, const CHAR* strSource, 
                                           int cchDestChar )
{
    if( tstrDestination==NULL || strSource==NULL || cchDestChar < 1 )
        return E_INVALIDARG;
        
#ifdef _UNICODE
    return DXUtil_ConvertAnsiStringToWideCch( tstrDestination, strSource, cchDestChar );
#else
    strncpy( tstrDestination, strSource, cchDestChar );
    tstrDestination[cchDestChar-1] = '\0';
    return S_OK;
#endif    
}
Exemple #2
0
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertGenericStringToWide()
// Desc: This is a UNICODE conversion utility to convert a TCHAR string into a
//       WCHAR string. 
//       cchDestChar is the size in TCHARs of wstrDestination.  Be careful not to 
//       pass in sizeof(strDest) 
//-----------------------------------------------------------------------------
HRESULT DXUtil_ConvertGenericStringToWideCch( WCHAR* wstrDestination, const TCHAR* tstrSource, 
                                           int cchDestChar )
{
    if( wstrDestination==NULL || tstrSource==NULL || cchDestChar < 1 )
        return E_INVALIDARG;

#ifdef _UNICODE
    wcsncpy( wstrDestination, tstrSource, cchDestChar );
    wstrDestination[cchDestChar-1] = L'\0';
    return S_OK;
#else
    return DXUtil_ConvertAnsiStringToWideCch( wstrDestination, tstrSource, cchDestChar );
#endif    
}
Exemple #3
0
INT CLcXSkinSrc::Create(void* p1, void* p2, void*, void* )
{
	HRESULT				hr;
	CLcXSkinAlloc		Alloc(this);

	char* sFile			= NULL;
	
	m_pDevice	= (LPDIRECT3DDEVICE9)p1;
	sFile		= (char*)p2;

	::strcpy(m_sFile, sFile);
	

	WCHAR* wFile = new WCHAR[strlen(m_sFile)+1];
	DXUtil_ConvertAnsiStringToWideCch(wFile, m_sFile, strlen(m_sFile)+1);

	hr = D3DXLoadMeshHierarchyFromX(wFile
								, D3DXMESH_MANAGED
								, m_pDevice
								, &Alloc
								, NULL
								, (LPD3DXFRAME*)&m_pFrameRoot
								, &m_pAC);
	delete[] wFile;

	if (FAILED(hr))
		return hr;
	
	
	hr = FindBones(m_pFrameRoot);
	if (FAILED(hr))
		return hr;
	
	hr = D3DXFrameCalculateBoundingSphere((const D3DXFRAME*)m_pFrameRoot, &m_ObjectCenter, &m_ObjectRadius);
	if (FAILED(hr))
		return hr;
	
	
	return S_OK;
}
Exemple #4
0
//-----------------------------------------------------------------------------
// Name: BYTE helper functions
// Desc: cchDestChar is the size in BYTEs of strDest.  Be careful not to 
//       pass use sizeof() if the strDest is a string pointer.  
//       eg.
//       TCHAR* sz = new TCHAR[100]; // sizeof(sz)  == 4
//       TCHAR sz2[100];             // sizeof(sz2) == 200
//-----------------------------------------------------------------------------
HRESULT DXUtil_ConvertAnsiStringToWideCb( WCHAR* wstrDestination, const CHAR* strSource, int cbDestChar )
{
    return DXUtil_ConvertAnsiStringToWideCch( wstrDestination, strSource, cbDestChar / sizeof(WCHAR) );
}