PDA

View Full Version : import .x file



appdeveloper
10-15-2009, 06:43 AM
Is it possible to import a 3d studio max file, probably exported as .x (like in some game engines) to be rendered in OpenGL? How?

My thanks in advanced

Jan
10-15-2009, 07:00 AM
Of course!

By writing an importer.

appdeveloper
10-15-2009, 07:15 AM
Can you give me any reference or link so that i can read as an example?

Jan
10-15-2009, 07:45 AM
Sure.

Having coded an x-importer, i found this page most informative:
http://msdn.microsoft.com/en-us/library/ee418099%28VS.85%29.aspx

First of all, google for the "x file format". There are several articles that explain how the file format works in general.

When you then want to know the details, to implement it, that msdn-page will be very valuable.

The format is actually quite straight-forward to understand, but implementing an importer is a bit of work.

Jan.

DWilson
10-15-2009, 08:59 AM
This article should help Loading and displaying .X files without DirectX (http://www.gamedev.net/reference/programming/features/xfilepc/).. Its a bit old, but it still renders X files in OpenGL. It basically goes into the file format in more detail, and example code to load a model.

appdeveloper
10-16-2009, 04:21 AM
Thanks for all your answers.
I see this is not an easy task. Is there any other way, maybe a most common way to add 3d Studio Max or Maya objects, to OpenGL and control them?

Jan
10-16-2009, 05:45 AM
Nope. OpenGL does not provide any built-in mechanisms. It allows you to render stuff. Where you get the data from, and how that is stored etc. is not a concern of OpenGL. So no matter what format you are trying to use, be it for models, textures, animations, whatever, you always need to write your own importers (or use other peoples importers, if there are any).

Part of the reason is, that there is no "standard" way to render your stuff. Someone might use VBOs, someone else uses display lists, the layout of the data can change, depending on your needs etc., so having ONE importer is usually not possible, because everyone has different needs how to render things.

Jan.

DarkShadow44
10-17-2009, 02:54 PM
You could also write your own exporter (3d modeller) and importer (openGL)...

I've my own exporter for blender (with python), that exports ertices,UVs and animations...

I think thats the "easiest" ^^

Alfonse Reinheart
10-17-2009, 03:25 PM
I think thats the "easiest"

Technically, what would be "easiest" is if Blender had a decent exporter to Collada, which has a specific and well-documented format. Then you can write an offline tool to convert this into whatever format you want.