Help for parsing texture from wad (custom engine)

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
Bubuche
Posts: 26
Joined: Mon Jun 06, 2016 5:12 pm

Help for parsing texture from wad (custom engine)

Post by Bubuche »

Hello everybody.

My first post here, so small presentation of myself: Bubuche, computer scientist, master 2 degree and ... with a lot of time (yup, i don't have a job, i know i should find one, shhh, don't say it to me please).
You must know : i am not a doom big fan, i didn't grow up with it even if it's my generation. I only start playing doom some month ago, with gzdoom and brutal doom on the top of it. English is not my native tongue and right now it's very late (so, forgive mistakes please). Also, i don't have internet during the day, only during the evening). This is for the small presentation.

I didn't find a doom engine under bsd licence and for this reason i decided, not to re-create an engine under this licence, but to at least do some job on that and create the basic stuff, something someone could use in the futur.

But ... i need a bit of help.
Here is the result right now :

https://www.youtube.com/watch?v=7j6aQmG7JK8
https://www.youtube.com/watch?v=fCaW8YpkHjY

I use jmonkeyengine for the rendering and the physic.
"So, what is your job actually ?"
My job is to parse the wad file, load textures, load levels, create tesselation for the ground, create the mesh with correct height for sectors ...
I'll also try to do music and basic sprite handling.

I need help for textures. I (kind of) understand the palette system and the light level system, the patch idea ... but i can't place patches correctly.

I already downloaded the uds.1666 file and some wiki page (i didn't use a tool to "grab" the site : i saved individual page, with the ctrl+s function of my browser. Don't hit) and for almost everything it was ok but for that ... nope.

For example the Brown144 texture is a texture with a height of 128 but it has a patch with a height of 144 pixels. How should i handle that, skip, use modulo ? There is also negative offsets in some textures.

I know that the "sky" is horrible : i didn't start to work on it yet, let me some time :p
I use bullet engine (actually : jbullet engine, the java port of bullet engine embedded in jmonkeyengine).
Ground is handled with a shader (and without texcoords) that map a color to a pixels according to the world coordinate of it. Well, you know how it works.
Every sector is loaded and "meshed" separatly. I don't use BSP tree (maybe i should) but if someone want to display only some sectors, it can.
The tesselation of the ground is made by an algorithm of my own (i don't say it's a brand new algorithm, i bet a lot of people already came with something similar) that doesn't add new vertex. So, i could (and i likely would) write a small program that take in parameter a wad file (and maybe a level) and generate a custom pwad file containing lumps that add triangles to levels.

(something like:
8-bit level name
[for each sector]
short number of triangle
3-short vertex index defining the triangle)

that way people will be able to do this part that is not that obvious to code otherwise (generate triangles for the floor and the ceiling).

Well ... good night everybody.

P.S. : i posted here because it seemed the best sub-forum to post it. It's "related to ZDoom". I don't mind if someone want to move it.
P.S.2 : i am not here to talk about GPL vs BSD licence. I like trolling like everybody does, but not in my first topic please :p
dpJudas
 
 
Posts: 3177
Joined: Sat May 28, 2016 1:01 pm

Re: Help for parsing texture from wad (custom engine)

Post by dpJudas »

I believe that the texture size sets the final size of the texture, and that patches either wrap or clamp to the edges. Which of the two I'm not entirely sure, but for virtually all of the textures the following code does the trick:

https://github.com/dpjudas/GameAssetsEx ... e.cpp#L740
https://github.com/dpjudas/GameAssetsEx ... e.cpp#L230

Sorry if the code is a little bit messy. I got a bit lazy and didn't create functions for each lump processing. But maybe it will still be of some use to you.

You could also take a look at the ZDoom source code:

https://github.com/rheit/zdoom/blob/mas ... exture.cpp
https://github.com/rheit/zdoom/blob/mas ... exture.cpp

Hopefully this will help you a bit.
Bubuche
Posts: 26
Joined: Mon Jun 06, 2016 5:12 pm

Re: Help for parsing texture from wad (custom engine)

Post by Bubuche »

I think it will not help me "a bit" : it will help me a lot !

Also ... wow wow wow, there is so much part of this code that are so close to mine ! Not only for textures !
You have a "WadFile" i have a "DoomFile". Ok, you are right on that one, it's wad, not doom. Anyway.
You have "read_linedefs" etc. to parse different lumps. I have a generic class "lump" and classes extended it, redefining the "readData" method that does the actual parsing. But the dispatching is the same (and the algorithm to read the lumps too).

a big difference however : i have a doomfile and a richdoomfile. Doomfile is mostly a collection of lumps, without more "semantic". The richdoomfile is like a view in a database: it adds the notion of level, of namespaces, add caching for some results etc. and use the doomfile as backend.

Hmm, i think now that you don't give a sh*t to what i did. Sorry, i like to explain things.

Anyway, thx a lot, i downloaded the code and inspect that deeply at home.
dpJudas
 
 
Posts: 3177
Joined: Sat May 28, 2016 1:01 pm

Re: Help for parsing texture from wad (custom engine)

Post by dpJudas »

Glad to hear you find it useful. Figured you might as its effectively trying to do the same as you are - just exporting to fbx and png files instead. :)

My code doesn't try create a "lump" abstraction or anything else because its only purpose was to dump the contents of a wad file to formats usable by my own game engine. The idea being it would give me some test maps - not to run a full Doom game. That's why the code is so relatively messy because it was intended as a sort of one time script. Anyhow, if you have any questions about the code feel free to ask and otherwise good luck with your engine!
Bubuche
Posts: 26
Joined: Mon Jun 06, 2016 5:12 pm

Re: Help for parsing texture from wad (custom engine)

Post by Bubuche »

One last video (i'll not post more here, if needed i'll open a topic dedicated to this engine).

https://youtu.be/xREniIsBkhI

The problem i had with texture was kind of fixed ... by commenting two line in my code (i was throwing away patch with a negative offset ... i did that to prevent crash and forgot to remove it).
I also started to integrate "thing"s (not the word "things", i am talking about lumps THING, i.e. actors etc). I can handle the sprite switch according to the angle with the player, just not done yet. Misaligned texture : partial fix. Transparent texture : done. Billboard for things : done. light level on things : done.

Well well well, thx for the help a lot, i can continue without this thorn in my side (not sure about that expression, the literal translation would be "a thorn in the foot")
Post Reply

Return to “General”