Tag Info

14

Given a "root" curve, here's how you might generate block vertices. The root curve is in the middle, in black. Its control points are shown with red Xs. In short: I made a Bézier and sampled it (at a configurable rate). I then found the perpendicular vector of the vector from each sample to the next, normalised it, and scaled it to to a (configurable) ...

13

What would the W3C do? The internet has had this problem. The World Wide Web Consortium noticed. It has a recommended standard solution since 1999: Scalable Vector Graphics (SVG). It's an XML-based file format specifically designed for storing 2D shapes. "Scalable-what?" Scalable Vector Graphics! Scalable: It's meant to scale smoothly to any size. ...

10

Let A and B be two points on the black line. Let C and D be your blue segment. The sign of the z coordinate of cross product AB^AC tells you whether C is "left" or "right" of the black line. Similarly, cross product AB^CD tells you whether CD steers "left" or "right" of the black line. We don't really want to know whether it's left or right; all we want is ...

6

I think you have two problems: Non-symmetric control points Initially you start with equal distances between p0 to p1 and p1 to p2. If the tolerance angle between the line segments is not met, you move p1 and p2 forward, but keep p0 where it was. This increases the distance between p0 to p1 while keeping the distance between p1 to p2 the same. When you ...

6

Just Google closed bezier curve, there are plenty of useful results, including one that has a code example It's just like a open bezier curve, but for the "next" point on your last point, you use the first point.

6

There are multiple types of Splines, Bezier curves are one of them. Beziers aren't required to pass through the points that define them. From the looks of it, you want a regular cubic spline. It will ensure that the line crosses through the points specified. You can find some interactive examples of different types here. Also, I know you're busy being an 80'...

6

There is rarely a "right way" or "wrong way" when it comes to game design. There are many, many ways to solve this problem, but here are a few possible approaches to explore: Constrain the tunnel pieces to both start and end only in certain directions; for instance only along the axes. Then you just have to keep track of the offset from the beginning to ...

4

My answer will cover the following topics: How to form a suitable Bezier curve for turning a character or a car smoothly. How to maintain the same speed across the curve. How to change the angle smoothly during motion. This is suitable for any character in any 2d game with a top down view and with minor adjustments could be used for 3d games as well. ...

4

I would suggest something you haven't listed. Don't "create" your track at all. Rather, define it indirectly by placing a bunch of collide-able objects around where you want your track to be. Walls, old cars, wrecked buildings, semi-transparent-laser-beams... whatever you want. Heck, they don't even have to be visible. Then you can do your collision ...

4

Well, first of all you need a way to descrive such path. I would use some spline curves like Bezier curves or Hermite Splines to describe the path, and let the button follow that path once pressed. Unfortunately these curves are not available as is, you need to implement them. If you are interested here you can find 2 nice Herman Tulleken's articles(...

4

To get a smoother intersection of two paths, you could scale them up before intersection and scale them down after. I don't know if it's a good solution, but it worked well for me. It's also fast. In my example, I intersect a rounded path with a pattern I created (stripes). It looks good even when scaled. Here my code: Path mypath=new Path(<...

4

Your code contains a misleading comment: dstPath.quadTo(p2[0] , p2[1], p3[0], p3[1]); //create a curve to the third point through the second A quadratic bezier curve does not go through the second point. If you want to go through the second point you need a different type of curve, such as a hermite curve. You may be able to convert the hermite curves ...

3

As the comments ask: How are you representing your curve (i.e. "drawn line")? Anyway, any representation should be possible to convert into a list of points that represent the curve to some precision. It might look something like this: Naive algorithm Go through adjacent point pairs and check if they intersect with another point pair that isn't the same....

3

