Arithmetic, geometry, calculus, and all else which resolves the number-crunching necessary in a game. Math questions are those that deal with the formulae and calculations used by the game in various parts.
6
votes
2answers
458 views
Calculating and detecting curves
How can I detect the 'steepness' of a curve? For example, if the user swipes their finger across the screen in a curve, what's the best way of detecting whether the curve is almost a semi-circle, or ...
6
votes
2answers
2k views
How to think about 2D scaling/rotation transformations
This is a kind of embarassing question to me since I'm getting more in-depth with XNA but some times my way of thinking about things in my head contradicts an example and I need to re-think it to make ...
6
votes
4answers
203 views
Interstellar Economic Simulation
I'm designing a game reminiscent of Elite or Escape Velocity, those old space trading games, where you play a traveling merchant in space.
I'd like to have the game's economy at least resemble a real ...
6
votes
2answers
322 views
How can you extract orientation from a transformation matrix?
I have a 4x4 transformation matrix M, and I want to find out the shape of a sphere when transformed by M. (Sphere is at the origin and has radius 1.)
I know I can find the center by just multiplying ...
6
votes
5answers
2k views
Changing coordinate system from Z-up to Y-up
Blender's coordinate system is different from what I'm used to, in that Z points upwards instead of Y. What would be the simplest way of converting all the world data (so that all animations, texture ...
6
votes
4answers
983 views
Implementing 2D CSG (for collision shapes)?
Are there any simple (or well documented) algorithms for basic CSG operations on 2D polygons?
I'm looking for a way to 'add' a number of overlapping 2D collision shapes. These may be convex or ...
6
votes
3answers
470 views
Can a straight line be called a polygon?
According to the definition of Polygon, If a Poly-line's first and last points are connected then it is called Polygon. See the image below. I have P1, .... P5 Polyline. If I draw a line from P5 to ...
6
votes
3answers
560 views
How can I do fast Triangle/Square vs Triangle collision detection?
I have a game world where the objects are in a grid based environment with the following restrictions.
All of the triangles are 45-90-45 triangles that are unit length. They can only rotate 90°. The ...
6
votes
2answers
827 views
Vector games (Wireframe, Elite-like) theory and implementations?
I'm interesting in knowing more about how vector games like Elite and Star Wars Atari were built from grounds up. The question is not how to implement vector graphics with modern 3D APIs like OpenGL ...
6
votes
2answers
687 views
What is eigenvalue decomposition and why would it be useful in games?
In various math libraries developed for game engines, I see 2x2 and 3x3 square matrices having this function (along with some helper functions). I tried to find information regarding it but did not ...
6
votes
2answers
165 views
How do you calculate if a line is facing a curve?
Given the 2 points describing a line segment, and the 3 points describing a quadratic bezier curve, how do you calculate if the line is facing towards or away from the curve?
The line has a fixed ...
6
votes
1answer
1k views
Atmospheric Scattering
I'm trying to implement atmospheric scattering based on Sean O`Neil algorithm that was published in GPU Gems 2. But I have some trouble getting the shader to work. My latest attempts resulted in: ...
5
votes
5answers
824 views
Are game programmers aware of all the physics derivatives?
I am trying to study XNA for game programming. XNA has many methods that can simplify developer's life, such as reflecting the vector when it hits a solid plane.
I know these are good and developers ...
5
votes
5answers
294 views
How to convert a number from one min\max set to another min\max set?
I'm doing terrain generation and I have a perlin library that is giving me random numbers between -1 and +1. I want to convert this to the scale of 0-255. What is the proper way to do this?
5
votes
3answers
259 views
How can I change the acceleration of an object to arrive at a particular time?
I'm trying to write some code to change an acceleration factor so a ball will arrive at a destination in a desired time.
The problem is I don't know time (t) but I do know I want it to arrive at (t - ...
5
votes
3answers
526 views
For normal mapping, why can we not simply add the tangent normal to the surface normal?
I am looking at implementing bump mapping (which in all implementations I have seen is really normal mapping), and so far all I have read says that to do this, we create a matrix to convert from ...
5
votes
3answers
648 views
What's a pre-multiplied 4x4 matrix?
I'm using a 3d game engine, that uses a 4x4 matrix to modify the camera projection.
The matrix is in the regular 4x4 format:
r r r x
r r r y
r r r z
- - - zoom
The description for the ...
5
votes
1answer
676 views
How to calculate new direction after sprite collision
The scenario as you can see in the picture. A ball will be hitting a surface and I want to fairly correctly get the new angle after the collision..
I expect to know the X,Y coordinates of the lines ...
5
votes
4answers
344 views
How would one generate a texture for cracks in different materials?
I would want to have the ability to simulate different variables like brittleness, or other variables to get varied end results.
I would mainly need to generate impact cracks, so it would need to ...
5
votes
1answer
381 views
What is the best way to limit player movement?
I'm currently programming a 2d game where the player moves around on a rectangular playing field. The player has a direction and a velocity. What is the best way to limit the player's movement so ...
5
votes
3answers
456 views
Determining the probability of a successful attack based on the equipped weapon?
Take this example, a player has a sword composed of the handle and a blade. Together, they generate a strength of X and that combination adds qualitative attributes (induce more damage to fire ...
5
votes
1answer
257 views
What is the point of this hard-coded vector when calculating luminance in glow/bloom effects?
I have looked at two different vertex shaders that calculate luminance and both use a "magic" vector that I'm not sure the meaning of the the actual values. For instance:
const mediump vec3 ...
5
votes
1answer
954 views
Rotate object to face player
This is probably a simple vector question, but I'm not sure how to do it.
I have an object at vector position (ox,oy). Potentially every update, the user walks around the screen, and will be at ...
5
votes
2answers
2k views
How to detect 2D line on line collision?
I'm a flash actionscript game developer who is a bit backward with mathematics, though I find physics both interesting and cool.
For reference this is a similar game to the one I'm making: Untangled ...
5
votes
2answers
280 views
How to generate random points on the surface of a quadrilateral
Alright, I'm sure there has to be a simple way to do this but it eludes me at the moment.
I want to be able to generate random points on the surface of a quadrilateral in 3D space. (Defined simply as ...
5
votes
1answer
738 views
Zooming and panning a camera simultaneously causes a swooping effect
In a 2d game, I have a basic camera class. The guts of the class creates a transformation matrix that is later passed to the Begin() method of a SpriteBatch. The transformation is done like this:
...
5
votes
2answers
376 views
How to render metaballs?
How to render metaballs?
I am a Python programmer familiar with the Panda3d and Blender3d APIs. My math kinda sucks, but I know enough to write game logic code and procedural model generation code, ...
5
votes
2answers
132 views
Drawing a line from a random coordinate through a given point
When the mouse button is clicked, I want to draw a line from (0, random) to (640, y) which goes through the click position.
How would I calculate the y coordinate of the end of the line?
5
votes
2answers
376 views
Is there a better way of determining direction to turn?
You have an entity A that you want to turn towards another entity B. One way to determine the direction to turn is to compute the cross-product of the direction vector of A with the vector from AB. ...
5
votes
2answers
329 views
How can I generate a navigation mesh for a tile grid?
I haven't actually started programming for this one yet, but I wanted to see how I would go about doing this anyway.
Say I have a grid of tiles, all of the same size, some traversable and some not. ...
5
votes
2answers
458 views
Manipulating a free camera
I have a camera class in my code which stores two 4x4 matrices. One for the view matrix and one for the projection matrix. Originally, I had two floats in the class for pitch and yaw and these were ...
5
votes
2answers
962 views
top down game - checking, drawing enemy's line of sight area with obstacles
Examples of what i'm going to need:
I'm using cocos2d to draw a CCTMXTiledMap, on those tiles i'll have to draw the LOS cone.
How would i test if the player is within that cone, taking obstacles ...
5
votes
1answer
202 views
A* for non grid network
For my specific case, I am trying to find a path finding implementation similar to what described here.
I could see reference implementation for A* and HPA*, but I wonder how to extend A* to simple ...
5
votes
2answers
265 views
How to make my character slide (not bounce) off a slope
My character needs to slide and not bounce off a slope.
The solutions I found here use a Reflection vector, but they make my character bouncy when they run downwards a slope.
var reflectVector = ...
5
votes
1answer
1k views
How do I calculate the normal of a plane defined using homogeneous coordinates?
I can define a plane in 3D space using three 3D points (p0, p1, p2) that all lie in the plane and that form a non-degenerate triangle. Calculating the normal of the plane is as simple as calculating ...
5
votes
2answers
807 views
Arrays for a heightmap tile-based map
I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:
I've managed to store tiles and corners in memory but I'm having troubles to get ...
5
votes
3answers
3k views
building a game for different resolution phones
I am starting some tests for building a game on the Android program.
So far everything is working and seems nice.
However I do not understand how to make sure my game looks correct on all phones as ...
5
votes
2answers
146 views
Plotting entities on a radar
I'm trying to build a radar system like the one in the original X-Wing games. The way it works is that there are two circular radar systems, one for behind the ship, and one for infront.
So, I've ...
5
votes
1answer
492 views
Why doesn't Unity's OnCollisionEnter give me surface normals, and what's the most reliable way to get them?
Unity's on collision event gives you a Collision object that gives you some information about the collision that happened (including a list of ContactPoints with hit normals).
But what you don't get ...
5
votes
3answers
769 views
Is it possible to map mouse coordinates to isometric tiles with this coordinate system?
I'm trying to implement mouse interaction in a 2D isometric game, but I'm not sure if it's possible given the coordinate system used for tile maps in the game.
I've read some helpful things like ...
5
votes
1answer
299 views
Predicting physics/trajectory for pool/billiards games
I'm thinking of making a quick proof of concept of a billiard-style game mechanic, where the player has perfect information of what is about to happen.
Here's a good example:
I'm only mildly ...
5
votes
1answer
4k views
OpenGL ES 2.0: Understanding Perspective Projection Matrix
Setting the Perspective projection matrix in Open GL (including OpenGL ES 2.0) has the following general format:
glm::mat4 perspective(float fovy, float aspect, float zNear, float zFar);
Notice the ...
5
votes
1answer
238 views
Realistic damage
I'm looking for a good way to simulate damage, for example a weapon firing at a ship it would calculate the damage depending on layer type, weapon type, angle and similar what i need is a way to to ...
5
votes
1answer
2k views
Ray Intersecting Plane Formula in C++/DirectX
I'm developing a picking system that will use rays that intersect volumes and I'm having trouble with ray intersection versus a plane. I was able to figure out spheres fairly easily, but planes are ...
5
votes
2answers
206 views
Robust line of sight test on the inside of a polygon with tolerance
Foreword
This is a followup to this question and the main problem I'm trying to solve. My current solution is an hack which involves inflating the polygon, and doing most calculations on the inflated ...
5
votes
3answers
197 views
Preventing ties
I'm working on a simple game to rate a users' preference among several styles. There are C classes, and the game consists of R rounds of comparison. At each round, the user is presented a ...
5
votes
1answer
1k views
Local to World coordinates in 2D and back
I'm getting back into hobby game programming after a long 4-year hiatus from college and I find that my understanding of coordinate systems is somewhat lacking.
I'm trying my skills at creating a ...
5
votes
1answer
342 views
How do I create weapon attachments?
My question is; I am developing a game for XNA and I am trying to create a weapon attachment for my player model. My player model loads the .md3 format and reads tags for attachment points. I am able ...
5
votes
1answer
384 views
Literature for Inverse Kinematics: Joint Limits and beyond
Recently I've been playing around with Inverse Kinematics and have been pretty impressed with the results. Naturally I want to take it further, but have no clue where to start. In particular, I would ...
5
votes
1answer
373 views
3D isometric depth sorting
How is it possible to depth sort tiles and objects in an isometric environments without any limitations? I've been researching this for a while now and there seems to be no publicly available answers ...