Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Iphone: Importing 3DS objects via OBJ file; export or import issue?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 babarorhum   Members   -  Reputation: 100

Like
0Likes
Like

Posted 11 December 2011 - 03:48 PM

Hello,

I have recently downloaded the 30-day trial version of 3DSMAX 2012; and would like to import some of my objects into an IPhone application.
My idea has been to export the file from 3DS in OBJ format and read them from my app afterward. From the App log, i can see that all vertex data are correctly read as i can see exactly the values as they are defined in the OBJ file. However, what i get on the iphone simulator is not what i have drawn on 3DS.

To simplify my investigation, i have imported a cube; with the following vertices (see the attached screenshots; one being the object drawn, second being the object shown in the iphone simulator)

-49.6109f, -37.0908f, 14.4273f,
-10.8045f, 40.7808f, 59.8638f,
76.1792f, 40.7808f, -14.4273f,
37.3728f, -37.0908f, -59.8638f,
-25.655f, -65.3948f, 42.476f,
61.3287f, -65.3948f, -31.8151f,
100.1351f, 12.4768f, 13.6214f,
13.1514f, 12.4768f, 87.9125f,

The code i use in the drawing method is the following:



glVertexPointer(3, GL_FLOAT, 0, [drawObjectTmp getVertices]);

glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);







With the arrays of drawobjectmp having the exact values described in the OBJ file. Note also that the GL_TRIANGLES option has presented similar results on the screen.

My current assumption is that something has to be done on the objects in 3DS studio max to export the file with a certain vertex "order"; however i am a total beginner in 3DS so it makes my troubleshooting rather slow. I have couple of leads on teslta to transform surface into trianges but it didn't really work out on the simulator screen either. I have tried also exporting the objects with the triange option on; didn't help either.

I am sure it's a trivial issue for any experienced person in opengl and 3ds max; but i am not , yet :)
so i am open for any suggestions, pointers to good tutorials or demos on this particular topic.
Thanks :)))

Babarorhum

Attached Thumbnails

  • Cube in 3DSMAX.jpg
  • Iphone Simulator Results.jpg


Sponsor:

#2 Kobo   Members   -  Reputation: 128

Like
0Likes
Like

Posted 12 December 2011 - 11:57 AM

So, I don't know much about openGL but have you tried using GL_POLYLGON or some other mode instead of GL_TRIANGLE_STRIP ?

#3 babarorhum   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 December 2011 - 01:06 PM

Hello Kobo,
Thanks for your suggestion.
However neither GL_POLYGON nor GL_QUADS options are available for this version openGL. I found on a blog a post describing how to draw polygons with GL_TRIANGE_STRIP, hence my attempt.

Since yesterday i've found out one bug though: the last parameter of the DrawArray method doesn't represent the number of vertices but the total number of elements within the array, e.g. 32 in the example. It helps in a way: it creates more gibberish on the screen; which is some sort of progress right ? Posted Image

Currently suspecting either the way i export from 3ds studio or something funny in my code to display the vertices.

BabarOrhum

So, I don't know much about openGL but have you tried using GL_POLYLGON or some other mode instead of GL_TRIANGLE_STRIP ?



#4 babarorhum   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 December 2011 - 06:15 PM

An update on this question: I have installed the trial version of Lightwave to study the export functionality to OBJ and i have redrawn a similar cube as the 3DS studio version.

It works right away into the Iphone app software which confirms the idea that i am missing some options in 3DS studio either while "designing" the cube or exporting it.

As example, lightwave pulls out the following list of vertices; which is much longer than the previous ones for a similar structure created in 3DS (see above post). I also enclose the screenshot of the created cube in lightwave. One major difference is that each face of the cube is made of triangle. Interesting thing: when i "tesselate" the cube under 3ds studio it gives the same visual appearance (2 triangles per face)but exporting it ,doesn't give the same list.

If any of you has a similar experience and know how to transform geometric structure in 3DS to obtain such result ; you will make my day :)

-Babarorhum

the Lightwave vertices:
0.300401f, -0.718622f, 2.07324f,

-1.17128f, -1.47058f, 1.03826f,

-0.187194f, -2.136f, 0.122397f,

1.28449f, -1.38403f, 1.15738f,

0.300401f, -0.718622f, 2.07324f,

-0.187194f, -2.136f, 0.122397f,

-1.17128f, -0.0143543f, -0.0197569f,

-0.187194f, -0.679765f, -0.935616f,

-0.187194f, -2.136f, 0.122397f,

-1.17128f, -1.47058f, 1.03826f,

-1.17128f, -0.0143543f, -0.0197569f,

-0.187194f, -2.136f, 0.122397f,

0.300401f, 0.737608f, 1.01523f,

-1.17128f, -0.0143543f, -0.0197569f,

-1.17128f, -1.47058f, 1.03826f,

0.300401f, -0.718622f, 2.07324f,

0.300401f, 0.737608f, 1.01523f,

-1.17128f, -1.47058f, 1.03826f,

0.300401f, 0.737608f, 1.01523f,

0.300401f, -0.718622f, 2.07324f,

1.28449f, -1.38403f, 1.15738f,

1.28449f, 0.0721975f, 0.0993714f,

0.300401f, 0.737608f, 1.01523f,

1.28449f, -1.38403f, 1.15738f,

1.28449f, 0.0721975f, 0.0993714f,

1.28449f, -1.38403f, 1.15738f,

-0.187194f, -2.136f, 0.122397f,

