EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Tools (https://www.eqemulator.org/forums/forumdisplay.php?f=623)
-   -   S3D format question (https://www.eqemulator.org/forums/showthread.php?t=15914)

jbb 09-18-2004 03:51 AM

S3D format question
 
This seems as good a place as any to ask this :

I've been trying to understand the S3D format and can sucessfully decompress all the records in one now.

I can get the record containing the "filenames" but they don't seem to be in any particular order I can find. The first filename doesn't seem to match the first directory entry...

How can I tie up the filenames with the directory entries?

daeken_bb 09-18-2004 04:38 AM

Sort the directory entries by their CRC in ascending order :)

jbb 09-18-2004 04:45 AM

Ah thanks, that works :)
What a strange file format.

I've now downloaded your viewing program instead of looking for random web pages with the information although i can't build it as I only have windows handy. Hmm, I think there is enough in there for me to decode the WLD files too at least enough to build a list of untextured triangles I can draw.

daeken_bb 09-18-2004 04:47 AM

Well, we hope to move fully away from wld soon. We're planning to convert all wld files to their new-style equivelents for efficiency and cleanliness reasons. Might want to look into how to read .TER files rather than wld hehe.

jbb 09-18-2004 04:52 AM

Well my main aim here was learning some more direct3d.
And the EQ files seemed like a good place to get some textures and verticies to draw :)

daeken_bb 09-18-2004 05:00 AM

Ah, cool. I would help ya out, but I neither know d3d nor desire to learn it :P

jbb 09-18-2004 05:06 AM

Well the graphics API is the easy part. It's getting the right data to put into it that's hard.
DX9 and opengl seem pretty much the same anyway with just a different syntax for doing the same things.

daeken_bb 09-18-2004 05:07 AM

Except OpenGL is cross-platform, and D3D isn't ;)

jbb 09-18-2004 05:21 AM

True, opegl itsself is cross playform although the programs that make use of it tend to be not so much.

Anyway, I'm already reasonably familiar with opengl and wanted to learn dx9 as well. You can never know too many things... And it seemed a good opertunity to combine that with learning about EQ file formats.

Are the other file formats of which you spoke in the earlier message any easier to process, or should I stick to WLD files given that for now I just want to extract some geometry to draw... Possibly doing something more advanced next project.

daeken_bb 09-18-2004 05:40 AM

Ter files are soooooooooooooooooooooooo easy to draw. Seriously, I did it in less than 60 lines of python lol. My documentation on the file format is available on this forum.

jbb 09-18-2004 06:42 AM

Thanks for that it looks interesting.
I'll take a better look at it tomorrow :)

jbb 09-19-2004 09:50 AM

You are right it is an easy format.
I've rendered "anguish" zone although all the triangles have a single texture so far. Real textures are a project for another day...


Thanks for the help :)

http://img76.exs.cx/my.php?loc=img76...e=render01.jpg

(Bah, can't seem to add a proper image to this posting...)

Cisyouc 09-19-2004 09:53 AM

Quote:

Originally Posted by jbb
You are right it is an easy format.
I've rendered "anguish" zone although all the triangles have a single texture so far. Real textures are a project for another day...


Thanks for the help :)

http://img76.exs.cx/my.php?loc=img76...e=render01.jpg

