The warehouse is one big mesh, some parts of it has alpha value less than 1.0, others objects include the trucks and the counter balances and the pallets in yellow
Here is how I load the mesh
void CMesh::LoadMesh(TCHAR *filename....)
{
D3DXLoadMeshFromX(filename, D3DXMESH_SYSTEMMEM, pDevice,
&adjBuffer, &mtrlBuffer, NULL, &numMtrls, &meshSys);
D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];
meshSys->GetDeclaration(elems);
bool hasNormals = false;
D3DVERTEXELEMENT9 term = D3DDECL_END();
for(int i = 0; i < MAX_FVF_DECL_SIZE; ++i)
{
// Did we reach D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED, 0,0,0}?
if(elems[i].Stream == 0xff )
break;
if( elems[i].Type == D3DDECLTYPE_FLOAT3 &&
elems[i].Usage == D3DDECLUSAGE_NORMAL &&
elems[i].UsageIndex == 0 )
{
hasNormals = true;
break;
}
}
// Step 3: Change vertex format to VertexPNT.
D3DVERTEXELEMENT9 elements[64];
UINT numElements = 0;
VertexPNT::Decl->GetDeclaration(elements, &numElements);
ID3DXMesh* temp = 0;
meshSys->CloneMesh(D3DXMESH_SYSTEMMEM | D3DXMESH_32BIT,
elements, pDevice, &temp);
ReleaseCOM(meshSys);
meshSys = temp;
// Step 4: If the mesh did not have normals, generate them.
if( hasNormals == false)
D3DXComputeNormals(meshSys, 0);
// Step 5: Optimize the mesh.
meshSys->Optimize(D3DXMESH_MANAGED |
D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE,
(DWORD*)adjBuffer->GetBufferPointer(), 0, 0, 0, &mMesh);
ReleaseCOM(meshSys); // Done w/ system mesh.
ReleaseCOM(adjBuffer); // Done with buffer.
// Step 6: Extract the materials and load the textures.
attTable = new D3DXATTRIBUTERANGE[numMtrls];
mMesh->GetAttributeTable(attTable, &m_cAttributes);
if( mtrlBuffer != 0 && numMtrls != 0 )
{
D3DXMATERIAL* d3dxmtrls = (D3DXMATERIAL*)mtrlBuffer->GetBufferPointer();
for(DWORD i = 0; i < numMtrls; ++i)
{
// Save the ith material. Note that the MatD3D property does not have an ambient
// value set when its loaded, so just set it to the diffuse value.
Mtrl m;
m.ambient = d3dxmtrls[i].MatD3D.Diffuse; //Diffuse;
m.diffuse = d3dxmtrls[i].MatD3D.Diffuse;
m.spec = d3dxmtrls[i].MatD3D.Specular;
m.specPower = d3dxmtrls[i].MatD3D.Power;
mMtrl.push_back( m );
// Check if the ith material has an associative texture
if( d3dxmtrls[i].pTextureFilename != 0 )
{
// Yes, load the texture for the ith subset
IDirect3DTexture9* tex = 0;
char* texFN = d3dxmtrls[i].pTextureFilename;
D3DXCreateTextureFromFile(pDevice, texFN, &tex);
// Save the loaded texture
mTex.push_back( tex );
}
else
{
// No texture for the ith subset
mTex.push_back( 0 );
}
}
}
ReleaseCOM(mtrlBuffer); // done w/ buffer
}
Here is how I render the static objects
void CStaticObject::RenderStaticMesh()
{
mFX->SetMatrix(mhWVP, &(m_matWorld*g_View*g_Proj));
D3DXMATRIX worldInvTrans;
D3DXMatrixInverse(&worldInvTrans, 0, &m_matWorld);
D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans);
mFX->SetMatrix(mhWorld, &m_matWorld);
mFX->SetTechnique(mhTech);
UINT numPasses = 0;
mFX->Begin(&numPasses,0);
mFX->BeginPass(0);
for (int j = 0; j < m_pMesh->m_cAttributes; ++j)
{
int mtrlIndex = m_pMesh->attTable[j].AttribId;
Mtrl m = m_pMesh->GetMaterial()[mtrlIndex];
mFX->SetValue(mhMtrl, &m, sizeof(Mtrl));
if (m_pMesh->GetTexture()[j] != 0)
{
mFX->SetTexture(mhTex, m_pMesh->GetTexture()[j]);
}
else
{
;
}
mFX->CommitChanges();
m_pMesh->GetMesh()->DrawSubset(j);
}
mFX->EndPass();
mFX->End();
}
Thanks

Jack