Skip to main content
GameDev.net gamedev.net
🔒 Locked

environment/scene - file format

Started by erik rostock Feb 24, 2008 at 2:35 PM 2 replies 600+ views
Original Post
erik rostock
erik rostock
Hi, we're currently programming an application that renders a scene à la Counterstrike/Quake ... whatever it's an indoor scene. (Actually, we're not programming a game ;) ...) We would like that we can load scenes, (or rather 'levels'). Our first attempt to loading scenes was to load a *.x File. There are two problems concerning this: First, we are not sure wether it could become a problem if there are big scenes with many polygons sotred in a .x file. Second, we would like to implement collision detection, thus it would be great if we could get the coordinates of the objects. Can we get them out of the *.x File? If it's not possible, which other file formats are made for our aims? Something like *.bsp or *.vmf, or should we implement our own file format? Thank you for your answers ;) Erik
BLiTZWiNG
BLiTZWiNG
I'm not aware of any limitation for .x files, they're just a data format like any other mesh file. Typically you would place individual objects in seperate .x files though for easier scene manipulation and draw efficiency, rather than every object in the scene in the one file. The only limitation will be your computer, not the file format.

As for coords of the object, yes you have access to that information. If you didn't you wouldn't be able to draw the object! Typically though, the object is designed in local space (around x,y,z=0,0,0) and then you use DirectX to move the object in your world by translating and rotating, that way you know exactly where in the world it is. Collision detection then just cycles through the vertices and adds the current world transformation to get the actual position, but of course that is a slow process, so you would always do a sphere test followed by a box test before comparing against vertices.

.x is as good a format as any, but there may be better formats depending on what other data you want to include in the mesh. I don't think there is going to be any more development of the .x format, but that doesn't make it unusable. With other formats you will need to find code to parse the file format and include that too.

HTH.
erik rostock
erik rostock
So, are there any DirectX functions with which I may get the coordinates? We haven't given collision detection a thought at all, but I think I will need them ...
Captain P
Captain P
This depends entirely on what you're going to use this for. The .bsp format, amongst others, contains some additional information that the engine uses to optimize rendering. The .x format, like many model file formats, does not. However, a format isn't automatically going to improve rendering: your rendering system still needs to use such information. Whether that's stored in a level file or generated while loading doesn't matter (it affects loading time, sure, but not performance afterwards). Either way, I'd run some stress tests if I were you. See if the system can handle enough. If it can't, you'll need to resort to some optimization techniques.

As for retreiving data from a .x file, why do you think you can't access this data? You're loading it, you are in control of the process... However, collision detection and handling can be quite difficult subjects. Most games use spatial division techniques and simplified collision geometry to get acceptable performance (besides that, it's also annoying when every shrub or leaf blocks movement). Even then, building a reliable collision system takes some thought and hard work. Have you considered using an existing game or rendering engine instead?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.