Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / Need to understand mesh data format of .x text files

Author
Message
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 19th May 2005 16:24 Edited at: 20th May 2005 15:00
Hello all,

I have studied a few texts on the internet about the .x text file and its layout. As to say, opening a .x file in a text editor and studying its format. The only part I need to understand within its format, is mesh { information.

For study purposes, I have exported a simple plain, extruded on one axis, as to make it include six vertices. However, though the extruded version of the plain contains, technically six vertices, the .x text file states it to still only include 4 vertices.



I do not quite understand the reason for this.


+NanoBrain+
Ianhfar
20
Years of Service
User Offline
Joined: 8th Jul 2004
Location: UK
Posted: 23rd May 2005 18:49
Nanobrain

try this site

http://astronomy.swin.edu.au/~pbourke/geomformats/directx/

Mesh Mesh_Plane {
4; // 4 vertices
1.0; 0.999999940395; 0.0;, // x,y,z
-0.999999642372; 1.00000035763; 0.0;,// x,y,z
-1.00000011921; -0.999999821186; 0.0;,// x,y,z
1.0; -1.0; 0.0;; // x,y,z
1; // 1 face
4; 0; 1; 2; 3;; face 0 has 4 vertices as expected for a plane


Hope this helps

Ianhfar
deckard
21
Years of Service
User Offline
Joined: 11th Apr 2003
Location:
Posted: 2nd Jun 2005 17:08
It is possible to write comments in text x files using #

# comment

So many digits after decimal dot are just error when converting
floating-point value to text. As usual, you can simply write
1.0 , not 1.00000035763 Or you can write a program for conversion.
This "digits removing" makes .x files much smaller without any
data loss.

If you miss one { or } most of programs (including DarkBasic)
crashes trying to load this file.

As far as I know, DarkBasic ignores "template strings" from .x
file. You can delete them.

Sometimes you can also delete all data about normals, because
DarkBasic recalculates normals by default.
(Try to check difference).

As seen from the NanoBrain's example, there is a polygon with 4 dots.
Some programs can read .x files only with triangles (3 dots per
polygon). But DarkBasic (at least Classic) can read .x files
with 4-dots polygons.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 2nd Jun 2005 22:46
I didn't comment ALL of the text, but I hope from the comments over the pure mesh you will get the idea of how it's structured and be able to make your own.



NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 2nd Jun 2005 22:54
To all,

Thank you guys for your help. Still a bit confused, but will continue racking my brain. Raven, I will be focused on what you have typed, and commented. It should make me to understand after sometime of putting the pieces together.


+NanoBrain+
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 3rd Jun 2005 01:20 Edited at: 3rd Jun 2005 01:21
well all of that is required to meet the DB/P standard load..

Vertex . Normal . UV

There is quite a bit more I could've added.
The last template is a very cool one, because it combined multiple Vertex Indicies when loading.

So if you have 2 identical Indicies it'll only act as one.

In DB/P what would happen would be that it'd export the code, but you'd have 6 Vertex Points for 2 Triangle Faces. Given DB/P only renders Triangles, there is no point in worrying about Quad or above.

So the final type will basically load DB/P's 6 Vertex Points like mine is, with only 4 Vertex Indexes.

It seems a little complex, but it actually makes sense.

In DirectX everything is Indexed from base values. These are then accessed via Look-up tables/arrays.
If say you were to recreate this using DB/P and the Mesh Memblock it would come out like this (exclusing the Header mind you)



In a more familiar coding it should become far more obvious what's going on.

It looks long and complimacated, but trust me it's pretty easy to follow ^_^

NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 3rd Jun 2005 10:07 Edited at: 3rd Jun 2005 10:10
Raven,

I'm not a user of DarkBasic Pro, unfortunately. However, I do have a good amount of programming knowledge in DarkBasic Classic and Visual Basic 6.0, enough to tie this together in my head, eventually. I've read over your last code snippet a few times, and I am coming to a more clear understanding of the .x format. Though, this will take time on my part, due to the "complexity" of this subject in my eyes.

On a last note, words won't say how much I thank you for spending your precious time in helping me to come to a more clear understaning. Your teachings will profit me greatly, and it is much appreciated!


+NanoBrain+
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 3rd Jun 2005 10:16
heh, well provided atleast a few users around here don't think i'm as much of an idiot as the press makes me out to be ^_^
what more cause i ask for?

just hope it helps for whatever you needed it for really.

NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 5th Jun 2005 12:19
Raven,

I have DarkBasic Classic, the unenhanced version. So, I cannot use any DLLs. Therefore, instead, I wish to create a program to extract vertice and normals information, enabling me to create collision detection for .x models, within DBC. My other option is to manually record the information myself, by referencing the model in the modeller. However, this method is unreal and exhausting, and would take too much of my time.


+NanoBrain+
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Jun 2005 12:29
You might find as far as DarkBASIC goes, that doing what your hoping to might end up cause extremely level loading times. Unless you export the 'Collision Mesh' out as an object to load later.

Generally speaking I used to find even trying to cope with the Enhancements was a pain to get some things like collision working at a reasonable speed.

Personally I'd suggest getting the Enhancements so you can use the Newton DLL, as it will solve so many headaches.

Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 9th Jun 2005 03:31
I think the newton dll is dbpro only

The happenings of tommorow are behind us now
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 11th Jun 2005 14:55
Raven,

I do agree with you Raven, and am simply using this method as an appetizer until I gain the money to get the enhancement. Yes, the enhancement patch is cheap, however, not in the midst of a marriage in less than a week. Thank you for your advice.


+NanoBrain+
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 12th Jun 2005 10:36
Two triangles with six verts. They make a plane and share two verts. The exporter optimizes the export by not writing the duplicate verts. I don't see any problem with that.
--
TAZ

"Do you think it is wise to provoke him?" "It's what I do." -- Stargate SG-1

Login to post a reply

Server time is: 2024-11-27 18:33:29
Your offset time is: 2024-11-27 18:33:29