[ Srki_82 @ 01.12.2004. 01:07 ] @
Cackao sam malo po Sample Framework (Microsoft DirectX 9.0 SDK Update (October 2004)) i video zgodnu klasicu CDXUTMesh pa sam odlucio da ucitavanje i prikazivanje mesh-eva prepustim toj klasi. Dok sam sve radio sam (kao u tutorijalu gde prikazuje tigra) sve je lepo radilo, ali od kad mi CDXUTMesh pomaze svi mesh-evi su potpuno crni. U cemu je problem?

Evo i jednog malog primera:
Code:

#include "dxstdafx.h"
#include "resource.h"

CDXUTMesh g_Terrain;
D3DXVECTOR3 vecEye(0.5f, 0.7f, -0.6f);
D3DXVECTOR3 vecAt (0.5f, 0.0f, 0.53f);
D3DXVECTOR3 vecUp (0.0F, 1.0F,  0.0f);

HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
void    CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
void    CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
void    CALLBACK OnLostDevice();
void    CALLBACK OnDestroyDevice();

INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    DXUTSetCallbackDeviceCreated( OnCreateDevice );
    DXUTSetCallbackDeviceReset( OnResetDevice );
    DXUTSetCallbackDeviceLost( OnLostDevice );
    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
    DXUTSetCallbackFrameRender( OnFrameRender );
    DXUTSetCallbackFrameMove( OnFrameMove );

    DXUTSetCursorSettings( true, true );
    DXUTInit( true, true, true );
    DXUTCreateWindow( L"FirstGame" );
    DXUTCreateDevice( D3DADAPTER_DEFAULT, true, 640, 480, NULL, NULL );

    DXUTMainLoop();

    return DXUTGetExitCode();
}

HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc )
{
    HRESULT hr;

    D3DXMATRIXA16 matView;
    D3DXMatrixLookAtLH( &matView, &vecEye, &vecAt, &vecUp );
    pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

    D3DXMATRIXA16 matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 0.05f, 100.0f );
    pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

    D3DXMATRIXA16 matWorld;
    D3DXMatrixIdentity( &matWorld );
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

    V_RETURN( g_Terrain.Create( pd3dDevice, L"C:\\Terrain.x" ) );


    return S_OK;
}

HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc )
{
    g_Terrain.RestoreDeviceObjects( pd3dDevice );

    return S_OK;
}

void    CALLBACK OnLostDevice()
{
    g_Terrain.InvalidateDeviceObjects();
}

void    CALLBACK OnDestroyDevice()
{
    g_Terrain.Destroy();
}

void    CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime )
{

}

void    CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime )
{
    HRESULT hr;
    pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    pd3dDevice->BeginScene();

    g_Terrain.UseMeshMaterials( TRUE );
        
        V( g_Terrain.Render( pd3dDevice ));

    pd3dDevice->EndScene();
    pd3dDevice->Present( NULL, NULL, NULL, NULL );
}


Da li neko zna u cemu je problem? U "Terrain.X" fajlu je sve ok. Tu su podaci o vertexima, indexima, normalama, materijalima. Textura je na pravom mestu i ucita se lepo. Kada otvorim "Terrain.X" u Mesh Viewer-u lepo se vidi... da li da i dalje pokusavam da radim sa CDXUTMesh ili mi je bolje da se vratim na stari oprobani nacin?
[ Reljam @ 01.12.2004. 01:09 ] @
Da li si ukljucio svetlo? Nigde ne vidim light enable.
[ Srki_82 @ 01.12.2004. 07:44 ] @
Mislio sam da je default vrednost za D3DRS_LIGHTING = TRUE i da je dovoljno samo da postavim D3DRS_AMBIENT na 0xffffffff da bi scena bila osvetljena. Tako je radilo dok nisam koristio Sample Framework.

Ok... probao sam i da ukljucim osvetljenje (D3DRS_LIGHTING = TRUE) i nista. Isto je kao i pre.
[ Srki_82 @ 01.12.2004. 23:04 ] @
Ok... nadam se da ce sad neko moci da neki odgovor koji ce mi mozda pomoci.