(Bah, can't seem to add a proper image to this posting...)

This is how ya do it:
http://img76.exs.cx/img76/9436/render01.th.jpg
Click to Enlarge.

jbb 09-19-2004 09:55 AM

Thanks , I tried about 20 different times with html and [img] tags but the preview just showed what I typed in.

Cisyouc 09-19-2004 10:04 AM

Quote:

Originally Posted by jbb
Thanks , I tried about 20 different times with html and [img] tags but the preview just showed what I typed in.

For future reference. (Imageshack images only)

Lets say
Code:

http://img76.exs.cx/img76/9436/render01.jpg
is the picture. To get the preview version attach th. to the suffix. So its now
Code:

http://img76.exs.cx/img76/9436/render01.th.jpg
.

So you use
Code:

[url=http://img76.exs.cx/img76/9436/render01.jpg][img]http://img76.exs.cx/img76/9436/render01.th.jpg[/img][/url]
[size=9]Click to Enlarge.[/size]

:D

daeken_bb 09-19-2004 10:05 AM

Nice job :)

However, you seem to have your vertices wrong or something... It looks like it's in a mirror.

jbb 09-19-2004 10:12 AM

Oh yes there are lots of things wrong. I was just pleased to get something that looked like it was at least coming from the correct triangles after a lot of work.

It originally rendered it going up and down the screen (I'm probably getting my x and z coordinates switched somewhere) so I put in a quick rotate to turn it through 90 degrees. Just a hack really to get something working. I need to figure out the exact problem and fix it rather than hack the symptom...

Also I expect most of the triangles are "inward" facing so you're probably seeing the far inside walls and not the top of the buildings at all. It's only intended to be renderered from inside the walls but withoug proper textures it's very hard to tell what you're looking at.

daeken_bb 09-19-2004 10:15 AM

Well, it's a great start :)

Just to let you know, we do the same rotation in OpenEQ, so don't feel bad :P

It's just the way they store their vertices I guess.

jbb 09-19-2004 10:24 AM

One question on texturing if you don't mind?

The "group" flield in your polygon structure in the TER file? Is that just an index to the appropriate texture? (Well the texture, bumpmap, effect etc. that you decoded in your other posting) or is it something more complicated? The group numbers I looked at all seem small enough to be indexes into that table?

daeken_bb 09-19-2004 10:35 AM

Yep, that's a material group ID. If it's -1, then either leave it out, or render it with a pure color, at least until we figure out what we're supposed to do with those.

jbb 09-19-2004 11:32 AM

Well I got it partly working.
I seem to be getting group indexes which are larger than the number of textures I've loaded, and also I'm getting a lot of missing triangles it seems.

But it looks nice :)

http://img26.exs.cx/img26/3194/render3.th.jpg

daeken_bb 09-19-2004 11:35 AM

Looks pretty damn good so far. Nice work :)

jbb 09-19-2004 11:42 AM

Thanks :)

I'm probably not going to go too much further with this although it's awfully tempting to fix the bugs, and implement lighting and bump mapping properly as well as a way to move around the map. But I don't have the time with work and all really, but I might be interested in helping out in a small way with your project should you need any help in the future.

daeken_bb 09-19-2004 11:44 AM

Cool, thanks :)

Speaking of OpenEQ... I just fully finished the octree and culling code... it rocks :D

jbb 09-20-2004 05:03 AM

Excellent. Does it speed up rendering much?

Hmm, still can't get the converter to work. I suppose I could build it under linux and compare the output files maybe.

daeken_bb 09-20-2004 07:48 AM

Heh, it's so incredibly fast it's not even funny :D

Still stuff I can do... in particular, using vertex buffers where supported. Right now, each end octree node has a compiled display list on it that we execute to render that node, and replacing that with a vertex buffer in video RAM might help a bit.

Mongrel 09-20-2004 07:57 AM

Be careful, though: Since you have to group the faces by texture you might end up with many small vertex buffers, which won't help you much in VRAM. It all depends on the size of your octree leafs :)

The vertex buffer object (ARB) extension should be supported on almost all vid cards, even my old GF4 Ti 4200 supports it.

daeken_bb 09-20-2004 08:07 AM

Hrm... yea...
I'm really new to doing advanced OpenGL optimization, so this is all new to me hehe. I'm mainly just experimenting and benchmarking right now to find the best way.

jbb 09-20-2004 10:20 AM

I'm having big problems reading TER files properly at the moment.
I'm trying to decode "wallofslaughter.eqg"

I extract ter_fortress.ter from the file which is at offset 19733813 and decompressed size is 9425438 bytes.

It has 29 texture entries, 190961 vertexes, 165352 triangles.

The problem I have is that this seems to be wrong because when I calculate the start location of the vertex data it seems to work out in the middle somewhere of the vertex data so I'm assuming I'm getting either the counts or the total size of the "file" wrong.

