• GM Paint - Draw shit in-game in 3D!
    115 replies, posted
  • Avatar of Skyhawk
  • GM Paint is, you guessed it, MS Paint in GMod. As I was working on a different addon the other day, I found myself wanting a flag for my pirate ship - and I got to thinking, what if, instead of making a new texture and material for the flag, I created something to allow myself and others to [i]draw their own?[/i] So I did. [release] [highlight]UPDATE: Version 0.77[/highlight] [i]Now with no datastream-breaking bugs! (Hopefully :ohdear:)[/i] [b]Beta Release 0.77[/b] [url=http://www.garrysmod.org/downloads/?a=view&id=81756][img]http://www.garrysmod.org/img/?t=dll&id=81756[/img][/url] Mediafire (OUTDATED, 0.76): [URL]http://www.mediafire.com/?tdhuzng0ijc[/URL] Now you can show us all your 8-bit works of art.[/release] Some feature listings for y'all: [b]Primary and Secondary Colors[/b] Like any good image editing program, GM Paint has primary and secondary color selection. When the editor is open, left clicking on a color in the color selection palette will set it to your primary color, and right clicking will set it to your secondary. This has an advantage not only in ease of selection, but also in less networking in that only an index and not a whole color value has to be sent. You then simply click on a point with your left or right mouse button to set it to the selected color on your massive :ninja: 16x16 resolution canvas. Additionally, you can hit the "Clear" button to set all the pixels on your canvas to your secondary color. [i]Editor:[/i] [media]http://img19.imageshack.us/img19/9687/editorg.png[/media] [b]File Saving and Loading[/b] Easy-to-use file saving and loading allows you to keep your grand works of *cough*art*cough* and easily manage it across servers. [b]Networking[/b] Once you're done editing your art, you can hit the Upload button to send it to the server. Once the server has a hold of it, you can spawn paint panels in the 3D world, upon all of which your image will be displayed for everyone to see. Uploading again will replace the image in your panels, and of course there are upload limits to prevent spamming minges. I kept the canvas at a resolution of only 16x16 as stated before because as is, a table of 256 values has to be sent every time you upload an image - I may add an option for daring server owners to increase the resolution later. [i]Small Panel[/i] [media]http://img44.imageshack.us/img44/8900/gmconstruct0021s.jpg[/media] [b]Text Support[/b] (Not yet implemented.) In addition to pixel-based art, you will also be able to use text to create signs, perfect for RP and whatnot. [i]What can currently be done in place of actual text:[/i] [media]http://img23.imageshack.us/img23/756/gmconstruct0018.jpg[/media] [b]Vector Art[/b] (Not yet implemented.) A feature still in the concept stage, I've been thinking about adding the option to use a "vector canvas," in which instead of specifying the color for every pixel, you would specify points that would be connected and filled to create polygons. This requires much less networking and would allow for "higher resolution" art. [i]And since it had to be done:[/i] [media]http://img23.imageshack.us/img23/509/gmconstruct0020.jpg[/media]
  • Avatar of Squad
  • I was about to make something like this, guess you beat me to it. Good work. I don't understand the dumb ratings?
  • Avatar of Skyhawk
  • [QUOTE=Python1320;16667832]Nice idea, but how's the fps drop if "any"?[/QUOTE] From my testing so far? Really none with just one or two panels on screen. When 4 or 5 are on screen, there's a tiny drop, but far from anything of significance - and considering I wrote and tested this on such a crappy laptop, that's really saying something. It's doing really simple draw functions actually, just drawing a rectangle for each pixel. And I'm very picky about optimization, so there's hardly any network lag from uploading.
  • Avatar of LimEJET
  • Awesomeness, now we can make our own battleflags! I've been wanting something like this for a long time, since reskinning and hexing just won't cut it on a server where everyone wants their personal flag as soon as they join -_-
  • Avatar of pdkm931
  • This is awesome :buddy: Gonna download it if it gets to about 64*64 pixels (if possible :3:)
  • Avatar of CowThing
  • [QUOTE=pdkm931;16676288]This is awesome :buddy: Gonna download it if it gets to about 64*64 pixels (if possible :3:)[/QUOTE] That's a lot, that's the same as 16 of the current size.
  • Avatar of nicktelli
  • Since everyone thinks I only shit on things when in reality I only bring constructive criticism to terribly made things... This is one of the most brilliant addons to GMod... ever. This is right up there with the vmf loader for gmod9 by Jinto. Sure it's limiting, but it's still quite ingenious and imaginative and will bring endless hours of fun to mingebags everywhere spamming penises and the like.
  • Avatar of Entoros
  • It would be supremely awesome if it functioned in a 16x16x16 cube (you draw by selecting unit cubes). But that's kind of ridiculously difficult. That aside, this is pretty awesome. Good job.
  • Avatar of SeveredSkull
  • I dont really see how that would be difficult... it would just be like 6 panels welded together like a box... I'm sure you could probbably already do it but considering the fact that I have no idea what the code looks like or how it functions so i really have no idea at all on how it would work.
  • Avatar of Skyhawk
  • [QUOTE=pdkm931;16677082]Well 32 Pixels than? :frown:[/QUOTE] Well you see, as-is, your image is stored on a per-player basis; not per-panel. So all your panels have the same image - yes it's kinda limiting but it is a LOT less to network and keep in memory. 32x32 pixels would be effectively increasing the networking and memory usage for each player's panel to 4 times its current amount - it's not terrible, but it's a bit more than I'd like, which is why increasing the resolution is a feature I may only add later for daring server owners. Also, the idea of the 6-sided cube is possible, but as I said, images are stored on a per-player basis, so your cube would have the same image on every side - might as well just weld them together. Oi, and I need to adjust some networking so it'll send info to newly connected players. Oh and one last thing, I will be adding dupe support but it will not record the image - it will just use a blank one until you upload the image you want to the server.
  • Avatar of Jawalt
  • TBH I don't think sending 32 integers to the server and players would be demanding at all.
  • Avatar of Skapocalypse
  • Would doing a table not help this? pixels would be 1| 2 | 3 |4 5| 6 | 7 |8 9|10|11|12 And just have a table entry for each pixel.. ? I haven't looked at the code because I'm on a laptop out of state, but Just a thought :3
  • Avatar of Skyhawk
  • [QUOTE=Jawalt;16702183]TBH I don't think sending 32 integers to the server and players would be demanding at all.[/QUOTE] Not 32 integers, a resolution of 32x32 would be [i]1024.[/i] :what-was-the-facepalm-emote-again?: [QUOTE=Skapocalypse;16703061]:words: about tables[/QUOTE] It already uses table entries. It's a table of 256 values that must be sent to the server and all clients, and be kept in memory for the server and clients, too, so I really don't think a resolution higher than 16x16 is efficient for now. Like I said though, I might bring it up to 32x32 for server owners who want to risk the possible performance drop for them and their clients. Personally, I think 16x16 is fine - you can fit a good amount of text or a decent 8-bit-style drawing in there if you know what you're doing, but I will try to do the 32x32 option anyway since it's got such high demand. Oh and late response but I will try to add transparent pixels - shouldn't be too hard. There won'd be actual Alpha, but you will be able to set it to not draw a pixel at all.
  • Avatar of Entoros
  • A cool function would, like in the real MS Paint, would be the "Invert Colors" function. I'm not entirely sure how you flip colors around like MS Paint, but it wouldn't be too hard; just get all the pixels and change their color by pressing a button.
  • Avatar of Overv
  • [lua]function flip( col ) return Color( 255 - col.r, 255 - col.g, 255 - col.b ) end[/lua]
  • Avatar of Jawalt
  • [QUOTE=Skyhawk;16703814]Not 32 integers, a resolution of 32x32 would be [i]1024.[/i] :what-was-the-facepalm-emote-again?: [/QUOTE] Even so, consider that every chat message sends on average ~60 string characters. :what-was-the-facepalm-emote-again?: Sending 1024 integers to the server then to all the clients would not be a big deal, I don't think. Considering that a serverside Youtube player can play at like 1/4th speed and sends alot more information than that.
  • Avatar of Skyhawk
  • [QUOTE=Overv;16711989][lua]function flip( col ) return Color( 255 - col.r, 255 - col.g, 255 - col.b ) end[/lua][/QUOTE] Unfortunately, as I said, to reduce networking the colors are not stored as Color values but indexes matching up to a palette. So that wouldn't quite work, nor would color flipping really be possible (or necessary?) Wow, rating glitches are getting annoying.
  • Avatar of Skyhawk
  • [QUOTE=Overv;16720832]Then you inverse the pallet, seems pretty obvious.[/QUOTE] Well yes, but it wouldn't match up quite right. (i.e. inversing blue would get you yellow normally, but not necessarily on the palette since the colors aren't in too particular of an order)
  • Avatar of Overv
  • I don't think we're understanding each other. On the palette you have your colors defined with RGB values and indices right?
  • Avatar of Skyhawk
  • [QUOTE=Overv;16721016]I don't think we're understanding each other. On the palette you have your colors defined with RGB values and indices right?[/QUOTE] [code]local palette = {Color(0,0,0), Color (245, 125, 50), Color (60, 60, 60), Color (50, 125, 50)}[/code] Not those actual colors but that's how it works. Flipping the indexes (i.e. flipping 1 to 16, 12 to 4, etc.) would work but visually you wouldn't have the actual opposite of the color. As far as going through the palette and actually flipping the values it contains would be possible but it would require another Networked Integer and more crap the client would have to deal with when drawing (recreating the palette inversed for just clients that have it inversed) It would also mean you are flipping all your palette colors and not just inversing the colors to others on the palette. I suppose it could be done but I really don't see why it would be necessary.
  • Avatar of Overv
  • You only need one user message to flip the values, it can all be done on the client.
  • Avatar of Skyhawk
  • [QUOTE=Overv;16721440]You only need one user message to flip the values, it can all be done on the client.[/QUOTE] Well yes, that or a networked variable, doesn't really matter, but the point is it's not really useful as it's not expanding the client's palette and it's not just flipping the existing colors as you would use it in MS Paint. I don't know, I might add it anyway later.