Hmmmm... ovako sam radio bez Sample Framework-a:
Code:

#include <Windows.h>
#include <mmsystem.h>
#include <d3dx9.h>


LPDIRECT3D9             g_pD3D           = NULL;
LPDIRECT3DDEVICE9       g_pd3dDevice     = NULL;

LPD3DXMESH              g_pMesh          = NULL;
D3DMATERIAL9*           g_pMeshMaterials = NULL;
LPDIRECT3DTEXTURE9*     g_pMeshTextures  = NULL;
DWORD                   g_dwNumMaterials = 0L;


HRESULT InitD3D( HWND hWnd )
{
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    D3DPRESENT_PARAMETERS d3dpp; 
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

    g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

    return S_OK;
}


HRESULT InitGeometry()
{
    LPD3DXBUFFER pD3DXMtrlBuffer;

    if( FAILED( D3DXLoadMeshFromX( "C:\\Terrain.X", D3DXMESH_SYSTEMMEM, 
                                   g_pd3dDevice, NULL, 
                                   &pD3DXMtrlBuffer, NULL, &g_dwNumMaterials, 
                                   &g_pMesh ) ) )
    {
        return E_FAIL;
    }

    D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer();
    g_pMeshMaterials = new D3DMATERIAL9[g_dwNumMaterials];
    g_pMeshTextures  = new LPDIRECT3DTEXTURE9[g_dwNumMaterials];

    for( DWORD i=0; i<g_dwNumMaterials; i++ )
    {
        g_pMeshMaterials[i] = d3dxMaterials[i].MatD3D;

        g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse;

        g_pMeshTextures[i] = NULL;
        if( d3dxMaterials[i].pTextureFilename != NULL && 
            lstrlen(d3dxMaterials[i].pTextureFilename) > 0 )
        {
            if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, 
                                                d3dxMaterials[i].pTextureFilename, 
                                                &g_pMeshTextures[i] ) ) )
            {
                const TCHAR* strPrefix = TEXT("..\\");
                const int lenPrefix = lstrlen( strPrefix );
                TCHAR strTexture[MAX_PATH];
                lstrcpyn( strTexture, strPrefix, MAX_PATH );
                lstrcpyn( strTexture + lenPrefix, d3dxMaterials[i].pTextureFilename, MAX_PATH - lenPrefix );
                if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice, 
                                                    strTexture, 
                                                    &g_pMeshTextures[i] ) ) )
                {
                    MessageBox(NULL, "Could not find texture map", "Meshes.exe", MB_OK);
                }
            }
        }
    }

    pD3DXMtrlBuffer->Release();

    return S_OK;
}


VOID Cleanup()
{
    if( g_pMeshMaterials != NULL ) 
        delete[] g_pMeshMaterials;

    if( g_pMeshTextures )
    {
        for( DWORD i = 0; i < g_dwNumMaterials; i++ )
        {
            if( g_pMeshTextures[i] )
                g_pMeshTextures[i]->Release();
        }
        delete[] g_pMeshTextures;
    }
    if( g_pMesh != NULL )
        g_pMesh->Release();
    
    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}


VOID SetupMatrices()
{
    D3DXVECTOR3 vEyePt( 0.5f, 0.7f,-0.60f );
    D3DXVECTOR3 vLookatPt( 0.5f, 0.0f, 0.53f );
    D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
    D3DXMATRIXA16 matView;
    D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
    g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

    D3DXMATRIXA16 matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 0.001f, 100.0f );
    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}


VOID Render()
{
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        SetupMatrices();

        for( DWORD i=0; i<g_dwNumMaterials; i++ )
        {
            g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
            g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
        
            g_pMesh->DrawSubset( i );
        }

        g_pd3dDevice->EndScene();
    }

    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}


LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_DESTROY:
            Cleanup();
            PostQuitMessage( 0 );
            return 0;
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}


INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, 
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      "D3D Tutorial", NULL };
    RegisterClassEx( &wc );

    HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 06: Meshes", 
                              WS_OVERLAPPEDWINDOW, 100, 100, 640, 480,
                              GetDesktopWindow(), NULL, wc.hInstance, NULL );

    if( SUCCEEDED( InitD3D( hWnd ) ) )
    { 
        if( SUCCEEDED( InitGeometry() ) )
        {
            ShowWindow( hWnd, SW_SHOWDEFAULT );
            UpdateWindow( hWnd );

            MSG msg; 
            ZeroMemory( &msg, sizeof(msg) );
            while( msg.message!=WM_QUIT )
            {
                if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
                {
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
                else
                    Render();
            }
        }
    }

    UnregisterClass( "D3D Tutorial", wc.hInstance );
    return 0;
}


i rezultat je ovakav



Ovako izgleda sa Sample Framework-om:
Code:

#include "dxstdafx.h"
#include "resource.h"

CDXUTMesh g_Terrain;
D3DXVECTOR3 vecEye(0.5f, 0.7f, -0.6f);
D3DXVECTOR3 vecAt (0.5f, 0.0f, 0.53f);
D3DXVECTOR3 vecUp (0.0F, 1.0F,  0.0f);

HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
void    CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
void    CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
void    CALLBACK OnLostDevice();
void    CALLBACK OnDestroyDevice();

INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    DXUTSetCallbackDeviceCreated( OnCreateDevice );
    DXUTSetCallbackDeviceReset( OnResetDevice );
    DXUTSetCallbackDeviceLost( OnLostDevice );
    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
    DXUTSetCallbackFrameRender( OnFrameRender );
    DXUTSetCallbackFrameMove( OnFrameMove );

    DXUTSetCursorSettings( true, true );
    DXUTInit( true, true, true );
    DXUTCreateWindow( L"FirstGame" );
    DXUTCreateDevice( D3DADAPTER_DEFAULT, true, 640, 480, NULL, NULL );

    DXUTMainLoop();

    return DXUTGetExitCode();
}

HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc )
{
    HRESULT hr;

    D3DXMATRIXA16 matView;
    D3DXMatrixLookAtLH( &matView, &vecEye, &vecAt, &vecUp );
    pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

    D3DXMATRIXA16 matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 0.001f, 100.0f );
    pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

    pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
    pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

    pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );

    V_RETURN( g_Terrain.Create( pd3dDevice, L"C:\\Terrain.X" ) );


    return S_OK;
}

HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc )
{
    g_Terrain.RestoreDeviceObjects( pd3dDevice );

    return S_OK;
}

void    CALLBACK OnLostDevice()
{
    g_Terrain.InvalidateDeviceObjects();
}

void    CALLBACK OnDestroyDevice()
{
    g_Terrain.Destroy();
}

void    CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime )
{

}

void    CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime )
{
    HRESULT hr;
    pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    pd3dDevice->BeginScene();
        
        V( g_Terrain.Render( pd3dDevice ));

    pd3dDevice->EndScene();
    pd3dDevice->Present( NULL, NULL, NULL, NULL );
}


i rezultat je



Sta nije dobro u drugom slucaju pa je sve crno?

P.S. Ovo je mesh koji koristim (324kb) http://www.geocities.com/srki_82/Mesh.zip
I mesh i textura treba da budu u C:\ da bi radilo lepo jer ih tamo program trazi, a u X fajlu je definisano da se textura nalazi bas u C:\
[ Reljam @ 01.12.2004. 23:48 ] @
Cekaj, ti nigde ne ucitavas teksturu - DXUTMesh ti nece sam ucitati teksture, on ce samo da ti ucita materijale. Probaj da rucno ucitas teksturu i da je namestis sa SetTexture pre iscrtavanja.
[ Srki_82 @ 02.12.2004. 00:09 ] @
Pa CDXUTMesh ucitava texture i postavlja ih pre rendera:
Code:

