|
Post by Darkjester on Nov 19, 2008 17:07:25 GMT -5
Hello, I have found very usefull information regarding the Wavefront (.obj) format, Here it is ;D
The format is realy simple. it goes like this:
a vertex is a line that starts with the letter v followed by 3 floating point numbers. i.e v 3.01213 -1.2345 1.000
a vertex normal starts with vn followed by 3 floatig point numbers vn 1.000 2.345 3.1415
a texture coordinat starts with vt followed by 2 numbers vt 0.123 0.567
a triangle looks like this
f 1/1/1 10/3/5 15/4/6
meaning that - the 1st point of the triangle uses the first vertex, the first normal and the first texture coordinate in the file - the 2nd point uses the 10th vertex, 3rd normal and 5th texture coordinate - the 3rd point uses the 15th vertex, 4th normal and 6th texture coordinate
you can ignore the rest of the lines (if any).
(there is a bit more but this will do for a start.)
now you have to do 2 passes on the file. in the first pass you count the number of vertex, normals texture coordinates, then you allocate memory to hold the date and in the second pass you you read in the data.
|
|
|
Post by Wayne Rayner on Nov 19, 2008 19:52:05 GMT -5
I don't understand wat is u just posted darkjester u should explain in detail like a tutorial wayne
|
|
|
Post by cheglasgow on Nov 20, 2008 7:05:04 GMT -5
Hi darkjester, This might seem like a random first post (hello world, I suppose!), but I found this pretty useful as i've been using similar files for a while now (I use basic4gl to visualise my own 3d/4d terrain models). A similar file-type is used by an app. called ElmerPost (also plain text, so pretty accessible) which could be worth a look if, like me, you need to animate the data you're importing.
|
|
|
Post by smc44 on Nov 20, 2008 7:08:32 GMT -5
hi i welcome to the forums, i am a 3 modeler i usually make test model for darkjester(i use 3ds max)
|
|
|
Post by Wayne Rayner on Nov 20, 2008 7:11:24 GMT -5
How much does 3ds max cost smc44
|
|
|
Post by smc44 on Nov 20, 2008 7:14:02 GMT -5
well i didnt quite pay for it youll have to talk to me in private about it lol
|
|
|
Post by Wayne Rayner on Nov 20, 2008 7:16:24 GMT -5
oh yea good morning east side americans especially smc44 wayne
|
|
|
Post by Darkjester on Nov 20, 2008 16:01:51 GMT -5
Lol wrayn3 Could you Explain more about Elmorpost for me cheglasgow?
|
|
|
Post by cheglasgow on Nov 23, 2008 11:02:07 GMT -5
Could you Explain more about Elmorpost for me cheglasgow? hi darkjester, sorry about the delay - i don't often get online. elmerpost is a multiphysics visualiser by csc. it's a bit niche but has the most useful plain-text file-format i've been able to find and it really suits my work - i'm a flood inundation modeller, so need to visualise a real-world terrain with scalar and vector variables that change over time at each node/vertex (flood-depth, water surface, vx, vy, vz, ax, ..., etc). it's a little bit tricky to find but www.csc.fi/english/pages/elmer is a pretty good place to start if you want to take a look for yourself. it's part of the larger elmer modelling package (for heat/cfd and the like), but i only use the post-processing part and its file format (which basically seems to be the wavefront .obj format described here with a bunch of node-variables that follow in the datastream). sadly, elmerpost plots only the node/vertex data in full 3d and then creates a colour-scale for the variables. this was the main reason i started to look at basic4gl - to produce full-3d visualisations from my data. but nevertheless, i've found it to be a pretty quick way to visualise multi-dimensional datasets. cheglasgow p.s. i found my way to this forum from a google search while i was looking at whether i could use blender to produce some fancy output from my data - i thought the .obj file format most promising, but couldn't find a quick enough way to animate the data i'd imported. does anyone know of any other multi-dimensional plain-text file formats i might look at (i've recently been exploring the .bvh format, but don't fancy the job of figuring out how to describe 'elastic' bones)?
|
|
|
Post by Wayne Rayner on Nov 24, 2008 18:27:46 GMT -5
Ok i went to the site u posted a link to cheglasgow but i probably won't get the Elmerpost Multiphysics Visualiser idea lol So Yea and I belive u are very helpful just probably not to me as i'm seriously slow at learning things i don't get. Wayne
|
|
|
Post by Darkjester on Nov 27, 2008 1:54:20 GMT -5
Its a complex format Heres what a "Standard" .obj File looks like v 0.00000000 0.00000000 0.00000000 v 0.00000000 0.00000000 3.00000000 v 0.00000000 3.00000000 0.00000000 v 0.00000000 3.00000000 3.00000000 v 3.00000000 0.00000000 0.00000000 v 3.00000000 0.00000000 3.00000000 v 3.00000000 3.00000000 0.00000000 v 3.00000000 3.00000000 3.00000000
vt 0.02000000 0.35000002 vt 0.24499999 0.35000002 vt 0.24499999 0.65000004 vt 0.02000000 0.65000004 vt 0.26499999 0.97500002 vt 0.26499999 0.67500001 vt 0.48999998 0.67500001 vt 0.48999998 0.97500002 vt 0.48999998 0.02500000 vt 0.48999998 0.32500002 vt 0.26499999 0.32500002 vt 0.26499999 0.02500000 vt 0.73500001 0.35000002 vt 0.73500001 0.65000004 vt 0.50999999 0.65000004 vt 0.50999999 0.35000002 vt 0.26499999 0.35000002 vt 0.48999998 0.35000002 vt 0.48999998 0.65000004 vt 0.26499999 0.65000004 vt 0.98000002 0.35000002 vt 0.98000002 0.65000004 vt 0.75500000 0.65000004 vt 0.75500000 0.35000002
vn 1.00000000 0.00000000 0.00000000 vn 1.00000000 0.00000000 0.00000000 vn 1.00000000 0.00000000 0.00000000 vn 1.00000000 0.00000000 0.00000000 vn 0.00000000 -1.00000000 0.00000000 vn 0.00000000 -1.00000000 0.00000000 vn 0.00000000 -1.00000000 0.00000000 vn 0.00000000 -1.00000000 0.00000000 vn 0.00000000 1.00000000 0.00000000 vn 0.00000000 1.00000000 0.00000000 vn 0.00000000 1.00000000 0.00000000 vn 0.00000000 1.00000000 0.00000000 vn -1.00000000 0.00000000 0.00000000 vn -1.00000000 0.00000000 0.00000000 vn -1.00000000 0.00000000 0.00000000 vn -1.00000000 0.00000000 0.00000000 vn 0.00000000 0.00000000 -1.00000000 vn 0.00000000 0.00000000 -1.00000000 vn 0.00000000 0.00000000 -1.00000000 vn 0.00000000 0.00000000 -1.00000000 vn 0.00000000 0.00000000 1.00000000 vn 0.00000000 0.00000000 1.00000000 vn 0.00000000 0.00000000 1.00000000 vn 0.00000000 0.00000000 1.00000000
f 1/1/1 2/2/2 4/3/3 3/4/4 f 3/5/5 4/6/6 8/7/7 7/8/8 f 5/9/9 6/10/10 2/11/11 1/12/12 f 5/13/13 7/14/14 8/15/15 6/16/16 f 2/17/17 6/18/18 8/19/19 4/20/20 f 1/21/21 3/22/22 7/23/23 5/24/24
I have heard that their are several types of .obj files, this is a wrong accusation, since they look different only because they are missing data hence if you look at the face data f 1/21/21 3/22/22 7/23/23 5/24/24 'this has all 3 elements required for vertex, normal, and textcoord data
but if it looks like f 1//21 3//22 7//23 5//24 'Then it is lacking texturecoords which should be between //
and if it looks like f 1/21 3/22 7/23 5/24 'Normals arent assigned to the vertices (they are per vertex normals)
Lastly if it looks like f 1 3 7 5 'it is merely just vertex data
And as a final note, if you want the fastest and easiest method of loading an .obj file, triangulate it so that when you go to draw it it simplifies your model drawing code. Edit: The parts of the format->> V = Vertex data VT = Texturecoordinates VN = Vertex Normals F = Face Structure Hope this uncovers the mystery behind the format -Darkjester
|
|
|
Post by Empyrion Martyr on Nov 27, 2008 12:30:25 GMT -5
I suggest you study carefully www.martinreddy.net/gfx/3d/OBJ.specThose are the official specs of the format. Any other specs are not considered proper. the 3d Wavefront format is more than merely those things you have written there, but for starters it's fine. There are groups, and curved surfaces as well. There are material files and stuff. A complete format reader knows how to read all of the above, and all combinations of v/vn/vt, calcualte normals where ther aren't any, and convert quad faces into triangle faces. However, this could prove interesting for tutorial purposes.
|
|
|
Post by Darkjester on Nov 27, 2008 13:26:49 GMT -5
Im aware of those features Since this is bas4gl, i dont think they are neeeded -Darkjester
|
|
zack8686
Posts a bit
gl-Home in wikispace
Posts: 207
|
Post by zack8686 on Dec 31, 2008 9:31:46 GMT -5
Is there any 3d modeler that can save 3d object as .obj that is compatible with basic4gl
|
|
|
Post by Darkjester on Dec 31, 2008 11:54:58 GMT -5
Of course, you just have to write the model loader, mine is still incomplete because i was waiting on a bug fix, Blender3d exports a .obj very nicely
|
|