I need ideas for two problems I have.

1. I need a way to distinguish between two areas in my game. the orange and blue in the image illistrates the way in which I want them distinguished. between the “in”(orange) and the “out”(blue).

2. I need a way to fill the “out”(blue) area with a new object(s).

[clarification] I used ms paint to add the orange and blue on the second image.

the way the game works is, the player draws lines to “trap” the computer controlled object into smaller and smaller areas. I’m sure many of you have played similar games before.

once I’ve solved the first problem, I have a cpu heavy solution to the second. the player moves on a grid. the grid squares are .05 X .05. since the closest the lines can get to eachother is .05, I can fill the area with .05 X .05 planes or cubes. the result, however, is that you end up with THOUSANDS of planes. I’m not sure that most computers could handle that, but I haven’t tried yet. I would prefer something less cpu heavy.

what it looks like without ms paint


edited in paint to add orange and blue


Attachments


It depends on what exactly you mean by “distinguish” and how your scene is setup. I would think that you could just have a large orange plane and then add blue planes on top of it.

If your trying to distinguish if a given point is inside or outside the blue area, then you could cast a ray downward from the point you’re checking. If it hits the orange plane, it’s in the orange area. Otherwise it’s in the blue area. Other than that I guess you could implement a PIP algorithm if you have a nice representation of your blue areas.

Here’s something I came up with:

  1. Traverse the edges of the shape in a clockwise manner
  2. When you come to a left turn, add a horizontal (or vertical, just stay consistent) edge from the point to the next edge it meets (this isn’t as easy as it sounds)
  3. Repeat step 2 until you’ve traversed the whole shape

When finished, the shape will be divided into a minimum number of rectangles. For each rectangle just add a plane and scale it appropriately.

From the look of things I guess you’re trying to make a game like Qix.

oops, I should have clarified that the image was post processed in pain to make part of the area orange and part blue. I added a “before” image so you can see what I mean.

the “PIP algorithm” looks promising for my first problem.

for your idea for my second problem, I know it’s a pain in the butt to try to edit meshes in the game engine. unless I’m mistaken, you have to either use an api someone created or make your own. You did, however, give me an idea.

Thanks for the inpute! :smiley:

You don’t have to modify meshes at all. I assume you have your shape represented a list of points. You only need to do operations on these points. No game objects or meshes are involved until you add and scale the planes at the very end.