HRESULT CDXUTMesh::Create( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strFilename )
{
    WCHAR        strPath[MAX_PATH];
    LPD3DXBUFFER pAdjacencyBuffer = NULL;
    LPD3DXBUFFER pMtrlBuffer = NULL;
    HRESULT      hr;

    // Find the path for the file, and convert it to ANSI (for the D3DX API)
    DXUTFindDXSDKMediaFileCch( strPath, sizeof(strPath) / sizeof(WCHAR), strFilename );

    // Load the mesh
    if( FAILED( hr = D3DXLoadMeshFromX( strPath, D3DXMESH_SYSTEMMEM, pd3dDevice, 
                                        &pAdjacencyBuffer, &pMtrlBuffer, NULL,
                                        &m_dwNumMaterials, &m_pSysMemMesh ) ) )
    {
        return hr;
    }

    // Optimize the mesh for performance
    if( FAILED( hr = m_pSysMemMesh->OptimizeInplace(
                        D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE,
                        (DWORD*)pAdjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL ) ) )
    {
        SAFE_RELEASE( pAdjacencyBuffer );
        SAFE_RELEASE( pMtrlBuffer );
        return hr;
    }

    // Set strPath to the path of the mesh file
    WCHAR *pLastBSlash = wcsrchr( strPath, L'\\' );
    if( pLastBSlash )
        *(pLastBSlash + 1) = L'\0';
    else
        *strPath = L'\0';

    hr = CreateMaterials( strPath, pd3dDevice, pAdjacencyBuffer, pMtrlBuffer );

    SAFE_RELEASE( pAdjacencyBuffer );
    SAFE_RELEASE( pMtrlBuffer );

    return hr;
}

Code:

HRESULT CDXUTMesh::CreateMaterials( LPCWSTR strPath, IDirect3DDevice9 *pd3dDevice, ID3DXBuffer *pAdjacencyBuffer, ID3DXBuffer *pMtrlBuffer )
{
    // Get material info for the mesh
    // Get the array of materials out of the buffer
    if( pMtrlBuffer && m_dwNumMaterials > 0 )
    {
        // Allocate memory for the materials and textures
        D3DXMATERIAL* d3dxMtrls = (D3DXMATERIAL*)pMtrlBuffer->GetBufferPointer();
        m_pMaterials = new D3DMATERIAL9[m_dwNumMaterials];
        if( m_pMaterials == NULL )
            return E_OUTOFMEMORY;
        m_pTextures = new LPDIRECT3DBASETEXTURE9[m_dwNumMaterials];
        if( m_pTextures == NULL )
            return E_OUTOFMEMORY;

        // Copy each material and create its texture
        for( DWORD i=0; i<m_dwNumMaterials; i++ )
        {
            // Copy the material
            m_pMaterials[i]         = d3dxMtrls[i].MatD3D;
            m_pTextures[i]          = NULL;

            // Create a texture
            if( d3dxMtrls[i].pTextureFilename )
            {
                WCHAR strTexture[MAX_PATH];
                WCHAR strTextureTemp[MAX_PATH];
                D3DXIMAGE_INFO ImgInfo;

                // First attempt to look for texture in the same folder as the input folder.
                MultiByteToWideChar( CP_ACP, 0, d3dxMtrls[i].pTextureFilename, -1, strTextureTemp, MAX_PATH );
                strTextureTemp[MAX_PATH-1] = 0;

                wcsncpy( strTexture, strPath, MAX_PATH );
                lstrcatW( strTexture, strTextureTemp );

                // Inspect the texture file to determine the texture type.
                if( FAILED( D3DXGetImageInfoFromFile( strTexture, &ImgInfo ) ) )
                {
                    // Search the media folder
                    if( FAILED( DXUTFindDXSDKMediaFileCch( strTexture, MAX_PATH, strTextureTemp ) ) )
                        continue;  // Can't find. Skip.

                    D3DXGetImageInfoFromFile( strTexture, &ImgInfo );
                }

                // Call the appropriate loader according to the texture type.
                switch( ImgInfo.ResourceType )
                {
                    case D3DRTYPE_TEXTURE:
                    {
                        IDirect3DTexture9 *pTex;
                        if( SUCCEEDED( D3DXCreateTextureFromFile( pd3dDevice, strTexture, &pTex ) ) )
                        {
                            // Obtain the base texture interface
                            pTex->QueryInterface( IID_IDirect3DBaseTexture9, (LPVOID*)&m_pTextures[i] );
                            // Release the specialized instance
                            pTex->Release();
                        }
                        break;
                    }
                    case D3DRTYPE_CUBETEXTURE:
                    {
                        IDirect3DCubeTexture9 *pTex;
                        if( SUCCEEDED( D3DXCreateCubeTextureFromFile( pd3dDevice, strTexture, &pTex ) ) )
                        {
                            // Obtain the base texture interface
                            pTex->QueryInterface( IID_IDirect3DBaseTexture9, (LPVOID*)&m_pTextures[i] );
                            // Release the specialized instance
                            pTex->Release();
                        }
                        break;
                    }
                    case D3DRTYPE_VOLUMETEXTURE:
                    {
                        IDirect3DVolumeTexture9 *pTex;
                        if( SUCCEEDED( D3DXCreateVolumeTextureFromFile( pd3dDevice, strTexture, &pTex ) ) )
                        {
                            // Obtain the base texture interface
                            pTex->QueryInterface( IID_IDirect3DBaseTexture9, (LPVOID*)&m_pTextures[i] );
                            // Release the specialized instance
                            pTex->Release();
                        }
                        break;
                    }
                }
            }
        }
    }
    return S_OK;
}

