Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

05.05.2007, 10:55

Textur Probleme beim Laden von X-Files

Hallo zusammen
Ich habe momanten ein Problem beim Laden von X-Files und zwar wird das X-File immer weiß dargestellt wenn es gerendert wird woran kann das liegen ich poste mal den Code zum laden von X-Files.

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
objekt::objekt()
    {
    mesh = NULL;
    materialien = NULL;
    anz_mat = 0;
    texturen = NULL;
    }

objekt::~objekt()
    {
    unsigned int i;

    if( materialien) 
        delete[] materialien;

    if( texturen)
        {
        for( i = 0; i < anz_mat; i++ )
            {
            if( texturen[i])
                texturen[i]->Release();
            }
        delete[] texturen;
        }
    if( mesh)
        mesh->Release();   
    }
void objekt::Init(LPDIRECT3DDEVICE9 m_device)
{
    device  = m_device;
    
}
void objekt::load( char *xfile)
    {
    LPD3DXBUFFER buf;
    D3DXMATERIAL* mat; 
    DWORD i;

    D3DXLoadMeshFromXA( xfile,D3DXMESH_SYSTEMMEM, device, NULL, &buf, NULL, &anz_mat, &mesh);

    mat = (D3DXMATERIAL*)buf->GetBufferPointer();
    materialien = new D3DMATERIAL9[anz_mat];
    texturen  = new LPDIRECT3DTEXTURE9[anz_mat];

    for( i=0; i<anz_mat; i++)
        {
        materialien[i] = mat[i].MatD3D;
        materialien[i].Ambient.r = 1.0f;
        materialien[i].Ambient.g = 1.0f;
        materialien[i].Ambient.b = 1.0f;
        if( D3DXCreateTextureFromFileA( device, mat[i].pTextureFilename, &texturen[i]) < 0) 
           texturen[i] = NULL;
        }
    buf->Release();
    }
void objekt::SetPosition(D3DXVECTOR3 vPos)
{
    m_vPosition = vPos;
}
void objekt::SetRotation(float RotX,float RotY, float RotZ)
{
    m_RotX = RotX;
    m_RotY = RotY;
    m_RotZ = RotZ;
}
void objekt::draw()
    {

    D3DXMATRIX TransMatrix;
    D3DXMATRIX RotMatrix;
    D3DXMATRIX RotMatrixX, RotMatrixY, RotMatrixZ;
    D3DXMATRIX WorldMatrix;

    // Rotationsmatrizen anlegen

    D3DXMatrixRotationX(&RotMatrixX,m_RotX);
    D3DXMatrixRotationY(&RotMatrixY,m_RotY);
    D3DXMatrixRotationZ(&RotMatrixZ,m_RotZ);
   
    D3DXMatrixIdentity(&RotMatrix);

    // und miteinander multiplizieren

    D3DXMatrixMultiply(&RotMatrix,&RotMatrix,&RotMatrixX);
    D3DXMatrixMultiply(&RotMatrix,&RotMatrix,&RotMatrixY);
    D3DXMatrixMultiply(&RotMatrix,&RotMatrix,&RotMatrixZ);
    
    
    // Transformations und Rotationsmatrix zur Weltmatrix zusammenfassen

    D3DXMatrixMultiply(&WorldMatrix,&RotMatrix,&TransMatrix);

    D3DXMatrixTranslation(&TransMatrix,m_vPosition.x,m_vPosition.y,m_vPosition.z);

    D3DXMatrixMultiply(&WorldMatrix,&RotMatrix,&TransMatrix);

    device->SetTransform(D3DTS_WORLD,&WorldMatrix);

    unsigned int i;

    for( i=0; i < anz_mat; i++ )
        {
        device->SetMaterial( &materialien[i]);
        device->SetTexture( 0, texturen[i]);
        mesh->DrawSubset( i);
        }
}

Also das X-File wird geladen aber die Textur fehlt eben wäre Euch für eine Hilfe sehr dankbar.
Gruß Andy

2

10.05.2007, 13:17

Ich würde mal folgendes kontrollieren:

1. Die Datei-Pfade zu den Texturen in der X-Datei (mit Notepad o.ä.)
2. Hast du ein Unicode-Projekt, und verwendest D3DXCreateTextureFromFileA ?
3. Die If-Abfrage ("< 0") bei D3DXCreateTextureFromFileA mal rausnehmen
4. Die Ambient-Werte (1.0f) auskommentieren, das ist ja schneeweiß!
5. Hast du überhaupt Licht in der Szene? (D3DRS_LIGHTING, LightEnable...)
fka tm