• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    DWF

    Reply
    Contributor
    Posts: 20
    Registered: ‎08-04-2006

    Texture doesn't map correctly

    573 Views, 4 Replies
    10-21-2006 07:33 AM
    Hi,

    Well, I have problems with texture mapping. The texture and texture coordinates are both loaded successfully, but I get unexpected results when I try to render the object. It seems as there is a problem with texture coordinates. Attached are two screenshots of the problem. A log of the data also follows. Any ideas?

    Thank you all.

    Vertex Buffer:
    Size: 31
    Vertex[ 0 ]: -87.739464, -72.413788, 0.000000
    Vertex[ 1 ]: -87.739464, -72.413788, 0.000000
    Vertex[ 2 ]: -87.739464, -72.413788, 0.000000
    Vertex[ 3 ]: -87.739464, -72.413788, 0.000000
    Vertex[ 4 ]: -87.739464, 72.413788, 0.000000
    Vertex[ 5 ]: -87.739464, 72.413788, 0.000000
    Vertex[ 6 ]: -87.739464, 72.413788, 0.000000
    Vertex[ 7 ]: 87.739464, -72.413788, 0.000000
    Vertex[ 8 ]: 87.739464, -72.413788, 0.000000
    Vertex[ 9 ]: 87.739464, -72.413788, 0.000000
    Vertex[ 10 ]: -87.739464, -72.413788, 245.210724
    Vertex[ 11 ]: -87.739464, -72.413788, 245.210724
    Vertex[ 12 ]: -87.739464, -72.413788, 245.210724
    Vertex[ 13 ]: -87.739464, -72.413788, 245.210724
    Vertex[ 14 ]: 87.739464, 72.413788, 0.000000
    Vertex[ 15 ]: 87.739464, 72.413788, 0.000000
    Vertex[ 16 ]: 87.739464, 72.413788, 0.000000
    Vertex[ 17 ]: 87.739464, 72.413788, 0.000000
    Vertex[ 18 ]: -87.739464, 72.413788, 245.210724
    Vertex[ 19 ]: -87.739464, 72.413788, 245.210724
    Vertex[ 20 ]: -87.739464, 72.413788, 245.210724
    Vertex[ 21 ]: -87.739464, 72.413788, 245.210724
    Vertex[ 22 ]: 87.739464, -72.413788, 245.210724
    Vertex[ 23 ]: 87.739464, -72.413788, 245.210724
    Vertex[ 24 ]: 87.739464, -72.413788, 245.210724
    Vertex[ 25 ]: 87.739464, -72.413788, 245.210724
    Vertex[ 26 ]: 87.739464, 72.413788, 245.210724
    Vertex[ 27 ]: 87.739464, 72.413788, 245.210724
    Vertex[ 28 ]: 87.739464, 72.413788, 245.210724
    Vertex[ 29 ]: 87.739464, 72.413788, 245.210724
    Vertex[ 30 ]: 87.739464, 72.413788, 245.210724

    Texture Coordinates:
    TexCoord[ 0 ]: 1.000000, 0.000000
    TexCoord[ 1 ]: 0.000000, 0.000000
    TexCoord[ 2 ]: 0.000000, 0.000000
    TexCoord[ 3 ]: 1.000000, 0.000000
    TexCoord[ 4 ]: 0.000000, 1.000000
    TexCoord[ 5 ]: 0.000000, 0.000000
    TexCoord[ 6 ]: 0.000000, 0.000000
    TexCoord[ 7 ]: 0.000000, 1.000000
    TexCoord[ 8 ]: 0.000000, 0.000000
    TexCoord[ 9 ]: 1.000000, 1.000000
    TexCoord[ 10 ]: 0.000000, 0.000000
    TexCoord[ 11 ]: 0.000000, 0.000000
    TexCoord[ 12 ]: 0.000000, 0.000000
    TexCoord[ 13 ]: 0.000000, 1.000000
    TexCoord[ 14 ]: 0.000000, 0.000000
    TexCoord[ 15 ]: 0.000000, 0.000000
    TexCoord[ 16 ]: 0.000000, 1.000000
    TexCoord[ 17 ]: 1.000000, 0.000000
    TexCoord[ 18 ]: 0.000000, 1.000000
    TexCoord[ 19 ]: 0.000000, 1.000000
    TexCoord[ 20 ]: 1.000000, 0.000000
    TexCoord[ 21 ]: 0.000000, 1.000000
    TexCoord[ 22 ]: 0.000000, 1.000000
    TexCoord[ 23 ]: 0.000000, 0.000000
    TexCoord[ 24 ]: 0.000000, 1.000000
    TexCoord[ 25 ]: 0.000000, 0.000000
    TexCoord[ 26 ]: 0.000000, 0.000000
    TexCoord[ 27 ]: 0.000000, 1.000000
    TexCoord[ 28 ]: 0.000000, 1.000000
    TexCoord[ 29 ]: 1.000000, 0.000000
    TexCoord[ 30 ]: 0.000000, 1.000000
    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎08-04-2006

    Re: Texture doesn't map correctly

    10-21-2006 07:36 AM in reply to: TheUnknown
    Seems only one attachment is allowed per post.
    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎08-04-2006

    Re: Texture doesn't map correctly

    10-21-2006 07:44 AM in reply to: TheUnknown
    You guys can't be of much help without some code, right?

    Here is the code to load the texture and save that into a file. Our texture loader can only load textures from files and doesn't support streams for now:

    DWFGraphicResource* pTxtr;

    for ( ; piImageResources->valid(); piImageResources->next() ) {
    pTxtr = dynamic_cast< DWFGraphicResource* >( piImageResources->get() );
    size_t sizeReq = 0;

    if ( pTxtr ) {
    DWFInputStream* pTxtrStrm = pTxtr->getInputStream();
    sizeReq = pTxtrStrm->available();
    if( sizeReq > 0 ) {
    char* pImageData = new char[ sizeReq ];
    size_t imageNameSize = pTxtr->title().bytes();
    char* pImageName = new char[ imageNameSize ];

    pTxtrStrm->read( pImageData, sizeReq );
    pTxtr->title().getUTF8( pImageName, imageNameSize );


    m_TextureMap[ pImageName ] = pImageData;

    FILE* textureFile = fopen( ".\\test.jpg", "w+b" );
    fwrite( pImageData, sizeof( char ), sizeReq, textureFile );
    fclose( textureFile );
    }
    }
    char* texturefilename = new char[ 16 ];
    sprintf( texturefilename, "test.jpg" );
    m_vecTextureFileName.push_back( texturefilename );
    }

    Texture coordinates are also read with a call to TK_Shell::GetVertexParameters() in a corresponding opcode handler.

    Thanks in advance.
    Please use plain text.
    Contributor
    binhpt
    Posts: 14
    Registered: ‎01-17-2012

    Re: Texture doesn't map correctly

    06-18-2012 07:16 PM in reply to: TheUnknown

    I can't get correct textcoords from TK_Shell, somebody show me how to get correctly textcoords from TK_SHELL thanks.

     

    My code : 

    ....................

    TK_Shell handle ---------------------

    Excute function ...

    ...

     

    if(*(this->GetExists()) == Vertex_Parameter)
    {

    float * uv = this->GetVertexParameters();

    if(uv != NULL)
    {
       for(i=0;i<numOfVertex*2;i+=2)
       { 
            printf("u=%f v=%f \n",uv[i],uv[i+1]);
        }
    }

    }

    Please use plain text.
    Contributor
    binhpt
    Posts: 14
    Registered: ‎01-17-2012

    Re: Texture doesn't map correctly

    06-18-2012 07:29 PM in reply to: binhpt

    Textcoords : 

    u=21.777624 v=8.676469
    u=-5.416665 v=21.777624
    u=7.427665 v=22.254717
    u=-7.325036 v=8.896846
    u=22.095686 v=-7.325036
    u=8.896846 v=22.254717
    u=-7.325036 v=8.823387
    u=-6.847943 v=21.777624
    u=8.896846 v=-5.416665
    u=21.936655 v=8.823387
    u=-5.416665 v=21.936655
    u=8.896846 v=21.936655
    ........
    ..................

     

    the value not be between 0...1

     

    Thanks !

    Please use plain text.