Code:

HRESULT CDXUTMesh::Render( LPDIRECT3DDEVICE9 pd3dDevice, bool bDrawOpaqueSubsets,
                          bool bDrawAlphaSubsets )
{
    if( NULL == m_pLocalMesh )
        return E_FAIL;

    // Frist, draw the subsets without alpha
    if( bDrawOpaqueSubsets )
    {
        for( DWORD i=0; i<m_dwNumMaterials; i++ )
        {
            if( m_bUseMaterials )
            {
                if( m_pMaterials[i].Diffuse.a < 1.0f )
                    continue;
                pd3dDevice->SetMaterial( &m_pMaterials[i] );
                pd3dDevice->SetTexture( 0, m_pTextures[i] );
            }
            m_pLocalMesh->DrawSubset( i );
        }
    }

    // Then, draw the subsets with alpha
    if( bDrawAlphaSubsets && m_bUseMaterials )
    {
        for( DWORD i=0; i<m_dwNumMaterials; i++ )
        {
            if( m_pMaterials[i].Diffuse.a == 1.0f )
                continue;

            // Set the material and texture
            pd3dDevice->SetMaterial( &m_pMaterials[i] );
            pd3dDevice->SetTexture( 0, m_pTextures[i] );
            m_pLocalMesh->DrawSubset( i );
        }
    }

    return S_OK;
}

I ako sam postavim texturu pre rendera CDXUTMesh ce ponovo postaviti onu koju je on ucitao. Sve deluje dobro... a ne radi.
[ Reljam @ 02.12.2004. 00:13 ] @
Ok, proveri samo prvo da li je DXUT stvarno ucitao teksturu - stavi breakpoint na pd3dDevice->SetTexture( 0, m_pTextures ); u CDXUTMesh::Render
i pogledaj da li je m_pTextures NULL. Moguce je da DXUT nije nasao teksturu.

Ako nije NULL i ako i dalje ne radi, posalji mi ceo projekat ili ga zakaci negde na web, pa cu da pogledam o cemu se radi.
[ Srki_82 @ 02.12.2004. 00:30 ] @
Nasao sam sta je :) Od tolikog obracanja na texturu zaboravio sam da pogledam koje se vrednosti nalaze za Diffuse i Ambient u materijalu. Kao sto predpostavljas Ambient je crna boja :P Kada sam je podesio da bude kao Diffuse sve radi kako treba i sad konacno mogu da odem na spavanje :)

Hvala ti, Relja... izvini sto sam te davio zbog ove sitnice.
[ Reljam @ 02.12.2004. 00:33 ] @
Ma jok, nema veze :)

Uvek se dese tako neke sitne gluposti, zato ljudi i rade code review-ove: ono sto promakne jednom, u vecini slucajeva nece drugom.