A branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space.

learn more… | top users | synonyms

4
votes
2answers
1k views

How do I use the dot product to get an angle between two vectors?

I am learning to use normalized vectors in my games. I've learned that in order to know the angle between two vectors, I can use the dot product. This gives me a value between -1 and 1, where 1 ...
4
votes
2answers
844 views

Repairing back-facing triangles without user input

My 3D application works with user-imported 3D models. Frequently, those models have a few vertices facing into the wrong direction. (For example, there is a 3D roof and a few triangles of that roof ...
4
votes
2answers
336 views

a flexible data structure for geometries

What data structure would you use to represent meshes that are to be altered (e.g. adding or removing new faces, vertices and edges), and that have to be "studied" in different ways (e.g. finding all ...
4
votes
1answer
3k views

How do I find rotation in 3D based on a vector/normal?

I've been playing with Blender and Python, doing basic things like accessing vertices/normals,etc. I can get the normal of each face of a mesh. I was wondering, how can I get the rotation of a face ...
4
votes
3answers
2k views

How can I draw a quad in wireframe with modern OpenGL, without rendering the interior bisecting edge?

I want to draw a quad (not two triangles). I actually know that triangles are faster, as I answered this question. But let's say I am building a 3D modeling tool. It makes sense to draw a quad for ...
4
votes
1answer
357 views

Running geometry shader only once

(Unfortunately couldn't find the answer myself) Does a neat way to cache the geometry shader results in Direct3D10 or OpenGL exist? (preferably Direct3D10). I'm building my geometry based on texture ...
4
votes
3answers
334 views

How to get distance from point to line with distinction between side of line?

I'm making a 2d racing game. I'm taking the nice standard approach of having a set of points defining the center of the track and detecting whether the car is off the track by detecting its distance ...
4
votes
2answers
466 views

Allowing a player to walk up and down slopes without resistance

I am trying to implement a platformer where both the player and the level are made up of arbitary polygons. One requirement is that the player can stand still on slopes, and walk up and down them ...
4
votes
2answers
1k views

What is a good way to determine if a vector is between two other vectors?

I could operate with the angles, but I do not have the angles calculated yet (and would like to avoid having to do that). It would be possible to calculate and cache the local-coordinate-frame angles, ...
4
votes
2answers
437 views

Geometry vs sprites

I'm developing an android game, where the enemies are geometrical shapes. Performance is a main goal for me so I was wondering if defining shapes directly in OpenGL would be more efficient than using ...
4
votes
3answers
886 views

scanline filling a trapezoid

I have computed the four corners of the viewable bit of 2d map in my 3d view. So I know the trapezoid that is visible, and I want to 'visit' these tiles in my map. So my algorithm is basically a ...
4
votes
1answer
402 views

rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise?

I've got a game object i need to rotate. It's current angle is player.rotation, the destination is targetAngle, both in degress, 0 to 359. I've got a function named rotateDirection(float sourceAngle, ...
4
votes
3answers
1k views

Point line collision reaction

I am trying to program point line segment collision detection and reaction. I am doing this for fun and to learn. The point moves (it has a velocity, and can be controlled by the user), whilst the ...
4
votes
2answers
415 views

Intersection points of plane set forming convex hull

Mostly looking for a nudge in the right direction here. Given a set of planes (defined as a normal and distance from origin) that form a convex hull, I would like to find the intersection points that ...
4
votes
2answers
496 views

OpenGL, Offset and Camera Space

I was reading chapter 4 of the Arcsyntesis OpenGL tutorial when I came across this line in the GLSL shader. vec4 cameraPos = position + vec4(offset.x, offset.y, 0.0, 0.0); About it, the tutorial ...
3
votes
2answers
328 views

How to calculate direction from initial point and another point?

I'm making a simple game where I shoot things from a certain point on screen (A). I tap the screen and shoot the projectile from initial point(A) to the tap point(B). But I want the projectile to ...
3
votes
2answers
209 views

How to make a projectile align correctly with the entity that shot it

I'm developing a 2D game. In the game, all entities can rotate 360 degrees. Each entity holds an angle value, and every frame it is drawn rotated around it's center by it's current angle value. For ...
3
votes
3answers
1k views

Textureing subdivided Icosahedron in XNA, seam problem

*Look below for the updated source code* I have started to to make some different types of objects and create them by code in XNA. Right now I have finished the code for creating a Icosahedron. And ...
3
votes
2answers
170 views

What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?

I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library. To project a single vector (X,Y,Z) ...
3
votes
2answers
310 views

Find the next cell in a grid from a point and direction

I'm trying to solve a very simple problem but I'm unable to come-up with an efficient solution so far. What I'm really trying to do is voxelize triangles in a three dimensional environment but I'll ...
3
votes
3answers
337 views

Throwing a ball and estimating its path using a Physics engine

The problem: A player entity wishes to throw a ball from a known position with a known initial velocity. The surrounding environment contains physical objects that can alter the trajectory of the ...
3
votes
1answer
124 views

Vertices shaking with large camera position values

Basicly when i set the position of my camera (my character in game) to a high value, the geometries seems to be shaking, the higher the position value, the more they shake. On low position values you ...
3
votes
2answers
615 views

Decomposing a concave mesh into a set of convex meshes

I'd like to be able to decompose a concave mesh into a set of convex meshes for 2 reasons: Transparent rendering Physics shapes Is there an algorithm that takes a set of triangles (concave) as ...
3
votes
2answers
1k views

Displaying (3D) objects' name above them

The Elder Scrolls: Morrowind has a rather interesting way to display each focused objects' name. It's all a bit fuzzy in my memory right now, but the most important part I remember perfectly: the ...
3
votes
1answer
326 views

Explain this line segment intersection code

I've been reading this article on pathfinding over polygon meshes using line-of-sight, and in the article are several code snippets. One of them, the one I'm trying to understand, is a simple function ...
3
votes
1answer
1k views

Generating spherical world from heightmapped terrain

I am using a standard heightmapped procedural terrain in my project. However, I want the terrain to appear spherical when the user zooms out. This is an attempt to simulate the appearance of a ...
3
votes
1answer
547 views

How do I render a filled and stroked path using OpenGL?

I want to render a 2-dimensional geometric path consisting of Bézier curves and straight lines. Paths can be concave. What is the most efficient way to draw this using modern OpenGL? Can I do this ...
3
votes
3answers
430 views

Adding tolerance to a point in polygon test

I've been using this method which was taken from Game Coding Complete to detect whether a point is inside of a polygon. It works in almost every case, but is failing on a few edge cases, and I can't ...
3
votes
1answer
100 views

How can I animate characters' static-geometry eyes?

Here's a Nintendo example: Specifically, the animation of the pupils seems not to animate the geometry. How is this done?
3
votes
1answer
263 views

Converting between Spiral Honeycomb Mosaic and axial hex coordinates

There seems to be quite a lot of logic in dealing with hexagonal grids using a system of axial coordinates like the one described here. In doing some reading about hex grids, though, I ran across the ...
3
votes
2answers
247 views

How to generate slopes that meet the plane, is using collision detection a good idea?

I have a terrain, which is defined by mesh. And there are a lot of other polygonal faces scattered throughout the terrain, they can be located above, or below or cutting through the terrain. You can ...
2
votes
2answers
1k views

How can I transform a point from world space to object space?

If I have an object space described by transformation matrix that should be applied to object to transform it to world space, what I have to do to transform point (world space) to that object space. ...
2
votes
2answers
157 views

Calculating specific coordinate along a path

Let's say I have a path comprised of a sequence of points that are connect by lines and arcs. The entire path has some specific length. Let's call that length 100. What would be the mechanism to ...
2
votes
1answer
438 views

How do I make a low pass filter (average of readings over time) for compass?

I'm making a prototype for android that pulls compass data from the phone. I want to stabilize it so it is less jerky, by taking the average of the last couple of readings. I have done this for ...
2
votes
1answer
508 views

2d grappling hook for platformer?

What are the options and mechanics for creating a grappling hook in a 2D game? In the prototype for this feature, the person runs around in a platformer world and can throw the hook at any wall, ...
2
votes
1answer
1k views

How do I find the circumcenter of a triangle in 3D?

I want to find the circumcenter of a triangle. Wolfram only shows how to find the circumcircle of a triangle in R2. How can I find the circumcenter of a triangle in R3?
2
votes
1answer
140 views

How do I compute the point of a triangle-ray intersection?

I have a line (the direction vector of the player) and a triangle representing the face of a model (so composed of 3 points). I can't find the mathematical operation to check if that vector is ...
2
votes
1answer
165 views

Why is there high performance hit with many meshes?

I am currently reading upon Geometry Instancing, as I want to render a lot of animatable objects on the screen. However I have come to a more fundamental question first: Why do I even need to use it? ...
2
votes
1answer
94 views

GL_TRIANGLE_ADJACENCY and glDrawElements

So I've not been able to find much online about how data should be stored for triangle adjacency. Currently I calculate my adjacent using half-edges (mention in an answer here). But do I store this ...
2
votes
1answer
596 views

Collision avoidance (AI)

Now my 3D model has complete AI behaviours, but my model has no collision avoidance while he is moving towards the player! Because of this, he gets stuck in front of 3D blocks sometimes. I think the ...
2
votes
1answer
258 views

Moving an object toward another object on sphere knowing their quaternions

I have a sphere centered in world origin. On the sphere surface I have two objects and I know their quaternions (rotation around sphere). Currently my movement works on Vector2 inputs (cannot change ...
2
votes
1answer
338 views

High school-level geometry book focusing on game dev for struggling student?

Here's the situation. My brother, a freshman in high school, isn't doing too well in geometry. Partially because he doesn't do half the work, but partially because he seems to have genuine ...
2
votes
1answer
655 views

Can Bullet Physics (or another 3d physics engine) use callbacks in my engine to check static geometry?

I'm wondering if it's possible to use or hack Bullet 3d Physics (or another free 3D physics engine) so that I don't need to "import" my static geometry into Bullet - instead I want to do it the other ...
2
votes
2answers
156 views

What is the purpose of glEdgeFlagv?

I know that what both glEdgeFlagv and glEdgeFlag do is toggle boundary edge status, but my question is why does the v version exist when the documentation specifies that the only difference is that ...
2
votes
2answers
45 views

Calculating angle a segment forms with a ray

I am given a point C and a ray r starting there. I know the coordinates (xc, yc) of the point C and the angle theta the ray r forms with the horizontal, theta in (-pi, pi]. I am also given another ...
2
votes
2answers
101 views

Connecting two arbitrary points with 2 lines

DEFINITIONS: Any "Point (x, y)" mentioned below is really the bottom left coordinates of a 1 unit by 1 unit rectangle. A "Line" is a defined as a rectangle that is either 1 unit tall and 1 unit or ...
2
votes
1answer
139 views

map the section of a procedurally generated surface on a plane

I'll try to be as clearer as I can. I have a surface on a 3D space which is not flat, it has hills and depths. My goal would be intersect it with a plane so that I can map the section of the surface ...
2
votes
1answer
162 views

Finding the normals of an oriented bounding box?

Here is my problem. I'm working on the physics for my 2D game. All objects are oriented bounding boxes (OBB) based on the separate axis theorem. In order to do collision resolution, I need to be ...
2
votes
1answer
58 views

Distort a quad with a World Matrix

Is it possible to distort a quad multiplying its vertices by a specific world matrix? See the picture to understand what kind of distortion I need: Please note, that the quad is in 3d space and I ...
2
votes
2answers
92 views

How can I test if a point is behind a polygon in 2D?

In order to improve the performance of my visibility graph generator I am trying to figure out the following. Given the image below; is there a way to find out if a point is 'behind' the polygon? For ...