Look at polygon interpolation (http://en.wikipedia.org/wiki/Polynomial_interpolation) Basically, you take n equispaced nodes (optimal interpolation is not equispaced, but for your case it should be good enough and easy to implement) You end up with a polygon of order n which decreases the error between your curve if (<-- big if) your line is smooth ...

3

One area you might want to look into is CAD programs. They mostly use modelling techniques based on some version of parametric surfaces, curves and solids. The one thing that could be useful is the fact that most CAD programs can export their parametric based models to some sort of mesh based format like STL. There is usually some sort of "resolution" ...

3

Here is my try. The following algorithms are far from perfect, but they are simple and I believe you should start with this, check whether they work in your situation, and switch to something faster and/or more accurate later. The idea is the following: Sample the Bézier curve, find the nearest point on that sample Sample a neighbourhood around the found ...

3

You could create a Bézier curve that matches a sine (read this article for an example). Creating a Bézier curve from a sine, just to feed into CCBezierTo seems like a very counter-intuitive way of doing things though. I would skip CCBezierTo entirely and update the position of your sprite yourself. You could do so in your update method or implement a ...

3

A quick google search shows this to be a common problem with line strips. I strongly suspect the correct answer is: don't use line strips. Use triangles instead, and build your own geometry so that it doesn't have gaps. Moreover, according to this answer on StackOverflow, it sounds like line rendering is not rigidly specified by the OpenGL spec the way ...

3

Here's a technique I experimented with recently. My RenderMonkey prototype shows a section of badlands-style canyon, but the same principle should work in caves. The idea is to start with tiles that are generic, downright boring, with simple predictable edges so they're easy to line up without seams or gaps: These starting tiles could be shapes you've ...

3

Of the methods you listed, the pixel perfect is the only one which can solve your exact problem. That is, unless: The curved line is defined by an exact formula you can use in checking You create a series of boundary lines that Approximate the curved line, and check for the crossover of any vector. Hope that helps! :)

3

Detecting swipe curvature Treat the finger swipe as a polyline. Approximate its curvature, and use that as a multiplier for how much to “curl” the resulting shot either left or right. Let's say a swipe path has no curvature if it goes linearly from the start (the circle), to the end, or curvature value 0. I'll emphasise other swipes' differences to this ...

2

First of all we need to know how a beizer curve is generated. according to it's wiki page, a Quadratic beizer curve is a function of t stated as follow: In this formula t is a variable between zero and one and all other parameters are vector values (it means B(t), P0, P1, and P2 have values for x and y in 2D world). the next thing you should know is how to ...

2

Assuming start point is the green circle, and end point is the red arrow Compute the distance between the start point as DS and the black segment, and do the same for the end point (red arrow) as DE. If DS>DE, then the segment is pointing toward. if DE>DS, it is pointing away. If both are equal, the two are parallels. You can find how to compute the ...

2

Just use Bezier, giving 3 points in concave section, and another 3 in convex section, its easier than give all points to do a perfect sine, and the trajectory is the same.

2

If you don't need to worry about stuff running into it simply use Body.SetPosition(). If you do then make sure its a kinematic body so its not bumped off course. You should know the time delta the physics engine is going to be updated by. So we can use that to find a direction and velocity that will cause us to be where we want to be after the step has ...

2

You might want to look into Phong tessellation and PN triangles. The idea with both of these techniques is to start with an ordinary triangle mesh with vertex normals - just as you would build in a standard art pipeline. Smoothed vertex normals fake the appearance of a curved surface, and the goal of both of these techniques is to actually generate a ...

2

If the point of the conversion is for storage only, and when you render it back on the screen you need it to be smooth, then the highest fidelity storage you can get, while still minimizing the total storage required to persist a given curve might be to actually store the attributes of the circle (or an arc, rather) and re-draw it on demand. Origin. Radius. ...

2

Is there a reason for going for curves as opposed to straight lines? Straight lines are simpler to work with, and can be rendered efficiently in hardware. The other approach worth considering is to store a couple of bits per pixel, stating if it's inside, outside or on the outline of the shape. This should compress well, and might be more efficient than ...

2

This isn't a problem with line strips. OpenGL is doing exactly what you have asked it to do: draw a bunch of rectangles oriented to match the 'lines' you've provided, each with a particular width which you've also provided. The problem is that you're imagining that OpenGL is going to magically join up the corners of those rectangles into a single swooping ...

2

You could model your cave as a sequence of points, each with an associated size, with lines connecting them. Then treat each point and line as metaballs and metacylinders. This gives you a basic shape for your cave, to which you might want to start adding variation, such as by randomly offsetting vertices.

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