Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

apatriarca

Member Since 03 Jul 2006
Offline Last Active Yesterday, 06:26 PM
-----

#5064406 QEF's and the SVD decomposition.

Posted by apatriarca on Yesterday, 02:58 AM

There are a few references to papers doing that truncation. It seem however that they have zeroed out all singular values less than some threshold (something like 0.001*sigma_1 where sigma_1 is the largest singular value). It is actually quite common to discard the smaller singular values. SVD is indeed often used to extract the most important "components" of a system reducing its dimension.




#5064160 Player Jittering with Camera Follow

Posted by apatriarca on 23 May 2013 - 08:46 AM

You have misunderstood my suggestion. Let suppose the player is moving 1 pixel in some direction. Since (playerPos - camPos)*strength is not related to the player movement, it can be any value. In particular, it may rounds to 2 pixels in the same direction. The result is the player moving one pixel in the wrong direction. In the next frame the player will move of 2 pixels and the camera of some other amount and you now see a jitter. The jitter is caused by the difference between the camera position and the player position not being a monotonic function. My suggestion is thus to make it monotonic by clamping the camera position so that it does not move faster than the player. When the player is still you clearly have to catch the player if you do not want the player to exit from the screen.




#5064150 Player Jittering with Camera Follow

Posted by apatriarca on 23 May 2013 - 08:13 AM

I saw that code but assumed you have updated it to make the camera movement relative to the on-screen player position. The problem is in my opinion that the camera may sometimes need to move faster then the player to catch it. A possible solution may be to clamp the camera movement to the player movement on screen when the player is moving (i.e. its velocity is non zero).




#5062113 Coefficients for bezier curves

Posted by apatriarca on 15 May 2013 - 02:12 PM

To get a point in a Bézier curve the standard method is known as De Casteljau's algorithm. You iteratively linearly interpolate all control points until you find a single point. This is more robust than evaluating your formula. It is also useful to get a better geometric intuition. You may also be interested in the Horner's Method which is a more robust way to evaluate your polynomial. You write C + t*(B + t*A) instead of C + t*B + t*t*A in the quadratic case.

 

The derivative of a Bézier curve is a lower degree Bézier curve. The derivative of a quadratic Bézier curve is thus a segment and of a cubic Bézier curve is a quadratic Bézier curve. The proof use the following result on the Bernstein polynomials (used to define the equation of a Bézier curve).

 

clnba7b.png

 

The control points of the derivative curve are indeed the points a9lcbze.png for all i from 0 to n-1.

 

If all you want is however to get some bounds on the curve, a Bézier curve also have the property to be contained in the convex hull of its points. It can be useful to easily discard curve pairs for collision for example. There also exists interative methods to compute intersections of Bézier curve using this method (or something similar).




#5062028 Coefficients for bezier curves

Posted by apatriarca on 15 May 2013 - 06:50 AM

You start from the parametric Bézier curve formula and rewrite the terms until you obtain the desired formula. This is simple algebra, nothing complicated. For example, for the quadratic case:

 

acv2qqk.png

 

The derivation in the cubic case is similar. But I have always found the Bézier formula a much more useful formulation. Why do you want the coefficients of the polynomial?

 

EDIT: corrected the formula..




#5059443 Dual Contouring and QEF's

Posted by apatriarca on 05 May 2013 - 06:19 AM

http://en.wikipedia.org/wiki/Givens_rotation




#5059439 'Fixed Timestep' wrap around problem

Posted by apatriarca on 05 May 2013 - 06:06 AM

If you don't care about showing part of the ship on the other side, you can simply test the ship position with each edge and then teleport both the new position and the old one to the other side of the screen. In this way the ship seem to enter from the edge. Alternatively you can implement the wraparound logic after the interpolation step, i.e. storing an "absolute" ship position and then computing the modulus when computing the ship position on the screen. 




#5058710 Quaternion n00b

Posted by apatriarca on 02 May 2013 - 01:27 PM

The conversion is more theoretical than practical because an imaginary quaternion is really just a 3D vector. It is something in the form xi + yj + zk. Moreover, it is possible to use the properties of imaginary and unit quaternions to optimize the rotation formula to make it more efficient. In your code you may thus simply have a something like q.rotate(v) where q is quaternion and v is a 3D vector. 

Quaternions, euler angles, matrices, axis-angle.. are different objects used to represent the same thing: a linear map from a 3D vector space to himself preserving distances and orientations*. The representation may change the way you see and interpret a single rotation, but the rotation itself is just a map from a vector to another. When you transform a quaternion to a matrix, the map remains the same, but you can now combine this transformation with translations, reflections, scalings..

* Note that I have written a linear map and not an affine map. Otherwise the set would also contains translations.




#5058648 Quaternion n00b

Posted by apatriarca on 02 May 2013 - 10:06 AM

