Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [3D] Importing .ASE objects inside OpenGL

This thread is locked; no one can reply to it. rss feed Print
[3D] Importing .ASE objects inside OpenGL
LordHolNapul
Member #3,619
June 2003
avatar

Hi,
I'm trying what I should have tried before :)
I'm starting with Nehe OpenGL lesson and I've an old version of a 3D program :
"3D studio 3.1"

With this program there is the possibility to EXPORT projects and geometry in various formats, such as ".ase" files.
They are represented as below...
(this is a simple Box! A kind of CUBE i mean...)

1*3DSMAX_ASCIIEXPORT 200
2*COMMENT "AsciiExport Version 2,00 - Thu Nov 09 21:44:14 2006"
3*SCENE {
4 *SCENE_FILENAME "Scenes01.max"
5 *SCENE_FIRSTFRAME 0
6 *SCENE_LASTFRAME 100
7 *SCENE_FRAMESPEED 30
8 *SCENE_TICKSPERFRAME 160
9 *SCENE_BACKGROUND_STATIC 0.00 0.00 0.00
10 *SCENE_AMBIENT_STATIC 0.04 0.04 0.04
11}
12*GEOMOBJECT {
13 *NODE_NAME "Box01"
14 *NODE_TM {
15 *NODE_NAME "Box01"
16 *INHERIT_POS 0 0 0
17 *INHERIT_ROT 0 0 0
18 *INHERIT_SCL 0 0 0
19 *TM_ROW0 1.00 0.00 0.00
20 *TM_ROW1 0.00 1.00 0.00
21 *TM_ROW2 0.00 0.00 1.00
22 *TM_ROW3 24.50 6.69 -50.10
23 *TM_POS 24.50 6.69 -50.10
24 *TM_ROTAXIS 0.00 0.00 0.00
25 *TM_ROTANGLE 0.00
26 *TM_SCALE 1.00 1.00 1.00
27 *TM_SCALEAXIS 0.00 0.00 0.00
28 *TM_SCALEAXISANG 0.00
29 }
30 *MESH {
31 *TIMEVALUE 0
32 *MESH_NUMVERTEX 8
33 *MESH_NUMFACES 12
34 *MESH_VERTEX_LIST {
35 *MESH_VERTEX 0 -25.50 -43.31 -50.10
36 *MESH_VERTEX 1 74.50 -43.31 -50.10
37 *MESH_VERTEX 2 -25.50 56.69 -50.10
38 *MESH_VERTEX 3 74.50 56.69 -50.10
39 *MESH_VERTEX 4 -25.50 -43.31 49.90
40 *MESH_VERTEX 5 74.50 -43.31 49.90
41 *MESH_VERTEX 6 -25.50 56.69 49.90
42 *MESH_VERTEX 7 74.50 56.69 49.90
43 }
44 *MESH_FACE_LIST {
45 *MESH_FACE 0: A: 0 B: 2 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
46 *MESH_FACE 1: A: 3 B: 1 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 2 *MESH_MTLID 1
47 *MESH_FACE 2: A: 4 B: 5 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
48 *MESH_FACE 3: A: 7 B: 6 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 3 *MESH_MTLID 0
49 *MESH_FACE 4: A: 0 B: 1 C: 5 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
50 *MESH_FACE 5: A: 5 B: 4 C: 0 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 4 *MESH_MTLID 4
51 *MESH_FACE 6: A: 1 B: 3 C: 7 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
52 *MESH_FACE 7: A: 7 B: 5 C: 1 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 5 *MESH_MTLID 3
53 *MESH_FACE 8: A: 3 B: 2 C: 6 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
54 *MESH_FACE 9: A: 6 B: 7 C: 3 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 6 *MESH_MTLID 5
55 *MESH_FACE 10: A: 2 B: 0 C: 4 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
56 *MESH_FACE 11: A: 4 B: 6 C: 2 AB: 1 BC: 1 CA: 0 *MESH_SMOOTHING 7 *MESH_MTLID 2
57 }
58 *MESH_NUMTVERTEX 8
59 *MESH_TVERTLIST {
60 *MESH_TVERT 0 0.00 0.00 0.00
61 *MESH_TVERT 1 1.00 0.00 0.00
62 *MESH_TVERT 2 0.00 1.00 0.00
63 *MESH_TVERT 3 1.00 1.00 0.00
64 *MESH_TVERT 4 0.00 0.00 1.00
65 *MESH_TVERT 5 1.00 0.00 1.00
66 *MESH_TVERT 6 0.00 1.00 1.00
67 *MESH_TVERT 7 1.00 1.00 1.00
68 }
69 *MESH_NUMTVFACES 12
70 *MESH_TFACELIST {
71 *MESH_TFACE 0 0 2 3
72 *MESH_TFACE 1 3 1 0
73 *MESH_TFACE 2 4 5 7
74 *MESH_TFACE 3 7 6 4
75 *MESH_TFACE 4 0 1 5
76 *MESH_TFACE 5 5 4 0
77 *MESH_TFACE 6 1 3 7
78 *MESH_TFACE 7 7 5 1
79 *MESH_TFACE 8 3 2 6
80 *MESH_TFACE 9 6 7 3
81 *MESH_TFACE 10 2 0 4
82 *MESH_TFACE 11 4 6 2
83 }
84 *MESH_NUMCVERTEX 0
85 *MESH_NORMALS {
86 *MESH_FACENORMAL 0 0.00 0.00 -1.00
87 *MESH_VERTEXNORMAL 0 0.00 0.00 -1.00
88 *MESH_VERTEXNORMAL 2 0.00 0.00 -1.00
89 *MESH_VERTEXNORMAL 3 0.00 0.00 -1.00
90 *MESH_FACENORMAL 1 0.00 0.00 -1.00
91 *MESH_VERTEXNORMAL 3 0.00 0.00 -1.00
92 *MESH_VERTEXNORMAL 1 0.00 0.00 -1.00
93 *MESH_VERTEXNORMAL 0 0.00 0.00 -1.00
94 *MESH_FACENORMAL 2 0.00 0.00 1.00
95 *MESH_VERTEXNORMAL 4 0.00 0.00 1.00
96 *MESH_VERTEXNORMAL 5 0.00 0.00 1.00
97 *MESH_VERTEXNORMAL 7 0.00 0.00 1.00
98 *MESH_FACENORMAL 3 0.00 0.00 1.00
99 *MESH_VERTEXNORMAL 7 0.00 0.00 1.00
100 *MESH_VERTEXNORMAL 6 0.00 0.00 1.00
101 *MESH_VERTEXNORMAL 4 0.00 0.00 1.00
102 *MESH_FACENORMAL 4 0.00 -1.00 0.00
103 *MESH_VERTEXNORMAL 0 0.00 -1.00 0.00
104 *MESH_VERTEXNORMAL 1 0.00 -1.00 0.00
105 *MESH_VERTEXNORMAL 5 0.00 -1.00 0.00
106 *MESH_FACENORMAL 5 0.00 -1.00 0.00
107 *MESH_VERTEXNORMAL 5 0.00 -1.00 0.00
108 *MESH_VERTEXNORMAL 4 0.00 -1.00 0.00
109 *MESH_VERTEXNORMAL 0 0.00 -1.00 0.00
110 *MESH_FACENORMAL 6 1.00 0.00 0.00
111 *MESH_VERTEXNORMAL 1 1.00 0.00 0.00
112 *MESH_VERTEXNORMAL 3 1.00 0.00 0.00
113 *MESH_VERTEXNORMAL 7 1.00 0.00 0.00
114 *MESH_FACENORMAL 7 1.00 0.00 0.00
115 *MESH_VERTEXNORMAL 7 1.00 0.00 0.00
116 *MESH_VERTEXNORMAL 5 1.00 0.00 0.00
117 *MESH_VERTEXNORMAL 1 1.00 0.00 0.00
118 *MESH_FACENORMAL 8 0.00 1.00 0.00
119 *MESH_VERTEXNORMAL 3 0.00 1.00 0.00
120 *MESH_VERTEXNORMAL 2 0.00 1.00 0.00
121 *MESH_VERTEXNORMAL 6 0.00 1.00 0.00
122 *MESH_FACENORMAL 9 0.00 1.00 0.00
123 *MESH_VERTEXNORMAL 6 0.00 1.00 0.00
124 *MESH_VERTEXNORMAL 7 0.00 1.00 0.00
125 *MESH_VERTEXNORMAL 3 0.00 1.00 0.00
126 *MESH_FACENORMAL 10 -1.00 0.00 0.00
127 *MESH_VERTEXNORMAL 2 -1.00 0.00 0.00
128 *MESH_VERTEXNORMAL 0 -1.00 0.00 0.00
129 *MESH_VERTEXNORMAL 4 -1.00 0.00 0.00
130 *MESH_FACENORMAL 11 -1.00 0.00 0.00
131 *MESH_VERTEXNORMAL 4 -1.00 0.00 0.00
132 *MESH_VERTEXNORMAL 6 -1.00 0.00 0.00
133 *MESH_VERTEXNORMAL 2 -1.00 0.00 0.00
134 }
135 }
136 *PROP_MOTIONBLUR 0
137 *PROP_CASTSHADOW 1
138 *PROP_RECVSHADOW 1
139}

