can't set my texture correctly

Problems with Canvas, OpenGL, etc...

can't set my texture correctly

Postby Vziuh » Fri May 27, 2011 12:01 pm

hi people.
I've started to learn openGL in android, and i've met some problem. i have 3d model in .ASE file, i wrote code witch read all data about mesh vertex, texture vertex and face indeces. I've checked all data which i transmit in buffer and they are the same as in .ASE file ( that means i didn't lose nothing )

here is the screenshot of 3d model in 3d max

Image


here's how it's looks on emulator
Image

after this i tried with simple object, here's screenshot from 3d max and how it's looks on emulator

Image


here's texture i use:
Image

help me please.
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Top

Re: can't set my texture correctly

Postby bxm » Sun May 29, 2011 2:10 am

There's not a lot to go on here... but at first glance I would ask if you've double checked your texture coordinate settings.
bxm
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue May 10, 2011 2:51 am

Re: can't set my texture correctly

Postby Vziuh » Sun May 29, 2011 11:29 pm

here's .ASE file in .txt format and the output of my texture_vertex_array ( so you can compare texture coordinates ) they are the same ( i think i did it right ).

i don't remembere where, i've read about that the coordinate Y is inversed.
i wrote new method, where i rewrite all texture and vertex coordinate, here it is:
Code: Select all

private void fix_arrays ()
      {
         
         float[] new_vert  = new float [ face_num * 3 * 3 ] ;
         float[] new_tvert = new float [ face_num * 3 * 2 ] ;
         byte [] new_index = new byte  [ face_num * 3 ] ;

         for ( int i = 0 ; i < face_num * 3 ; i ++ )
         {

            new_vert  [ i * 3 ] = vertex_coords [ index_array   [ i ] * 3 ] ;
            new_tvert [ i * 2 ] = texture_data  [ texture_index [ i ] * 2 ] ;
            

            new_vert  [ i * 3 + 1 ] =        vertex_coords [ index_array   [ i ] * 3 + 1 ] ;
            new_tvert [ i * 2 + 1 ] = 1.0f - texture_data  [ texture_index [ i ] * 2 + 1 ] ;

            new_vert  [ i * 3 + 2 ] = vertex_coords [ index_array   [ i ] * 3 + 2 ] ;

            
            new_index[ i ] = ( byte ) i ;
                     
         }
         
         
         vertex_num         = vertex_coords.length ;
         texture_vertex_num = vertex_coords.length ;
         
         vertex_coords = new_vert  ;
         index_array   = new_index ;
         texture_data  = new_tvert ;
      }



i've set my simple box.
and look what i get:

( everything is fine )


Image


________________________________________________________________________

so with simple model everything is ok, but when i've set my robot model, i've got this:


Image


i've got only the part of my model =(
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Re: can't set my texture correctly

Postby bxm » Tue May 31, 2011 5:02 am

I don't have much time right now to browse through all of the vertex data, but are you sure your "fix" function is not cutting the data short - since you are practically recreating the areas you should be sure that there is not a counting issue, as that would be the easiest problem to notice. You can also try just disabling texture with the current methods to see if the rest of the model is drawn, without textures, otherwise you lost some vertex information somewhere.
bxm
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue May 10, 2011 2:51 am

Re: can't set my texture correctly

Postby Vziuh » Thu Jun 02, 2011 3:14 pm

damn you're right, this method is cutting my model, but i don't wont to use it, after rewriteing, all my arrays becom bigger by 3 times. that's bad, i need to find some ather method to set my texture.
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Re: can't set my texture correctly

Postby bxm » Sun Jun 05, 2011 2:29 am

Why not just modify the Y coordinate at draw time? When I draw in 2D I just subtract the screen's height, obviously it's a different calculation in 3d but the general concept should be the same, no?
bxm
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue May 10, 2011 2:51 am

Top

Re: can't set my texture correctly

Postby Vziuh » Thu Jun 09, 2011 4:40 pm

i've tried this way, after reading y coord, i've did transformation like this: texture_array [ y ] = 1 - y_coord ;
as resul i had something like in first time, when i saw texture problem ( but it was little bit different ) but still no OK =).
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Re: can't set my texture correctly

Postby GerdGerdGerd » Thu Jun 09, 2011 6:47 pm

try to flip your texture horizontal or vertical or both. this works for me very well.

greetz
GerdGerdGerd
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sun Jun 05, 2011 6:14 pm

Re: can't set my texture correctly

Postby Vziuh » Sat Jun 11, 2011 8:07 am

Can you show your part of code where you are reading texture coordinate
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Re: can't set my texture correctly

Postby GerdGerdGerd » Sat Jun 11, 2011 1:48 pm

i mean flip the texture with an graphic programm. you don't have to change the texture coordinates. its a workaround but it works..

here you can see the uv map:
uv_map.jpg
uv_map.jpg (28.12 KiB) Viewed 401 times


and here is the texture after flipping.
die_Cube.png
die_Cube.png (22.63 KiB) Viewed 401 times



greetz
GerdGerdGerd
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sun Jun 05, 2011 6:14 pm

Re: can't set my texture correctly

Postby mr-cool » Fri Jul 15, 2011 4:17 pm

sorry a lot dear...these texture and their co-ordinates coding is too above than my mind can understand....:).........................lols...........
good luck
mr-cool
Freshman
Freshman
 
Posts: 6
Joined: Fri Jul 15, 2011 1:48 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests