Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
wlievens
Nov 26, 2006

Gordon Cole posted:

I'm trying to come up with an algorithm to solve a problem that I've never come across before. The situation is thus:

I have a 2D grid of cells. Any number of cells can be selected in any shape or pattern. I need to create an algorithm that will partition an arbitrary selection of cells into a reasonably small set of rectangles. To illustrate the situation, here's an image:



The selection on the left should be partitioned into something like the 6 rectangles on the right.

Brute force approaches are pretty straightforward, but I need this to be fast. It doesn't need to be the smallest possible set of rectangles, just reasonably small.

Does this problem or algorithm have a name? I've been trying to google it with no luck.

You could use a linescan approach. Divide it into lines first, and then collect lines of equal height into rectangles.

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
wlievens: yeah, that was my first thought.

If that approach winds up having a bunch of edge cases, you could more generally apply some kind of simulated annealing algorithm.

Duke of Straylight
Oct 22, 2008

by Y Kant Ozma Post
You could start by constructing a region quadtree over the grid, marking leaves as either selected or not-selected. The end result would be a structure looking somewhat like so: http://en.wikipedia.org/wiki/File:Quad_tree_bitmap.svg. Then you can just pick all of the selected leaves.

If that's not optimal enough, you might be able to modify this whitespace cover algorithm to match your needs. That quadtree you constructed earlier should help to get this one to run fast even with a large number of "obstacles" (unselected tiles), I believe, though you might need to come up with a clever way to pick obstacles fairly to really make it worth it.

dizzywhip
Dec 23, 2005

Thanks for all the suggestions. I think I'm leaning towards the quad tree approach. The line scan approach seems interesting, but as I'm understanding it, it sounds a bit more complicated to implement since lines can be discontinuous.

A quad tree seems like it will work great though. Thanks!

LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!
I think I would just line scan over it in the horizontal and vertical directions, and encode the one that generated the least rectangles.

However, there have been papers written about this, if you care.

dizzywhip
Dec 23, 2005

Sweet, thanks for the link. That was exactly the kind of thing I was searching for, but I didn't know the proper term for the problem.

Hanpan
Dec 5, 2004

Anyone have any idea what kind of language developing something like Super Meat Boy would be best suited to? I've seen a lot of those kind of games recently and I'm keen to know what powers it.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

How do you guys find the artists for your games?

haveblue
Aug 15, 2005



Toilet Rascal

Hanpan posted:

Anyone have any idea what kind of language developing something like Super Meat Boy would be best suited to? I've seen a lot of those kind of games recently and I'm keen to know what powers it.

I think SMB started out as a Flash game before it was remade for Xbox. Any of the major languages can do a 2D platformer, but Flash is probably faster and easier for that specific sort of game.

POKEMAN SAM
Jul 8, 2004

Yakattak posted:

How do you guys find the artists for your games?

Ah, the age old question for wannabe independent game developers :) There are some posts on the XNA forums about this (like where to hunt for artists, etc.) but since you're a goon you probably just want to try stalking goon artists. Either way, if you're not paying they'll probably flake out, if you don't flake out first. Additionally, it's always a million times better to bring a lovely looking (but functional) prototype to the table when trying to find an artist.

Hanpan
Dec 5, 2004

haveblue posted:

I think SMB started out as a Flash game before it was remade for Xbox. Any of the major languages can do a 2D platformer, but Flash is probably faster and easier for that specific sort of game.

Yea the prototype was a Flash game from what I remember. I'm just wondering what they actually used for the final production because its really solid.

Tax Oddity
Apr 8, 2007

The love cannon has a very short range, about 2 feet, so you're inevitably out of range. I have to close the distance.

Hanpan posted:

Yea the prototype was a Flash game from what I remember. I'm just wondering what they actually used for the final production because its really solid.

I'm fairly sure it's just good ol' C++. I don't think a lot of other languages will run on the xbox, except for XNA, but that's mostly (or exclusively?) used on the indie channel.

POKEMAN SAM
Jul 8, 2004

Nev posted:

except for XNA, but that's mostly (or exclusively?) used on the indie channel.

Not exclusively, but nearly so.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
The game is also for the Wii, so it's most likely written in C++. Well, I'm sure they embed some sort of scripting language like Lua and use that for many things. It's at least not C#/XNA.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Yakattak posted:

How do you guys find the artists for your games?

What are you looking for, exactly? 3D models, textures, 2D sprites?

There are lots of sites like OpenGameArt (and not-so-kosher sites that have rips from console ROM's and PC games), that might be enough to get you started. Then you can offer to pay a goon cash to create some stuff for you, a lot of the stuff I see there is pretty good. The trouble will be finding someone who is good at making game-specific art.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
I have a question that should be pretty simple - what's the best (or a good) way to make a color-configurable object in 3D, such that you can have ten of the same object with different colors and without ten duplicates of the model and without changing the vertex data between renders?

For example, say I wanted to use a flag object with a fixed pattern but three user-configurable colors. I figure one way would be to split the object into three sub-objects and render them each with different colored lighting. Is there a better way than that?

haveblue
Aug 15, 2005



Toilet Rascal

roomforthetuna posted:

I have a question that should be pretty simple - what's the best (or a good) way to make a color-configurable object in 3D, such that you can have ten of the same object with different colors and without ten duplicates of the model and without changing the vertex data between renders?

For example, say I wanted to use a flag object with a fixed pattern but three user-configurable colors. I figure one way would be to split the object into three sub-objects and render them each with different colored lighting. Is there a better way than that?

More or less. You'd split up the base geometry into one class and the characteristics of each instance of the flag into a second, then instantiate three of the second that all refer back to the single base instance and have them call the base's render method after setting up their unique transformation and lighting.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Let's talk map file formats for a tile-based game for a second (either overhead or side-scroller)

First thought is to make up some sort of binary file spec, with a header for misc stuff then x*y bytes for the map. Would it make more sense to use some sort of text file format? For some reason something like XML makes my toenails curl, but I can see it making sense. What's a good library to use to read/write formats like that?

I'm trying to piece an editor together for maps, because right now I'm just making them in a text editor.

code:
......................i..i....
..............................
....ooooooooo.................
..............................
..............................
....x..x......................
................ooooo.........
..............................
..............................
oooooooooooooooooooooooooooooo
:downs:

a slime
Apr 11, 2005

I always use a text format for the basic map data, followed by XML/JSON/YAML/whatever to note the position of entities and so on

The library depends on the language. I use yaml-cpp for all my text file needs

POKEMAN SAM
Jul 8, 2004

Bob Morales posted:

Let's talk map file formats for a tile-based game for a second (either overhead or side-scroller)

First thought is to make up some sort of binary file spec, with a header for misc stuff then x*y bytes for the map. Would it make more sense to use some sort of text file format? For some reason something like XML makes my toenails curl, but I can see it making sense. What's a good library to use to read/write formats like that?

I'm trying to piece an editor together for maps, because right now I'm just making them in a text editor.

code:
......................i..i....
..............................
....ooooooooo.................
..............................
..............................
....x..x......................
................ooooo.........
..............................
..............................
oooooooooooooooooooooooooooooo
:downs:

There's no reason that you can't/shouldn't write an editor that works with the file format you have already, assuming the same rules are in effect (each thing that can be placed is one tile, etc.) It'd be a good starting point at least.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Ugg boots posted:

There's no reason that you can't/shouldn't write an editor that works with the file format you have already, assuming the same rules are in effect (each thing that can be placed is one tile, etc.) It'd be a good starting point at least.

I think I'm just having nightmares about doing text i/o in C

ambushsabre
Sep 1, 2009

It's...it's not shutting down!
Why wouldn't a solution like OGMO work? The format is going to be different from what you have, but it shouldn't be too difficult to convert, it's really simple at its heart.

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug

Bob Morales posted:

I think I'm just having nightmares about doing text i/o in C
You only really have to do I/O when you save or load the map from the editor. Just load it into a buffer and translate the ASCII into proper values indicating what tile to place, and display/manipulate the buffer from the editor.

Surely you have to do the exact same I/O in order to get the actual game to use these maps.

I think there's also the Mappy editor, unless that doesn't exist/work anymore. I've always rolled my own tools and ended up with a crappy miasma of hotkeys and awkward half-right UI elements because I hate writing my own UI controls.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Bob Morales posted:

I think I'm just having nightmares about doing text i/o in C

You could always build a mapping tool that emitted C files that contain all the map data in array literals and so forth. :q:

Jo
Jan 24, 2005

:allears:
Soiled Meat
Because I am a huge manslut, I will recommend the use of TilED. (http://www.mapeditor.org/) If you can avoid re-inventing the wheel and dodge not-invented-here syndrome, you'll save yourself tons and tons of time.

brian
Sep 11, 2001
I obtained this title through beard tax.

I personally use OGMO but it's not really the best, I tend to write a lot of small very specific editors for certain things in as3 with AIR to make up for the shortcomings. I think the key thing with 2D level editors is having the ability to define as much information and behaviour as you want, OGMO does that well for most stuff but could really do with a plugin system (or be open source which Matt is apparently planning on once the code is cleaned up a bit, i'd rather just have him clean it up publicly).

Also I never understood why people dislike XML based file formats for things that aren't huge in file size, it's readable, there's a good implementation for every language and DOM really suits a lot of game entity data. I'm guessing a lot of people have bad experiences from Xerces or having to validate for software engineering/web purposes.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Seat Safety Switch posted:

I've always rolled my own tools and ended up with a crappy miasma of hotkeys and awkward half-right UI elements because I hate writing my own UI controls.

It's going to be my first 'real' Cocoa app (the editor) so in theory I should just be able to throw something together real quick and the hard stuff will be taken care of for me.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

haveblue posted:

More or less. You'd split up the base geometry into one class and the characteristics of each instance of the flag into a second, then instantiate three of the second that all refer back to the single base instance and have them call the base's render method after setting up their unique transformation and lighting.
Most games that do this have separate texture overlays for colorable parts.

For things that are color-tinged rather than a solid color, you can avoid using an alpha channel by premultiplying and treating the colorization layer as additive.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

OneEightHundred posted:

Most games that do this have separate texture overlays for colorable parts.

For things that are color-tinged rather than a solid color, you can avoid using an alpha channel by premultiplying and treating the colorization layer as additive.
Sorry, can you give me a bit more detail about that? I mean, what would the vertex format be like for an object with three colorable parts using this method? Or does it still involve splitting the object into three sub-objects, and just coloring with a texture instead of with changing the light[s]? (If it's that, what makes that better than changing the light[s]?)

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
You'd make the entire thing a "colorable part" and you have a separate texture for coloration.

Like let's say you had a human model with a colorable shirt. You'd have two textures for them, a base which contains all colorable areas and the area corresponding to the shirt would be black. The second texture has everything black except the shirt area, which would be white, or shaded, or whatever.

You'd render the whole object, send the coloration as a uniform instead, and render as basetexture+(shirtmasktexture*shirtcolor)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Still not sure I'm getting how this works - what if you have ten guys with indepenently colored shirts, pants and hats? Would this involve rendering with basetexture and three other textures for each object? And if so, is that really going to be quicker/better than rendering it as three or four objects with only one texture each?

Also not getting how you'd do shirtmasktexture*shirtcolor - is shirtcolor being set as a variable in a shader or something? (So far I'm still using the old FVF so I'm not really sure what you can do with shaders.)

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Gordon Cole posted:

Thanks for all the suggestions. I think I'm leaning towards the quad tree approach. The line scan approach seems interesting, but as I'm understanding it, it sounds a bit more complicated to implement since lines can be discontinuous.

A quad tree seems like it will work great though. Thanks!

I know you said it doesn't need to be optimal, but I would note that a quad-tree algorithm will be problematic for anything that doesn't lay on or close to the quad tree boundaries. A better approach would probably be something like an axis-aligned BSP, where you basically keep slicing in into two parts until you end up with a completely covered cell (which will be your rectangle). The optimization here will be in how you choose where to put your partition; however, the simplest case (always splitting in the middle) will be exactly as good as the quad-tree approach, so you've got room to improve there in the event of lopsided distributions inside each node.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

Still not sure I'm getting how this works - what if you have ten guys with indepenently colored shirts, pants and hats? Would this involve rendering with basetexture and three other textures for each object? And if so, is that really going to be quicker/better than rendering it as three or four objects with only one texture each?
Coloration masks are single-channel so you can stuff up to 4 of them in the same texture.

quote:

Also not getting how you'd do shirtmasktexture*shirtcolor - is shirtcolor being set as a variable in a shader or something? (So far I'm still using the old FVF so I'm not really sure what you can do with shaders.)
Use a uniform, which is a value you can set that's constant for all pixels or verts in the shader.

Also FVF is obsolete as of D3D9, having been replaced by vertex declarations, which are better in every conceivable way.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

OneEightHundred posted:

Coloration masks are single-channel so you can stuff up to 4 of them in the same texture.
Ah, I see what you're saying. Pixel shader magic.

quote:

Also FVF is obsolete as of D3D9, having been replaced by vertex declarations, which are better in every conceivable way.
Yeah, I have three reasons for still using FVF - one, it's what I wrote the engine to use the second time I rewrote it, and it seems silly to rewrite it again if I don't desperately need to, two, my target platform is "somewhat outdated machines and up", and my previous was-high-end laptop couldn't cope with a lot of shader stuff - I figure I'm pretty safe on the requirements front if I continue to use DX9 era stuff, and three, time spent learning to use shaders would be time spent not working on the actual game. Though I do occasionally find myself wishing I was using some of the vertex declaration stuff just for ease of handling the raw data!

Sorry if that sounds ungrateful, I do appreciate the advice and am certainly filing it away as a thing you can do with shaders that I didn't know about (especially sneakily slapping four 'grayscale' masks into one texture).

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

Yeah, I have three reasons for still using FVF - one, it's what I wrote the engine to use the second time I rewrote it, and it seems silly to rewrite it again if I don't desperately need to, two, my target platform is "somewhat outdated machines and up"
DX9 is a pretty reasonable minimum target right now, it hits things as low as the 915G and FX5200. Doing shaders in DX8 will drive you insane since it's low-level and inconsistent across vendors.

Shaders are something worth learning BECAUSE they make things a lot easier, instead of trying to do stupid tricks with the state machine to produce effects you want, you just hammer out some shader code blurb which tells it to do EXACTLY what you want it to do in very no-bullshit fashion.

Zerf
Dec 17, 2004

I miss you, sandman

OneEightHundred posted:

DX9 is a pretty reasonable minimum target right now, it hits things as low as the 915G and FX5200. Doing shaders in DX8 will drive you insane since it's low-level and inconsistent across vendors.

Shaders are something worth learning BECAUSE they make things a lot easier, instead of trying to do stupid tricks with the state machine to produce effects you want, you just hammer out some shader code blurb which tells it to do EXACTLY what you want it to do in very no-bullshit fashion.

Seconding this. You shouldn't even need to rewrite that much of your engine anyways, since you could just use shaders/FVF side by side. Heck, I'd implement support for shaders just to be able to quickly reload and debug graphic glitches.

If I were you I would at least consider downloading some samples/tutorials with shaders to toy around with them and see what they can do for you.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Basically the instant you want bumpmapping, you'll quickly start seeing the advantages of shaders. Without them, you need goofy poo poo like directional cubemaps, you'll quickly run in to texture unit limits, and trying to combine multiple effects will combine all of the previous problems into endless frustration. Don't even get me started on how horrible it is trying to do bumpmapped reflection without shaders or in DX8 compared to how trivial it is with shaders.


Regarding the FVF point in regard to hardware targets, there is very little reason to target anything below DX9 as a minimum. The 915G, which has been Intel's low-end shitpiece since Vista came out (2006) and has the horsepower of a GeForce 2, supports DX9. Nearly everything bad about DX8 was either resolved or given a non-bad alternative in DX9, and the non-bad alternative to FVF are vertex declarations.

If you REALLY need to target below DX9, use OpenGL instead, the Direct3D API pre-9 is pretty brain-damaged.

OneEightHundred fucked around with this message at 18:35 on Oct 28, 2010

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

OneEightHundred posted:

If your target minimum is DX9, you should be using vertex declarations, not FVF.
I was aiming for a minimum of "Direct3D 9 Drivers without Pixel Shader Version 3 Support" (as a piece of Microsoft documentation calls it), for which the requirements for using vertex declarations include that the declaration must map precisely to an FVF. Is this a model not worth supporting any more? (Again, this is what my previous was-high-end-at-the-time laptop was capable of.)

Eh, just checked my girlfriend's new-low-end laptop and it supports DX9 and puxel shader 3, so I guess it probably would be okay to stretch my low-end support up that far.

That said, I'm very unlikely to need or want any of the really clever stuff for my project - it's pretty much comprised of 2D stuff (some of which is made of basic 3D to produce a "Flashback" sort of look). As such I barely even need texture mapping (except as used for sprites), and certainly bump mapping would be ridiculous in this context.

Edit: But I should probably learn shaders anyway because my backburnered project will certainly want some of that prettier-looking stuff.

roomforthetuna fucked around with this message at 18:52 on Oct 28, 2010

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
I'm pretty sure the FVF/declaration mapping requirement only applies when you're using fixed-function.

Adbot
ADBOT LOVES YOU

Zerf
Dec 17, 2004

I miss you, sandman

roomforthetuna posted:

I was aiming for a minimum of "Direct3D 9 Drivers without Pixel Shader Version 3 Support" (as a piece of Microsoft documentation calls it), for which the requirements for using vertex declarations include that the declaration must map precisely to an FVF. Is this a model not worth supporting any more? (Again, this is what my previous was-high-end-at-the-time laptop was capable of.)

Eh, just checked my girlfriend's new-low-end laptop and it supports DX9 and puxel shader 3, so I guess it probably would be okay to stretch my low-end support up that far.

That said, I'm very unlikely to need or want any of the really clever stuff for my project - it's pretty much comprised of 2D stuff (some of which is made of basic 3D to produce a "Flashback" sort of look). As such I barely even need texture mapping (except as used for sprites), and certainly bump mapping would be ridiculous in this context.

Edit: But I should probably learn shaders anyway because my backburnered project will certainly want some of that prettier-looking stuff.

We still target PS 2.0 graphics cards at work and while it has its limits, I can think of a myriad of cool effects I could do in a 2D game that would be trivial to implement using shaders and nightmarish to implement otherwise. I think if you just learn a little bit of what shaders are capable of and realize how easy they are to manipulate, you will suddenly have tons of ideas that you will want to squeeze into your game :)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply