problem loading mesh with trancparent texture

Started by
3 comments, last by kingpinzs 12 years, 8 months ago
I am using D3DXLoadMeshFromX and D3DCreateTextureFromFile but it doesnt show transpaerncy with the texture

hw can I acomplish this? I am using directx 9c and c++
Advertisement
[font=arial, verdana, tahoma, sans-serif][size=2]Can you show some code?
Much easier to help then.[/font]
EnJOJ Gaming
I am using this sample code for now tell I figure out how it all works

ODEL *LoadModel(char *filename)
{
MODEL *model = (MODEL*)malloc(sizeof(MODEL));
LPD3DXBUFFER matbuffer;
HRESULT result;

//load mesh from the specified file
result = D3DXLoadMeshFromX(
filename, //filename
D3DXMESH_SYSTEMMEM, //mesh options
d3ddev, //Direct3D device
NULL, //adjacency buffer
&matbuffer, //material buffer
NULL, //special effects
&model->material_count, //number of materials
&model->mesh); //resulting mesh

if (result != D3D_OK)
{
MessageBox(NULL, "Error loading model file", "Error", MB_OK);
return NULL;
}

//extract material properties and texture names from material buffer
LPD3DXMATERIAL d3dxMaterials = (LPD3DXMATERIAL)matbuffer->GetBufferPointer();
model->materials = new D3DMATERIAL9[model->material_count];
model->textures = new LPDIRECT3DTEXTURE9[model->material_count];

//create the materials and textures
for(DWORD i=0; i<model->material_count; i++)
{
//grab the material
model->materials = d3dxMaterials.MatD3D;

//set ambient color for material
model->materials.Ambient = model->materials.Diffuse;

model->textures = NULL;
if( d3dxMaterials.pTextureFilename != NULL &&
lstrlen(d3dxMaterials.pTextureFilename) > 0 )
{
//load texture file specified in .x file
result = D3DXCreateTextureFromFile(d3ddev,
d3dxMaterials.pTextureFilename,
&model->textures);

if (result != D3D_OK)
{
MessageBox(NULL, "Could not find texture file", "Error", MB_OK);
return NULL;
}
}
}

//done using material buffer
matbuffer->Release();

return model;
}

VOID DeleteModel(MODEL *model)
{
//remove materials from memory
if( model->materials != NULL )
delete[] model->materials;

//remove textures from memory
if (model->textures != NULL)
{
for( DWORD i = 0; i < model->material_count; i++)
{
if (model->textures != NULL)
model->textures->Release();
}
delete[] model->textures;
}

//remove mesh from memory
if (model->mesh != NULL)
model->mesh->Release();

//remove model struct from memory
if (model != NULL)
free(model);

}

void DrawModel(MODEL *model)
{
//draw each mesh subset
for( DWORD i=0; i<model->material_count; i++ )
{
// Set the material and texture for this subset
d3ddev->SetMaterial( &model->materials );
d3ddev->SetTexture( 0, model->textures );

// Draw the mesh subset
model->mesh->DrawSubset( i );
}
}


What kind of format is the texture?
and i can't see any enabling of AlphaBlending

Here's a tutorial on it.
http://www.codesampl...rc/dx9src_4.htm

btw I'm kind of a noob :P
EnJOJ Gaming
I am using a bmp with a mask bmp

This topic is closed to new replies.

Advertisement