If you are able to decode this EQG file properly can you check my numbers please?

Thanks.,

daeken_bb 09-20-2004 10:22 AM

Are you skipping past the unknown data before the vertex list?

jbb 09-20-2004 10:26 AM

Well I'm doing this... Based slightly on your code... It's not perfect code but I've been hacking it a lot as I go, it could do with some proper structures and stuff. Too many global variables :(

I'm hoping that "verts" and "tris" will contain pointers to the vertex and triangle structures based on counting back from the end of the file. Which is why I suspected that either I've somehow got yhe counts, or the file size wrong.

Code:

void ProcessTERFile(char* terdata, int size)
{
        int magic                = *(long*)(terdata+0);
        int unk                        = *(long*)(terdata+4);
        int list_length = *(long*)(terdata+8);
        int obj_count  = *(long*)(terdata+12);
        int vert_count  = *(long*)(terdata+16);
        int poly_count  = *(long*)(terdata+20);

        assert(sizeof(TERVertex) == 32);
        assert(sizeof(TERTriangle) == 20);

        char* verts = terdata + size - (vert_count * sizeof(TERVertex) + poly_count * sizeof(TERTriangle) + 4);
        char* tris  = terdata + sizeof(TERVertex) * vert_count;

        g_nVerts = vert_count;
        g_Verts  = (TERVertex*)verts;

        g_nTriangles = poly_count;
        g_Triangles  = (TERTriangle*)tris;

        /* Now process the texture names part */
        char* p = terdata + 24;


jbb 09-20-2004 10:35 AM

Ok there is a big mistake there calculating "tris" - the location of the triangle structures, but the problem is that the verts are not right either.

jbb 09-20-2004 10:36 AM

Oops, I found my problem. My zlib code earlier on was faulty and was leaving a byte between uncompressed chunks so all the data was in the wrong place. I'm amazed it worked at all.

daeken_bb 09-20-2004 10:42 AM

So it works now? Cool :)

I gotta go to the doctor in a few, but I'll be back shortly hehe.

jbb 09-20-2004 10:44 AM

Yes it works! Amazing how trying to explain the problem causes you to suddenly realise what the problem it is

http://img68.exs.cx/img68/5009/render03.th.jpg

Next I'll try converted potranquility

daeken_bb 09-20-2004 11:06 AM

Looks great man. Nice work :D

jbb 09-20-2004 11:36 AM

http://img69.exs.cx/img69/5350/render04.th.jpg

and

http://img69.exs.cx/img69/1870/render05.th.jpg


Thanks to your work figuring out the file format and making the converter :)

daeken_bb 09-20-2004 12:20 PM

No problem, it looks great :D

jbb 09-20-2004 07:32 PM

I notice that in the poknowledge file there is a lot missing, like trees, the portal stones etc.

I presume these are added as objects onto the basic map.

Do we have any information on the file formats for these objects & their locations at all?

jbb 09-20-2004 07:46 PM

Quote:

Heh, it's so incredibly fast it's not even funny Very Happy

Still stuff I can do... in particular, using vertex buffers where supported. Right now, each end octree node has a compiled display list on it that we execute to render that node, and replacing that with a vertex buffer in video RAM might help a bit.
On my directX9 renderer at the moment I'm just creating one huge vertex buffer with all the vertices in and one huge index buffer with all the triangles in.

And then I'm going through every triangle and setting it's texture and then drawing it via the index buffer. The only optimization I'm doing is checking if the texture is the same for two consecutive triangles and not setting it again.


Even drawing every triangle individually I'm getting about 3 frames per second on poknowledge.

My next plan would be to pre-sort all triangles into a seperate list for each texture so I can draw many triangles with a single index buffer.

Not sure how culling triangles for visibility fits in with this... I suppose that every frame I need to check each triangle for potential visibility using the octree stuff (Does it have this information for the older zones?) and build a new index buffer containing only the triangles I want to draw for each frame.


All times are GMT -4. The time now is 05:29 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.