Problem mit Modelloading



  • Hi,

    ich habe ein Problem beim Milkshapemodelloading: Ich habe ein Programm geschrieben, welches bewegte(mit boneanimation), texturierte Ms3d-Moldels rendert. Mit untexturierten bewegten Models funktioniert dies auch wunderbar, sind jedoch die Models texturiert erscheint beim starten des Programmes der unten aufgeführen Fehler. Lade ich jedoch nur texturierte Models ohne boneanimation funktioniert dies. Weiß irgend einer von euch, warum diese beiden Sachen nicht zusammen funktionieren oder woran der Fehler liegen könnte.

    Hier nun der Fehler:

    Assertion failed: frame > 0 && frame < pJoint->m_numRotationKeyframes, file C:\
    ...Animation\model.cpp, line 435

    abnormal program terminaton

    Hier die entsprechenden Codezeilen

    model.cpp
    //...
    
    frame = pJoint->m_currentRotationKeyframe;
            while ( frame < pJoint->m_numRotationKeyframes
                    && pJoint->m_pRotationKeyframes[ frame ].m_time < time )
            {
                frame++;
    
            }
            pJoint->m_currentRotationKeyframe = frame;
    
            if ( frame == 0 )
            {
                transform.setRotationRadians( pJoint->m_pRotationKeyframes[ 0 ].m_parameter );
            }
            else
            {
                if ( frame == pJoint->m_numRotationKeyframes )
                {
                    transform.setRotationRadians( pJoint->m_pRotationKeyframes[ frame - 1 ].m_parameter );
                }
                else
                {
                    assert( frame > 0 && frame < pJoint->m_numRotationKeyframes );/////////////////////hier
    
                    const Model::Keyframe& curFrame =
                        pJoint->m_pRotationKeyframes[ frame ];
                    const Model::Keyframe& prevFrame =
                        pJoint->m_pRotationKeyframes[ frame - 1 ];
    
                    float timeDelta = curFrame.m_time - prevFrame.m_time;
                    float interpValue = ( float ) ((time - prevFrame.m_time)
                                                   / timeDelta);
    
                    assert( interpValue >= 0 && interpValue <= 1 );
    
    //...
    

    Quellcode für die Textur des Models:

    textur.h
    
    unsigned texture;
    
    unsigned LoadTexture(const char *filename)
    {
        SDL_Surface *bitmap, *conv;
    //    unsigned texture[3];
    
        bitmap = SDL_LoadBMP(filename);
        if (!bitmap) {
            fprintf(stderr, "%s: konnte nicht geladen werden\n", filename);
            exit(1);
        }
    
    	    conv = SDL_CreateRGBSurface(SDL_SWSURFACE, bitmap->w, bitmap->h, 32,
    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
                0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
    #else
                            0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
    #endif
        SDL_BlitSurface(bitmap, 0, conv, 0);
    
    	    glGenTextures(1, &texture);
    
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, conv->pitch / conv->format->BytesPerPixel);
        glTexImage2D(GL_TEXTURE_2D, 0, 3, conv->w, conv->h, 0, GL_RGBA,
            GL_UNSIGNED_BYTE, conv->pixels);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    
    	    SDL_FreeSurface(bitmap);
        SDL_FreeSurface(conv);
    
        return texture;
    }
    
    model.cpp
    
    void Model::reloadTextures()
    {
    	for ( int i = 0; i < m_numMaterials; i++ )
    		if ( strlen( m_pMaterials[i].m_pTextureFilename ) > 0 )
    			m_pMaterials[i].m_texture = LoadTexture( m_pMaterials[i].m_pTextureFilename );
    		else
    			m_pMaterials[i].m_texture = 0;
    }
    

    Bitte helft mir.

    Gruß Crabbe



  • Schonmal den Debugger versucht? Man kann nicht viel mehr sagen, als: Der Wert liegt wahrscheinlich nicht in dem Bereich.

    Bye, TGGC \-/



  • Hi,

    erst einmal Danke für die Antwort, aber eine Textur verändert doch nicht den Wert der frames oder der Keyframes? Wenn ich das Model ohne Textur rendere funzt das ja auch.

    Gruß Crabbe


  • Mod

    wenn es einen speicherüberschreiber gibt, dann könnte das passieren, setz einfach einen breakpoint nach dem laden des models, dass wenn die variable verändert wird, das programm im debugger stopt, dann weißt du was dort einen falschen wert einfügt. (geht im devstudio)

    rapso->greets();



  • Crabbe schrieb:

    aber eine Textur verändert doch nicht den Wert der frames oder der Keyframes

    Offensichtlich doch. Halte dich an Holmes.

    Bye, TGGC \-/



  • Hi,

    wenn ich den Debug starte funzt mein Programm einwandfrei und der Debug zeigt dann natürlich auch keine Fehler an. *freu*
    Aber wenn ich mein Programm ganz normal starten will, wird der oben angegebene Fehler angezeigt.

    Gruß Crabbe



  • Die MSDN beschreibt die Unterschiede.

    Bye, TGGC \-/



  • Äh, was ist die MSDN?

    Gruß Crabbe



  • http://msdn.microsoft.com/library/
    msdn ist das online nachschlagewerk für windowsprogrammierung



  • Ja und wie hilft mir das weiter. Ich habe da bis jetzt nichts brauchbares gefunden.

    Gruß Crabbe






Anmelden zum Antworten