How can I move and rotate an object in an “infinity” or “figure 8” trajectory?

I know that the easiest way to move an object with the figure 8 trajectory is: x = cos(t); y = sin(2*t) / 2; but I just don’t know how to rotate it, lets says with a new variable r as rotation, how do I merge it into the above formula ? can anyone please … Read more

Rotate an object to face a point with glm::lookAt

I want to rotate an object to face a point, such as the monster look at the player. For that I’ve decided to use the glm::lookAt function. However the following does not yield good results: const glm::mat4 transformation = glm::lookAt(ghostPosition, cameraPosition, glm::vec3(0, 1, 0)); ghost.transformation = transformation; The ghost is correctly oriented to the player … Read more

2d Scale width and height based on distance

I’m drawing a health bar on top of each player. I transform 3d position to 2d. I would like to draw it smaller when distance increases. Any simple math for that? Let’s say bar width is 30 and height is 10 it looks good only on distance == 100. What formula should I use to … Read more

I’m trying to learn the “digital physics” required to do a floating network of spheres

If that is even what it is called. What I am trying to do it: Can someone please point me to towards a book or in vaguely the right direction? I don’t even know where to start or what physics/maths to read about? Answer What you’re looking at is called a force-directed graph. Google … Read more

OpenGL Camera causes spatial distortion

I’m trying to implement a 3D camera of the “Orbit around the origin” variety in a game engine I’m developing in order to learn about 3D graphics and game programming. I have a basic handle on the required math, and have implemented my own crude 3D math library and matrix stack (functionally similar to the … Read more

How do I build a matrix to translate one set of points to another?

I’ve got 3 points in space that define a triangle. I’ve also got a vertex buffer made up of three vertices, that also represent a triangle that I will refer to as a “model”. How can I can I find the matrix M that will transform vertex in my buffer to those 3 points in … Read more

Min/Max of two vectors?

This seems like a simple question, but i’m having trouble searching the internet for it. In XNA, during a collision detecting method, I would determin the minimum of some vectors. // Get the minimum top point Vector2 minTopPoint1 = Vector2.Min(topLeft1, topRight1); // Get the minimum bottom point Vector2 minBottomPoint1 = Vector2.Min(bottomLeft1, bottomRight1); // Get the … Read more

Approximating particles with with nebula

I have a 2d galaxy where each star is rendered a particle: I’d like to approximate it with nebula, so that instead of seeing lots of tiny dots from afar, users will see lots smooth light in the area. Something like this: I’m more interested in technology-agnostic solution which accurately resembles underlying particles. E.g. how … Read more

Perlin noise example the same on CPU as GPU?

I am looking for an example site with a Perlin Noise implementation in both CPU and GPU, that generates somewhat the same results in those two places. I see many CPU implementations of Perlin Noise, but they don’t match up with the GPU implementations that I found. The reason I need this is for physics. … Read more