DiSaMe Posted July 4, 2010 Share Posted July 4, 2010 Less than 2 weeks ago RW binary stream files format seemed difficult to understand for me. Now it doesn't I have already requested the feature I wrote about in the video, but that was long time ago, when I hadn't even thought how important that feature is Link to comment
Lordy Posted July 4, 2010 Share Posted July 4, 2010 That is.. most interesting. So you take some input from client, convert it into a txd with some funky stuff and fileWrite, change meta.xml and load it as a txd? That's REALLY awesome Link to comment
DiSaMe Posted July 4, 2010 Author Share Posted July 4, 2010 There are two resources: drawtag and drawntag. Drawntag has TXD and a script which imports TXD and replaces a game texture with it. Drawtag has a client-side script for drawing. When you close drawing window, it sends image data to server. Server reads data, generates new TXD in drawntag and restarts that resource. So the texture changes. And drawtag also has a script which makes spray paint create tag object. Link to comment
MaddDogg Posted July 5, 2010 Share Posted July 5, 2010 That's really a great thing! The creating of the txd really impresses me, seems to be really cool to be able to generate those files. Where did you learn this from? Now you made me curious A clientside file management would be very useful indeed. I would love to be able to manipulate client files and load them without having to use meta.xml. This would also be great to create a signature system. By this I mean that every player is able to sign his driver license or whatever you want to be signed and this signature could then be saved as an image file. Link to comment
DiSaMe Posted July 5, 2010 Author Share Posted July 5, 2010 I learned about TXD files from here: http://www.gtamodding.com/index.php?tit ... tream_file. RW Analyzer by steve-m helped me a lot too. Link to comment
MaddDogg Posted July 5, 2010 Share Posted July 5, 2010 Nice stuff.. never actually bothered learning this stuff, although I'm quite experienced in modeling. Sorry, if this may sound like a nooby question, but.. do the textures have a format like png? I just know that when creating a txd, it seems to become a bmp, but as I said, I never learned this I hope that the MTA team will actually react to this (besides favoring your video). Link to comment
DiSaMe Posted July 5, 2010 Author Share Posted July 5, 2010 I don't know how PNG stores data. But uncompressed TXD textures store raster data in a similar way BMP files do. My script creates textures with DXT3 compression which stores data in 4x4 pixel blocks. Each block takes 16 bytes. Link to comment
DiSaMe Posted July 7, 2010 Author Share Posted July 7, 2010 Hmmm.... Maybe not... Not yet I think I will work a bit more on it and then release it. Link to comment
Maccer. Posted July 9, 2010 Share Posted July 9, 2010 Hrm, I can imagine fileCreate being able to make a .txd, but the real challenge and the thing I'm impressed about is how you transferred draw coordinates successfully. At least share that with us. Link to comment
DiSaMe Posted July 9, 2010 Author Share Posted July 9, 2010 When you draw image client-side, you create green squares. Their coordinates are transferred to the server with triggerServerEvent when you close drawing window. Server uses them to store data in a matrix, 128x128 table. If a pixel is drawn over, its value in the raster is true, otherwise it's nil. Then it creates TXD file, and writes the beginning until it reaches position where raster data in the file starts. It cycles through the table, writes image data and final RW sections, then closes the file. Firstly I made it create BMP files because that format is very simple. Link to comment
Maccer. Posted July 10, 2010 Share Posted July 10, 2010 When you draw image client-side, you create green squares. Their coordinates are transferred to the server with triggerServerEvent when you close drawing window. Server uses them to store data in a matrix, 128x128 table. If a pixel is drawn over, its value in the raster is true, otherwise it's nil. Then it creates TXD file, and writes the beginning until it reaches position where raster data in the file starts. It cycles through the table, writes image data and final RW sections, then closes the file. Firstly I made it create BMP files because that format is very simple. Hrm, thanks. But how do you write binary using fileWrite? It only takes strings AFAIK. Sorry if I'm slow, really sleepy. Link to comment
Maccer. Posted July 10, 2010 Share Posted July 10, 2010 string.char possibly Thanks Lordy! It worked! I've created a blank TXD file with fileCreate and string.char... if that counts for something. Edit: No, actually I did something wrong. DoomedSpaceMarine, how did you do it, and what TXD specification/format did you use for your images? fileWrite ( fileTXD, string.char ( 0x09 ) ) -- platform id: 9 for GTASA on the P.C fileWrite ( fileTXD, string.char ( 0x04 ) ) -- filter flag : FILTER_MIP_LINEAR 0x04 fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00 fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00 fileWrite ( fileTXD, "TESTEXTURE", string.char ( 0x00 ) ) -- Diffuse Texture Name + Null Termination fileWrite ( fileTXD, "TESTEXTUREALPHA", string.char ( 0x00 ) ) -- Alpha Texture Name + Null Termination fileWrite ( fileTXD, string.char ( 0x20 ), string.char ( 0x00 ) ) -- Raster Format [b] ***[/b] fileWrite ( fileTXD, string.char ( 0x01 ) ) -- Alpha/FOURCC fileWrite ( fileTXD, string.char ( 0x80 ) ) -- image width fileWrite ( fileTXD, string.char ( 0x80 ) ) -- image height fileWrite ( fileTXD, string.char ( 0x08 ) ) -- image BPP fileWrite ( fileTXD, string.char ( 0x02 ) ) -- mipmap count, testing 2 as value fileWrite ( fileTXD, string.char ( 0x04 ) ) -- raster type - apparently always 0x04 fileWrite ( fileTXD, string.char ( 0x03 ) ) -- dxt compression type *** - This is out of format. Since this part is 16-bit, and string.char only writes up to 8-bits max, it turns into 0x00, 0x20. A lot of these parts are DWORDS & WORDS anyways, so string.char won't do. It's roughly how I did it, but I just put in some random values out of the ones supported. Edit 2 (Right Datalenghts, STILL FAILURE): fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x09 ) ) -- platform id: 9 for GTASA on the P.C fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x04 ) ) -- filter flag : FILTER_MIP_LINEAR 0x04 fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00 fileWrite ( fileTXD, string.char ( 0x00 ) ) -- texture wrap WRAP_NONE 0x00 fileWrite ( fileTXD, "TESTEXTURE", string.char ( 0x00 ) ) -- Diffuse Texture Name + Null Termination fileWrite ( fileTXD, "TESTEXTUREALPHA", string.char ( 0x00 ) ) -- Alpha Texture Name + Null Termination fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x20 ), string.char ( 0x00 ), string.char ( 0x00 ) ) -- Raster Format fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x00 ), string.char ( 0x01 ) ) -- Alpha/FOURCC fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x80 ) ) -- image width fileWrite ( fileTXD, string.char ( 0x00 ), string.char ( 0x80 ) ) -- image height fileWrite ( fileTXD, string.char ( 0x08 ) ) -- image BPP fileWrite ( fileTXD, string.char ( 0x02 ) ) -- mipmap count, testing 2 as value fileWrite ( fileTXD, string.char ( 0x04 ) ) -- raster type - apparently always 0x04 fileWrite ( fileTXD, string.char ( 0x03 ) ) -- dxt compression type Link to comment
DiSaMe Posted July 10, 2010 Author Share Posted July 10, 2010 You need to write all sections with their headers before writing texture native struct section. This is TXD file structure. Try looking at TXD files with RW analyzer. Without it, I would hardly have understood RW format. Link to comment
Maccer. Posted July 10, 2010 Share Posted July 10, 2010 You need to write all sections with their headers before writing texture native struct section. This is TXD file structure. Try looking at TXD files with RW analyzer. Without it, I would hardly have understood RW format. I feel like an idiot, I was writing the txd native struct, not the folder txd. But what was your method of writing the data to the .txd's? fileWrite ( string.char ( ) ) is 8-bit, so it makes you have to make adjustments. Link to comment
DiSaMe Posted July 11, 2010 Author Share Posted July 11, 2010 function addBinaryValueToString(s,value,size) if value == false then value = 0 end if value == true then value = 1 end if type(value) == "number" then value = value%(256^size) for bytenum = 0,size-1 do s = s..string.char(math.floor(value%256)) value = value/256 end elseif type(value) == "string" then value = value..string.rep("\0",size-string.len(value)) s = s..value end return s end s is a string you want to join the new bytes to, value is the value you want to join, it can be a boolean, integer or string, size is number of bytes you want to join. Function returns s string with new bytes joined. First I made a function which writes the value directly to the file, but it turned out to be faster to write more bytes in less times than less bytes in more times. Using this function on long strings is slow too, so it's best to write the data to the file when the string is long enough. Link to comment
DiSaMe Posted August 30, 2010 Author Share Posted August 30, 2010 I thought of improving this script, but didn't change anything, so this is download link: http://www.sendspace.com/file/emhly9 Link to comment
DiSaMe Posted September 7, 2010 Author Share Posted September 7, 2010 Readme file updated and /clear bug fixed: http://www.sendspace.com/file/3owikg Link to comment
Maccer. Posted September 14, 2010 Share Posted September 14, 2010 Not sure if you knew, but in 1.1, client-side files were added. All credit goes to gamesnert. Link to comment
Castillo Posted September 14, 2010 Share Posted September 14, 2010 wow this resource rocks dude! Link to comment
nowofresh Posted December 1, 2011 Share Posted December 1, 2011 I putted drawntag and drawtag in resources and add acl - admin. When i type /draw and draw something, and again /draw to close window. It save, reload but when i am using spray always i got a oryginall texture from resource, not my new pattern. Any errors in debugscript 3. Any ideas ? Link to comment
nowofresh Posted December 2, 2011 Share Posted December 2, 2011 Who know how to fix that ? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now