* To rotate a vector, does that vector need to be normalized?  It also seems that I do not convert the vector to be rotated into a quaternion.  It is just (vx, vy, vz, 0).  But then after multiplication with the quaternion and inverse, I convert the result from the quaternion back to a vector? 

To rotate a vector you have to convert it to an imaginary quaternion, i.e. a quaternion with the scalar part equal to zero and vector part equal to the vector you want to rotate. After the rotation you have to convert the quaternion back to a vector. But this is more conceptual than practical. You usually directly implement the logic of the rotation on vectors.

 

* I have examples of turning a quaternion into a matrix, but when is this necessary?  Do I convert the rotation into a matrix and multiply that by my current matrix?  What happens to vectors multiplied by this matrix?  Do they come on quaternions?  It is very confusing.

Quaternions are a more compact representation of rotation and they are more convenient for interpolation. However, they are usually converted to matrices to compose the rotation with other transformations (like translation or scaling). Vectors multiplied by this matrix are transformed as usual. There is no difference between this matrix and another rotation matrix computed in a different way.

 

* If I want to rotate my planet based on the user clicking and dragging the mouse, I don't understand what the code should do.  What vector becomes the quaternion?  What vector is rotated by the quaternion?  How do I take the result and rotate the planet?

You usually define two points on the planet and then compute the quaternion which transform the initial point in the final point. The axis is usually computed using a cross product of the two vectors from the center of the planet through the two points and the angle is simply the angle between the two vectors.




#4997354 What is a (Finite) State Machine? Why are they useful for game dev?

Posted by apatriarca on 04 November 2012 - 06:18 PM

A finite state machine is a quite general and abstract model for something whose behaviour can be described in terms of "states". There exists several different implementations and versions (they can be deterministic or not, they can be event based or not..). The use of FSMs is not motivated by efficiency or clear coding. These things depends on the specific implementation. FSMs are used because they can often model complex behaviours using a small and easy to understand description.


#4994771 Is it possible to draw Bezier curves without using line segments?

Posted by apatriarca on 28 October 2012 - 11:21 AM

I do not know special algorithms outside lines, circles, ellipses and conic sections. However, I think any "midpoint algorithm" to rasterize a curve defined by the implicit equation f(x,y) = 0 follows the following steps:
  • Choose an initial point
  • Choose the two candidate next points (from the points adjacent to the current one) based on the derivative of the curve at the current point
  • Evaluates the function f at the midpoint of the two candidate points
  • Choose the next point based on the sign of the value computed at 3
  • Repeat steps 2-5 until the last point is rendered
This general algorithm comes from my general understanding of the algorithms and not from some reference. However, looking for relevant papers on Google I have found "Rasterization of Nonparametric Curves" by John D. Hobby. I haven't read it but the abstract is the following:

We examine a class of algorithms for rasterizing algebraic curves based on an implicit form that can be evaluated cheaply in integer arithmetic using finite differences. These algorithms run fast and produce “optimal” digital output, where previously known algorithms have had serious limitations. We extend previous work on conic sections to the cubic and higher order curves, and we solve an important undersampling problem.




#4994675 Is it possible to draw Bezier curves without using line segments?

Posted by apatriarca on 28 October 2012 - 06:04 AM

All midpoint algorithms describe the curves with an equation in the form f(x, y) = 0 (with integer or rational* coefficients). A Bézier curve is not in this form. It is a parametric equation in the form (x, y) = P(t). However, it is always possible to transform a Bézier curve to the required form. In the case of a quadratic (or maybe also cubic) curve it may be practical. In general it is probably easier and faster to simply use the subdivision idea. Note that a quadratic Bézier curve is an arc of parabola, so you need an algorithm to draw it if you want to draw a quadratic Bézier curve.

* A polynomial with rational coefficients can be easily converted to a polynomial with integer coefficients by multiplication by an integer constant.


#4991129 Game of life issue

Posted by apatriarca on 17 October 2012 - 08:32 AM

You have defined field as an array of booleans and tf as an array of integers. They have different types and probably also different sizes.


#4990980 High-poly model XNA 10 FPS !

Posted by apatriarca on 16 October 2012 - 08:19 PM

You can draw much more than 300k polygons at once. How are your meshes loaded and drawn?


#4990976 MOBA in C# XNA

Posted by apatriarca on 16 October 2012 - 08:07 PM

If you are really having so much problems in starting coding for this project, maybe you should consider starting with a simpler game. Alternatively, you can try to use something like Unity or UDK which simplify some coding tasks and let you concentrate more on the content. Depending on your objectives, these may be better choices.

I don't know any open-source DOTA/MOBA game or tutorial. I would probably try to make a small game prototype showing some basic map and implementing the main gameplay features (basic player control, the creation of the waves of non-player controllable units..). Start from some simpler game and build incrementally.




PARTNERS