Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3422280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:11:53+00:00 2026-05-18T06:11:53+00:00

I’m parsing an OBJ-file in Android and my goal is to render & display

  • 0

I’m parsing an OBJ-file in Android and my goal is to render & display the object. Everything works fine except the correct texture mapping (importing the resource/image into opengl etc works fine).

I don’t know how to populate the texture related data from the obj-file into an texturebuffer-object.

In the OBJ-file I’ve vt-lines:

vt 0.495011 0.389417 
vt 0.500686 0.561346

and face-lines:

f 127/73/62 98/72/62 125/75/62

My draw-routine looks like (only relevant parts):

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glNormalPointer(GL10.GL_FLOAT, 0, normalsBuffer);

gl.glTexCoordPointer(2, GL10.GL_SHORT, 0, t.getvtBuffer());

gl.glDrawElements(GL10.GL_TRIANGLES, t.getFacesCount(), GL10.GL_UNSIGNED_SHORT, t.getFaceBuffer());

Output of the counts of the OBJ-file:

Vertex-count: 1023
Vns-count: 1752
Vts-count: 524
/////////////////////////
Part 0
Material name:default
Number of faces:2037
Number of vnPointers:2037
Number of vtPointers:2037

Any advise is welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:11:54+00:00Added an answer on May 18, 2026 at 6:11 am

    Sorry, not sure to what extent this is patronising, but from the top:

    f 127/73/62 98/72/62 125/75/62
    

    Means a triangle between the vertex with the 127th position given in the file, the 73rd texture position in the file and the 62nd normal and the two other vertices specified in a similar way.

    In OpenGL you specify only a single index per vertex (as the whole thing goes through the transform as a single unit), so you need to figure out all the different combinations of position, texture coordinate and normal and arrange the buffers you pass to glVertexPointer, glNormalPointer and glTexCoordPointer accordingly. For example, the above face might end up being specified via GL_TRIANGLES as between vertices 0, 1 and 2, where you’d copied the 127th position to the first in your internal vertex buffer, you’d copied the 73rd texture coordinate to the first in your internal texture coordinate buffer and you’d copied the 62nd normal to the first in your internal normal list.

    Quite probably you want a HashMap taking the combination key vertex/texture coordinate/normal and mapping to a position in your internal arrays. As you come across each face in the incoming OBJ, you can check whether you’ve already got that combination allocated to a spot in your internal buffers and give it the next available one if not.

    vt is a texture coord, so e.g. the texture coordinate:

    vt 0.495011 0.389417
    

    Means that, within texture space, x = 0.495011, y = 0.389417. From memory, the OBJ file format and OpenGL have the y axes in opposite directions. So in OpenGL terms you’d want s = 0.495011, t = 1 – 0.389417 = 0.610583.

    If your object is using a suitably complicated texture atlas or skinning, I imagine it would be far from obvious that the y coordinates are flipped; if you just have something like a cube with the same texture repeated in its entirety on each face then you’d probably just see it as being flipped along the vertical.

    Does that cover the source of confusion?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
i want to parse a xhtml file and display in UITableView. what is the
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.