How can I move this information inside my 3D space created in a OpenGL application?
If you don't know, what's your best 3D editor and how do you import objects in your Space ?

lot of thanks to everyone.
ciao.8-)

Steve Terry
Member #1,989
March 2002
avatar

You need to write a parser to go through the .ase file and build the vertex list, which is used to make the faces of the cube, and it looks like the file already has computed normals for the face vertex for proper lighting. Learn some OpenGL first, then see how it's all put together in a 3D file format. If you want an easier format use .obj, get that going then you can play with .ase files. They look a bit more complicated but not impossible.

The format is pretty much similar to .3ds only in ASCII format. Think about it, to make a cube you need 8 points, and 12 faces (this is due to the fact that the faces aren't square but triangles).

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

LordHolNapul
Member #3,619
June 2003
avatar

I thank you for the Suggest.
I think that I will continue my Opengl readings waiting the right time to understand.

I've tried to write a parser utility, but the coordinates inside the previous file are not in the right order to generate my cube using Openg Gl vertex... and I cannot understand the faces criteria declared into the file yet.

How could be used... ? boh.

And What do you prefer to use if I can to know ?

ciao

SiegeLord
Member #7,827
October 2006
avatar

Quote:

what's your best 3D editor and how do you import objects in your Space ?

I personally like to use Lightwave files, since they separate the scenes and meshes into two separate files, unlike many other programs. Since I only want to load the mesh, I see no point fiddling through random scene information during parsing.

LW file was constructed out of chunks (RIFF, afaik), which I personally find easier to parse than other file types.

I would suggest parsing the binary form of the file however, it always takes less space, and it is somewhat faster.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

LordHolNapul
Member #3,619
June 2003
avatar

ok, I will proceed to 3DS file parsing then.
Lot of thanks.. I suppose to have seen some good tutorials angain in Nehe.

Ciao

Steve Terry
Member #1,989
March 2002
avatar

3ds may not be the best format to attempt, it's in binary not ASCII and it's not very open to the file format internals. I wrote my own 3ds renderer but it's not complete since it was a bit confusing what some things meant.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

LordHolNapul
Member #3,619
June 2003
avatar

Thank you Steve.
In Some way I must find a path to follow... in the meanwhile I've found this site that could be usefull to us:

http://www.wotsit.org/search.asp?s=3d

Ah, if you dare, review my game here on Allegro. The link is below. 8-)

ciao from Italy

Go to: