Loding Mesh from X files error....

Started by
1 comment, last by ankhd 17 years, 1 month ago
here is the code

void Mesh(void)
{
	LPD3DXBUFFER* bufShipMaterial;

	D3DXLoadMeshFromX(L"Thing.x",
		D3DXMESH_SYSTEMMEM,
		pd3dDevice,
		NULL,
		&bufShipMaterial,
		NULL,
		&numMaterials,
		&THING);


	// trycker ner allt i tempMaterials!
    D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufShipMaterial->GetBufferPointer();
    // skapar ett nytt material för varje grej i meshen
    material = new D3DMATERIAL9[numMaterials];

    for(DWORD i = 0; i < numMaterials; i++)    // för varje material
    {
        material = tempMaterials.MatD3D;    // skaffar material infot
        material.Ambient = material.Diffuse;    // gör ambient samma som diffues!
    }

    return;

} 
here is the error: ------ Build started: Project: Meshes tut, Configuration: Debug Win32 ------ Compiling... WinMian.cpp c:\Documents and Settings\Nicklas\Mina dokument\Visual Studio Projects\Meshes tut\WinMian.cpp(121) : error C2664: 'D3DXLoadMeshFromXA' : cannot convert parameter 1 from 'const unsigned short [8]' to 'LPCSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\Documents and Settings\Nicklas\Mina dokument\Visual Studio Projects\Meshes tut\WinMian.cpp(125) : error C2227: left of '->GetBufferPointer' must point to class/struct/union type is 'LPD3DXBUFFER * ' Build log was saved at "file://c:\Documents and Settings\Nicklas\Mina dokument\Visual Studio Projects\Meshes tut\Debug\BuildLog.htm" Meshes tut - 2 error(s), 0 warning(s) ---------------------- Done ---------------------- Build: 0 succeeded, 1 failed, 0 skipped [/source]
Advertisement
The first error is ocurring because you have L in front of the string which is a conversion to unicode. Unicode is represented as unsigned shorts, so take this L out to build with ASCII. An alternative here is to use _T( "myString" ) which only converts to unicode if the project settings for character set is set to unicode.

For the second error, bugShipMaterial should be declared as a LPD3DXBUFFER not a LPD3DXBUFFER*.

Try those solutions and see if it works.

Dave
Hi, You could set the projects settings to use ASCII if you have VC++ 2005
you goto Projects->Properties->Configuration->CharacterSet = Not Set;

and here to Projects->Properties->General->CharacterSet = Not Set;


This topic is closed to new replies.

Advertisement