Sign in to follow this  
snoddas14

Loding Mesh from X files error....

Recommended Posts

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[i] = tempMaterials[i].MatD3D;    // skaffar material infot
        material[i].Ambient = material[i].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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this