-0.187194f, -0.679765f, -0.935616f,

1.28449f, 0.0721975f, 0.0993714f,

-0.187194f, -2.136f, 0.122397f,

0.300401f, 0.737608f, 1.01523f,

1.28449f, 0.0721975f, 0.0993714f,

-0.187194f, -0.679765f, -0.935616f,

-1.17128f, -0.0143543f, -0.0197569f,

0.300401f, 0.737608f, 1.01523f,

-0.187194f, -0.679765f, -0.935616f

Attached Thumbnails

  • Screen shot 2011-12-13 at 2.00.21 AM.png


#5 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 12 December 2011 - 06:32 PM

On the 3DS side you did not unpack the vertices. You have a pool of non-duplicate vertices.
You have not run over the faces of the object and have not duplicated the vertices according to the vertex indices on the faces.

Additionally, it is extremely unwise to import .3ds files. You should instead be making your own file format, or in the very least importing from COLLADA or FBX.

Importing directly from .3ds means you are asking users to store overly large model files on a small iOS device with limited storage capacity. After you breach 20 megabytes your app can no longer be downloaded without having an actual Macintosh computer.

COLLADA and FBX reduce some of the data stored but still contain a lot of data you don’t need. The reason for using them, however, is that all 3D software can create these files.
Meaning that importing from .3ds requires users to use one specific software package instead of allowing them to use their choice.


Ultimately, the only wise path to follow is to make COLLADA or FBX files and then extract only the data you need from them and put them into your own file format.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#6 babarorhum   Members   -  Reputation: 100

Like
0Likes
Like

Posted 13 December 2011 - 02:08 PM

Hello,
Thank you for your reply and the very valuable advises.

The plan plan has been to read from the .OBJ file instead of .3DS file. Do you see any practical challenge in using such file format compare to the Collada or FBX format ? (except one is about parsing strings and xml).

Thank you also for noting the 20Meg hard limit; i was unaware of such restriction but must confess i do not fully comprehend it: games such as Infinity Blade are rather heavy on the storage capacity; however they do not seem to need a computer to be downloaded. Has it been always the case or has it changed very recently ? Is there any specific conditions for such behaviour ? (e.g. country specific limitation, iphone using mobile network (i.e. excl phone connecting to WIFI, a specific operator; only on iphones not ipad etc...)

As for your advice for the dupplication of vertices; i understand the principles behind the operation however my knowledge is fairly limited in the 3DS tool domain such as Lightware or 3DS; so i cannot match it with the right terminology and features in the modellers. Do you have a specific and common term which would help me to find the function to use in 3DS? For example, i have been looking into the optimization , merge options but have been unsuccesful so far.

Cheers,
Babarorum




On the 3DS side you did not unpack the vertices. You have a pool of non-duplicate vertices.
You have not run over the faces of the object and have not duplicated the vertices according to the vertex indices on the faces.

Additionally, it is extremely unwise to import .3ds files. You should instead be making your own file format, or in the very least importing from COLLADA or FBX.

Importing directly from .3ds means you are asking users to store overly large model files on a small iOS device with limited storage capacity. After you breach 20 megabytes your app can no longer be downloaded without having an actual Macintosh computer.

COLLADA and FBX reduce some of the data stored but still contain a lot of data you don’t need. The reason for using them, however, is that all 3D software can create these files.
Meaning that importing from .3ds requires users to use one specific software package instead of allowing them to use their choice.


Ultimately, the only wise path to follow is to make COLLADA or FBX files and then extract only the data you need from them and put them into your own file format.


L. Spiro



#7 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 13 December 2011 - 06:55 PM

20 megabytes is the limit for cell download. For WiFi there is no limit.
But you should aim for the cell downloads when possible; I have been on dates and asked my partner to check out a game I made only to have been disappointed that it was over 20 megabytes and receive instead, “I’ll check it out when I get home”.


Duplicating vertices.
Traverse the list of faces on each object.
For each face you will get a triangle fan. In your case 4 points for each face, which resolves to 2 triangles.

Converting a fan to triangles means taking the first point with each other 2 points increasingly.
Since that is obviously difficult to explain in words, here is code:

for ( unsigned int i = 2; i < totalFacePoints; ++i ) {
	unsigned int index0 = 0;		// Use point 0 for ALL triangles.
	unsigned int index1 = i - 1;	
	unsigned int index2 = i;
}

The faces will have index data that allows you to look up vertices, normals, etc., inside the pools of vertices and normals, etc.
What you have posted is a vertex pool. It is nothing more than an array of unique vertices. There are 8 unique vertices (8 corners on the cube).
As you know, many faces share the same vertices. When you duplicate the vertices correctly you will have 36 of them.


There is no special terminology.


As for using OBJ files, I find them fairly unwieldy. They contain data that is not typical of games and need to be converted to something usable for games. COLLADA and FBX are more suited for games.


L. Spiro

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#8 jonbonazza   Members   -  Reputation: 121

Like
0Likes
Like

Posted 14 December 2011 - 04:47 PM

Not to mention OBJ files cannot be animated as the file format does not support skeletal or keyframe animations.
Co-founder/Lead Programmer
Bonafide Software, L.L.C.
Fairmont, WV 26554 US

#9 babarorhum   Members   -  Reputation: 100

Like
0Likes
Like

Posted 07 January 2012 - 06:55 PM

With a bit of delay, thanks both of you. It helped a lot !

:)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS