Tag Info

Hot answers tagged

106

Metroid's just using tiles, nothing special going on there. Aquaria however is doing something rather clever. If you'll notice, a lot of those rocks on the bed get repeated several times. Here's one of the rocks for instance: It looks like they've just dumped sprites along the edges of their terrain. It's kind of like what Metroid did - a massive arsenal ...


25

Draw a line to infinity and count how many times you cross the shape (even or odd), not counting the segment where the creature lies. Then check whether the creature is going left or right of that line. In this example, we cross the shape twice (so even) and we go to the left. The result is immediate from this table: # Crosses | even | odd ...


9

I would advise that even if you are going to write all your own code, that you download Recast and build the sample application as it has visualisations that show the generated navmesh and it allows you to test the path-finding with a simple point and click interface. You can learn a lot just by playing with that. As you have already realised, there are two ...


9

With i going from 0 to n-1 inclusive: pointX[i] = ( sin( i / n * 2 * PI ) * radius ) + xOffset; pointY[i] = ( cos( i / n * 2 * PI ) * radius ) + yOffset; Edit: As Lars Viklund mentioned in the comments, this is only safe in languages like javascript in which integer division returns a floating point number rather than a integer. In other languages you ...


9

OpenGL wiki's pseudocode (as referenced by Peter Taylor, as well) is correct. What you want is the normal of the plane the triangle, quad or other polygon represents. All you need are two edges of any planar polygon that share a common vertex. The number of edges does not matter. All you need is to get enough information to define the plane, and then get ...


6

For MMO due to their nature, wide adoption is a must to survive. They need to have a window which enables them to run on mediocre pc. So, no matter how tech progresses forward, MMO should be always the least to take full advantage of it. And poly count doesn't matter too much, if you can cover this up with your art style and/or other visual stuff. For ...


5

There are tons of source snippets for a method that performs a test for "point inside polygon". The principle comes from Jordan's curve theorem for polygons (http://www-cgrl.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Octavian/compgeom.html). The naive way would be: having that method, call it PointInsidePolygon(Point p, Polygon poly): bool isInside = ...


5

The easy/naive solution would simply be to take your existing points, and for each point have a corresponding point that's at the same Y position but off screen. From there, create your polygon by taking, say, points 0, 1, 1's pair, and 0's pair and pass that to your DrawPoly method. Then continue on with (1, 2, 2's pair, 1's pair), etc.


5

Technically? Yes. It's no different to, say, a polygon with the shape of a D with 5 points viewed edge-on. A polygon is just a closed shape which has 3 or more vertices and edges. A shape with only two vertices is just a line. Meanwhile a shape with 3 vertices and only 2 edges cannot be a closed shape: most libraries would just join the first and last ...


4

Focusing on poly count and other rendering minutae is really putting the cart before the horse. Your question depends entirely on what client engine you're going to use, and so can't be answered. Onwards to predicting future hardware platforms. Many projects have been sunk by assuming that hardware speeds will always advance. Look at what happened during ...


4

I would loop through your array two points at a time, extrapolating two more points (by using the X value for each of the two and making the Y value 0) to give you the bottom of your shape. Pass those four points into ccDrawPoly() and repeat until you run out of array values. so, if you have say: P1 = (0, 25) P2 = (5, 30) P3 = (10, 20) P4 = (15, 25) for ...


4

On OS X, you can use PhysicsEditor. It is a tool for Box2D or Chimpmunk but there is a txt export for your need. The main difficulty is to find a mac. Note: there is a windows version too. But i didn't use it. Try it and add a comment if it is useful.


4

Yes, it's typical to convert into triangles. When reading the mesh in, it's simple to convert a quad into a triangle. It will depend on the format you're exporting to. For example, the format I use, Blender will export all the vertices, then it will export index information for triangles and quads. So it's a simple matter of arranging the indices to take a ...


3

Google "resting contact" -- physics engines typically handle it as an explicit state, rather than allowing objects to collide continuously, which causes jitter. Check many sources. There are a variety of approaches and none of them are easy, unfortunately. This paper serves as a good overview of all aspects of physics simulation, including resting contact.


3

The standard approaches are (pick one): Increase your boundary width AND/OR reduce the maximum speed of your bullet so that it can never jump through a wall in a single update (requiers a bit of Pythagoras to figure out the maxium distances / minimum boundary widths); Perform continuous collision detection (CCD), usually by raycasting to detect collision ...


