BSP Editor
#1
Posted 17 March 2013 - 03:01 PM
I'm currently trying to develop a bsp editor. I use the bsp format specs found here. My 'bsp reader' works perfectly but my 'bsp writer' doesn't (for the moment i'm just trying to replace a texture).
Does anyone know what datas is missing in those specs? Have you got links to share with me?
Thanks in advance
#2
Posted 17 March 2013 - 03:37 PM
I'm not aware whether those specs are complete or not (but I've used them too in the past, for different purpose). Since you're the one who wrote the code you practically have it in your hand to deeper analyze it (e.g. what means "doesn't work"? Compare the input binary with the output binary and I'm sure you will find the problem).
#3
Posted 17 March 2013 - 04:03 PM
I compared an "original" bsp and an edited one by myself, I see a difference but I dunno what are those datas (string? int32? float? byte?...) and what is the correspondence.
I'm not a pro with binary files (I've just discovered them with this project), then there might be a way to do it that i dunno..
Btw I'll look for the code that radiant is using, maybe I'll find some useful informations.
#4
Posted 17 March 2013 - 07:13 PM
n4w4k, on 17 March 2013 - 04:03 PM, said:
I do not understand what you mean. As described here a "texture-datablock" contains a string[64] (64 bytes long) which specifies the name of the texture or shader (e.g. "textures/common/caulk"). If the name is less than 64 bytes long, the rest is filled with nulls ('\0' or 0x00). The name is followed by two int32 (integer, 4 bytes long) which represent some flagcomibnations.
You have to make sure, that your writer writes the correct number of bytes, for instance the writer has to write 64 bytes for the name.
I have done something similar recently, perhaps my code helps...
If it still does not work, maybe I can help you if you care to share some code :)
Fractal Image Calculator: Fraktalysator
#5
Posted 18 March 2013 - 09:41 AM
Now I get another issue But this time I have a error in urt:
Quote
I dunno the meaning of that.
@argusmagnus: I saw your project, it looks nice. I'm using csharp too for this project so maybe you can help me
You can find my source code here. I hope you or someone else will be able to find where is my mistake(s).
Thanks
PS: Of course my project is open source
This post has been edited by n4w4k: 18 March 2013 - 10:07 AM
#6
Posted 18 March 2013 - 11:02 AM
char ch = (char)reader.ReadByte();
instead. Of course the same is true for BinaryWriter.Write(char[]).
edit: Or you could use the constructor overload and set the encoding to ASCIIEncoding. (I did not test this, but it should work).
This post has been edited by argusmagnus: 18 March 2013 - 11:17 AM
Fractal Image Calculator: Fraktalysator
#7
Posted 18 March 2013 - 12:11 PM
I've fixed issues and now I'm able to load a bsp file and save it after (tested with ut4_abbey and my own maptest).
The code is available here.
Now I'll try replacing some textures and see what happens.
At the end, I want to be able to add new 4.2 jump entities in a friend's bsp file (map file is lost..).
I'll see what I'll can do
Thanks a lot for your help!
#8
Posted 19 March 2013 - 01:46 PM
Good luck anyway! :)
Fractal Image Calculator: Fraktalysator
#9
Posted 19 March 2013 - 06:28 PM
My friend's issue is a pretext for manipulating bsp files, so it's not really a problem for me.
For adding jump_start & jump_stop entities, I have to add them in the entity lump (pretty easy as you said) but I have to add trigger_multiple brushes, and here is the difficulty. One of the easiest way I have imagine is decompiling the original map with q3map2, looking for the trigger_multiple brushes bounds in radiant, and creating a method like AddTriggerMultipleBrush(float[] position, float[] size, string target) in my program. But adding a brush looks a pain..
I still have to learn a lot about the bsp file data before finishing the project..
#10
Posted 19 March 2013 - 07:46 PM
Fractal Image Calculator: Fraktalysator