Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  OBJ conventions  (Read 12573 times)
0 Members and 1 Guest are viewing this topic.
Offline Oxen

Junior Devvie


Medals: 5
Exp: 6 years



« Posted 2016-05-09 08:38:32 »

I have been improving my engine to use larger models but I have seen some with strange data inside.

It was my understanding that the face elements at the end of the file should consist of three sets of data containing, Indices , texture coords and normals. But i found a teapot example with face data in this format.

1  
f 7771/8201 7770/8200 7758/8187 7759/8188 


I know it's the indices and texture data but why is there 4 sets of data??
Offline Phased
« Reply #1 - Posted 2016-05-09 08:49:18 »

For that face you have shown; the face is a quad, as their is 4 vertices per face.

if it was a triangle, their would be 3.

You will need to write some code to triangulate the faces or load it into blender and export it with the triangulate checkbox on.
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #2 - Posted 2016-05-12 13:50:06 »

You can manipulate this to turn quadrilaterals to triangles:
1  
2  
3  
4  
int[] vertexIndicesRectangle = new int[]{1, 2, 3, 4}

int[] vertexIndicesTriangle1 = new int[]{vertexIndicesRectangle[0], vertexIndicesRectangle[1], vertexIndicesRectangle[2]}
int[] vertexIndicesTriangle2 = new int[]{vertexIndicesRectangle[2], vertexIndicesRectangle[3], vertexIndicesRectangle[0]}


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Oxen

Junior Devvie


Medals: 5
Exp: 6 years



« Reply #3 - Posted 2016-05-12 14:13:55 »

For that face you have shown; the face is a quad, as their is 4 vertices per face.

Ahh okay, thanks. I was not sure...I exported that model on a different pc so my settings must be different, thanks!
Offline Riven
Administrator

« JGO Overlord »


Medals: 1370
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2016-05-12 17:06:24 »

You can manipulate this to turn quadrilaterals to triangles:
1  
2  
3  
4  
int[] vertexIndicesRectangle = new int[]{1, 2, 3, 4}

int[] vertexIndicesTriangle1 = new int[]{vertexIndicesRectangle[0], vertexIndicesRectangle[1], vertexIndicesRectangle[2]}
int[] vertexIndicesTriangle2 = new int[]{vertexIndicesRectangle[1], vertexIndicesRectangle[2], vertexIndicesRectangle[3]}


This is a highly unlikely pattern.

Use {0,1,2}, {2,3,0} as mappings.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #5 - Posted 2016-05-12 18:02:41 »

This is a highly unlikely pattern.

Use {0,1,2}, {2,3,0} as mappings.

I was just showing the exact indices coming from another array so OP gets a good idea.

Offline Riven
Administrator

« JGO Overlord »


Medals: 1370
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2016-05-12 19:28:22 »

This is a highly unlikely pattern.

Use {0,1,2}, {2,3,0} as mappings.

I was just showing the exact indices coming from another array so OP gets a good idea.
And I was just saying that your indirection layer is highly unlikely to be correct.
You create two triangles that partially overlap and do not fill the whole quad.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #7 - Posted 2016-05-13 00:08:19 »

Read that wrong, whoops! Fixing it now. Thanks!

Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #8 - Posted 2016-05-13 08:51:24 »

it's only important to create two triangles with the correct winding, CW or CCW - whatever your GL is set to.

something i learned about importing quads is importance of the information.

once transformed into triangles it's still interesting to know which triangle belongs to a quad.

when generating normals and the quad wasn't perfectly flat.
when processing the mesh; subdivision or smoothing. iterating over vertex-neighbour-edges, that extra edge needs special attention.

o/
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (207 views)
2019-09-04 15:33:17

hadezbladez (4947 views)
2018-11-16 13:46:03

hadezbladez (1824 views)
2018-11-16 13:41:33

hadezbladez (5222 views)
2018-11-16 13:35:35

hadezbladez (1029 views)
2018-11-16 13:32:03

EgonOlsen (4407 views)
2018-06-10 19:43:48

EgonOlsen (5239 views)
2018-06-10 19:43:44

EgonOlsen (2986 views)
2018-06-10 19:43:20

DesertCoockie (3880 views)
2018-05-13 18:23:11

nelsongames (4312 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!