PDA

View Full Version : how to read a .x file using opengl



Rubbish Kid
05-30-2004, 03:05 AM
I have some models which are in .x file.
I want to load them using opengl.
Does anyone know how to do it?
thanks

ZbuffeR
05-30-2004, 03:13 AM
You don't load using OpenGL. You draw using OpenGL. For loading, parse the file (if I remember correctly, it is ascii), and store into ram, then draw using GL.

Edit : google is your friend, here is the file format :
http://www.google.com/search?num=100&hl=...ctx&btnG=Search (http://www.google.com/search?num=100&hl=en&lr=&ie=UTF-8&safe=off&q=%22.x%22+file+format+directx&btnG=Search)

Rubbish Kid
05-30-2004, 03:16 AM
then how to draw them?
I used a text editor to open the .x files,
see some points' coord,
and I think it must have some format.
then how to draw it in opengl
thanks

Jared
05-30-2004, 03:41 AM
you draw them the same way like you draw any other collection of triangles. if youre looking for a magic "glDrawXFile" function youre out of luck. same goes for "glDraw3dsFile" and "glDrawObjFile". stuffing the geometry into arrays or buffers is your job, not opengls. an no, opengl doesnt automatically play any keyframed animations or does skinning all by itself. if thats what youre looking for then you need a 3d engine.

Rubbish Kid
05-30-2004, 04:33 AM
thanks.
Then I think I have to write such a function
glDrawXFile().
Is there any code implementing such function?
I have search for some thing like this, and find an article about this topic, but I can't open that page!! :eek:
Does any one so generous to give me any help:>

ZbuffeR
05-30-2004, 11:54 PM
Originally posted by Rubbish Kid:
I have search for some thing like this, and find an article about this topic, but I can't open that page!! :eek: Isn't it hard to live in China sometimes ?
Try www.wotsit.org (http://www.wotsit.org) for file formats :
http://www.wotsit.org/download.asp?f=x
Or directly from Microsoft :
http://msdn.microsoft.com/archive/defaul.../FileFormat.asp (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_c/directx_cpp/Graphics/Reference/FileFormat/FileFormat.asp)

Rubbish Kid
05-31-2004, 07:45 AM
Thank you so much