3

They use the same models again and again in Trine. They use a lot of batched rendering. Because of their unique camera angle, a lot of the meshes get culled with frustum culling. The levels are hand-made by artist. They are just very good at re-using the same models over and over again.


3

PIX is a fairly low-level data collector/analyzer for D3D. PIX can examine the state of device objects -- including vertex and index buffers -- from within an experiment. The PIX tutorials page has a document on examining mesh data. The tutorials tend to build on each other so it's probably a good idea to at least skim them from the first one. It's not a ...


3

InkScape is a good choice for vectorial images. Size your document to 1m x 1m... Add the bitmap... Draw the polyline... Save as .svg or .xaml document... whose are text based... Develop a light parser to load the data


3

Your question may mean two diffrent things, and for both there is some solutions: You have both the texture and the polygon and know you want to know how to store and draw your polygon. Storing a 2D polygon is a real easy job, you only have to store all the vertices in order in some array. and to apply a texture to your polygon you need equal number of ...


3

You will need an active edge list, which contains a list of all polygon edges intersected by the current scanline. You will also need an in/out flag for each polygon on the scanline. The flags are toggled on/of as you cross an edge for a polygon. The rules are drawing for each pixel along a scanline are; no polygon flags are 'in', then draw background ...


3

I think you'll need to do it in two or three steps: For converting a raster image to polygons you can use pre-existing software like http://en.wikipedia.org/wiki/Potrace Optimizing the result from that to get the best possible result with a specific number of polygons I believe is much harder. However efficiently optimizing an existing mesh down to a lower ...


3

Calculate the center point of your shape. Pick the most distant edge of your shape from the center. (Picking the most distant edge ensures that you don't start from an inverted, concave part of the shape, which would result in getting the clockwise/anticlockwise determination backward for the whole shape) Determine which direction along that edge is ...


2

A common technique for creating cutaways or cross-sections is to use an arbitrary clipping plane to exclude a part of the body. By cloning the body and clipping an opposite part of the body you end up with two pieces of something that appears to have been sliced in two. You would then have to use the stencil buffer to 'fill in' the clip edges, and create ...


2

I'm successfully using this for quads / triangles. Loop through each face, and pass in 3 verticies. If you have a quad ABCD pass in ABD. For example for the front facing face on this cube, I would pass in, v2, v3, v0 // cube /////////////////////////////////////////////////////////////////////// // v6----- v5 // /| /| // v1------v0| // | | ...


2

I don't think you can do this directly using SFML. It looks like the shape class will not support texture mapping; allegedly it is a planned feature for the next version (discussion). Depending on the kind of visual effect you are going for -- I didn't find your description entirely clear -- you could do something like using a shape to mask a sprite, as ...


2

The performance of a game does not usually get bottlenecked by poly count first. This is one of the reasons that pixel shaders have been gaining speed faster than vertex shaders over the past several years. To put it somewhat bluntly: If you are asking about how many polygons your models should have, then you should not be working on an MMO. MMO production ...


2

r2d2rigo's answer is almost correct. Here is the correct matrix code to set up a BasicEffect that matches SpriteBatch (from Shawn Hargreaves' blog): Matrix projection = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); basicEffect.World = Matrix.Identity; ...


2

Well, you could literally generate a Voronoi diagram. That is, produce some random points in the rectangle, find their Delaunay triangulation (google for the algorithms for this), then generate the Voronoi polygons from the triangulation. The Delaunay triangulation is the dual graph of the Voronoi diagram, so there will be one Voronoi vertex for each ...


2

I think you've got the right idea, but the execution is going to be immensely challenging. I'm presuming when you say 'in an SVG file' you mean that the shape is defined by one (or more — your sample figure has an internal hole!) stroke paths. Unfortunately, SVG paths can be remarkably complicated, with both quadratic and cubic Bezier curves and ...


2

Try doing a line intersection with each red line. In pseudocode: // loop over polygons for (int i = 0; i < m_PolygonCount; i++) { bool contained = false; for (int j = 0; j < m_Polygon[i].GetLineCount(); j++) { for (int k = 0; k < m_PolygonContainer.GetLineCount(); k++) { // if a line of the container polygon ...



Only top voted, non community-wiki answers of a minimum length are eligible