Tag Info

Hot answers tagged

11

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. ...


9

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

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 ...


5

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 ...


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

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. ...


3

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

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 ...


3

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 ...


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 ...


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 ...


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

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

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 ...


1

Just for what concern GUI you can use UIToolkit. It's free and opensource and already have the methods that you need for doing simple gui movement (you can call the delegate with the Action onTouchUpInside). There are also a demo scene that reproduce what you want to do, and with this library you can make all your GUI's element with a single draw call ...


1

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 ...


1

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. ...


1

Take a look at curve interpolation - there's a few different types you can implement that will help smooth your curve. The more points you can get on that circle, the better. Storage is pretty cheap - so if extracting 360 close nodes is cheap enough (even at 8 bytes for position; 360 nodes is hardly expensive to store). You can place with some interpolation ...


1

I am currently working on a 3D wipeout clone, and my tracks are constructed using a Catmull-Rom spline from a small number of points. Catmull-Rom is good because it goes through the points, unlike Bezier which uses the points as a hull. In 3D it is more complicated because I use quaternions to control orientation at the points. But you can get away with ...


1

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 ...


1

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" ...


1

You can just fake this by finding the next point along the curve for some t increment, calculating the velocity vector to get to that point, and going from there. You'll need to tweak the t increment values to get smooth looking animation, but it'll work. Your objects should not be moving so fast that they'll skip over even sharp turns in your paths, even ...


1

I wouldn't bother with heavy maths to get that ellipse's equation. Here's what I recommend: Discretize your wireframe sphere (the usual way, using lattitude/longitude, or with a geodesic grid, or fancier). This gives you a list of 3D vertices; Transform them to screen space with the usual model-view-projection matrix; Then just render line segments between ...



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