A branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space.
23
votes
1answer
753 views
How do you turn a cube into a sphere?
I'm trying to make a quad sphere based on an article, which shows results like this:
I can generate a cube correctly:
But when I convert all the points according to this formula (from the page ...
21
votes
4answers
1k views
Why does my object move faster at 45 degrees than at 90 degrees?
I have objects in my game that move faster at 45 degrees then at 90 degrees.
Each object has
Point (x,y) position
Vector2D (x,y) direction
Int speed
And what I do during a update is that new ...
19
votes
3answers
1k views
Is there a 3D equivalent of hex tile maps?
Probably the biggest advantage of a hex-based versus square-based map tiling is that the center of each hex has the same distance to all its neighboring hexes. Is there a similar shape that tiles this ...
18
votes
5answers
476 views
Moving CW or CCW?
Lets say we have a jagged shape:
And two creatures moving along it's outline.
Then we smooth the shape completely by pulling the corners out.
We get this:
It is easy to see now that Orange is ...
14
votes
4answers
450 views
Algorithm for creating adjacent triangles
I have a system where you can click once to place a node in a scene. When you place 3 nodes, it forms a triangle. When you place any future nodes, it creates a new triangle by joining that node to the ...
13
votes
2answers
2k views
How to find if circle and concave polygon intersect?
I have a polygon (sometimes convex, but often concave), and a bunch of circles with different radius. How can I find out if a circle is intersecting/overlapping with the polygon?
If it makes it ...
13
votes
3answers
318 views
How do you calculate the nearest point on 2 curves?
Given the points of a line and a quadratic bezier curve, how do you calculate their nearest point? .... Similarly, given the points of 2 curves, how do you get the nearest point?
11
votes
2answers
3k views
Are the Minecraft animations hardcoded into the game?
I would like to know how the animation system works in minecraft. I get a feeling that all the mobs are hardcoded into the game. Did notch really sit there and create the matrices for all the ...
11
votes
2answers
3k views
How do you programmatically generate a sphere?
Could someone please explain how it would be possible to create a sphere vertices, indices and texture coordinates? There is a surprising lack of documentation on how to do so and it is something that ...
10
votes
5answers
521 views
How would one determine the length of a path?
I have a game that requires each player to move along one specified path. I draw the path using Bézier curves. How can I determine the total real (not linear) length of the path and the distance that ...
9
votes
3answers
319 views
Are the first 3 parameters that describe a 3D plane actually a 3d vector?
A 3d plane is typically defined as a,b,c,d. Are a,b,c actually the x,y,z coordinates of a 3d vector, with d defining the rotation of the plane, something like axis-angle rotation data?
9
votes
2answers
324 views
How to limit click'n'drag movement to an area?
I apologize for the somewhat generic title. I'm really don't have much clue about how to accomplish what I'm trying to do, which is making it harder even to research a possible solution.
I'm trying ...
9
votes
2answers
6k views
converting a mouse click to a ray
I have a perspective projection. When the user clicks on the screen, I want to compute the ray between the near and far planes that projects from the mouse point, so I can do some ray intersection ...
8
votes
2answers
284 views
How do you calculate if 2 lines are facing toward or away?
Given the 4 points describing 2 line segments, how do you calculate if line A is towards or away from line B?
The 2 lines have a fixed length, and can be measured as distance from x1/y1 to x2/y2.
8
votes
2answers
875 views
How do I determine if one polygon completely contains another?
I have 2 polygons. I know the vertex coordinates of both polygons. What's the best way to check if one is completely inside the other? For example, the algorithm should only recognize the black ...
8
votes
1answer
2k views
Am I going to regret using a color based collision detection system?
I'm just getting started build my first game with XNA (I'm experienced with C# but not games).
I'm building a pretty simple top down 2d shooter. I read this tutorial on using a color based collision ...
8
votes
2answers
564 views
Arbitrary Rotation about a Sphere
I'm coding a mechanic which allows a user to move around the surface of a sphere. The position on the sphere is currently stored as theta and phi, where theta is the angle between the z-axis and the ...
8
votes
1answer
168 views
What are some ways to implement variable body shapes?
Games like Ryzom and the Sims allow players to have human bodies with different shapes: wide or thin, tall or short, big noses or small, etc. It seems to me that it'd be impractical to pre-generate ...
8
votes
1answer
365 views
How can I determine the first visible tile in an isometric perspective?
I am trying to render the visible portion of a diamond-shaped isometric map.
The "world" coordinate system is a 2D Cartesian system, with the coordinates increasing diagonally (in terms of the view ...
7
votes
1answer
2k views
Circle-Line Collision Detection Problem
I am currently developing a breakout clone and I have hit a roadblock in getting collision detection between a ball (circle) and a brick (convex polygon) working correctly. I am using a Circle-Line ...
7
votes
2answers
147 views
Intersect of vector and triangle side
I'm trying to create a triangular touch surface for iOS where the user can drag around a point inside this triangle. Using information from this page, it is easy to figure out if the dragged point is ...
6
votes
2answers
424 views
Perspective in early pseudo-3d games
Please take a look at the screenshot below, from the old classic Space Harrier. My question regards the curved perspective on the chequerboard 'ground'. It's got a strangely curved geometry (I ...
6
votes
1answer
1k views
Moving a particle around an Archimedean spiral at a constant speed
I want to move a particle in a spiral at a constant speed. Note that that is not a constant angular speed. This is proving rather difficult, and I'll go through my method so far below.
The spiral in ...
6
votes
3answers
377 views
Transforming a primitive tetrahedron into a primitive icosahedron?
I've created a tetrahedron by creating a BoundingBox and building the faces of the tetrahedron within the bounding box as follows (see image as well):
VertexPositionNormalTexture[] vertices = new ...
6
votes
4answers
982 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
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 ...
5
votes
4answers
245 views
Would like some help in understanding rendering geometry vs textures
So I was just pondering whether it is more taxing on the GPU to render geometry or a texture. What I'm trying to see is whether there is a huge difference in rendering two scenes with the same setup:
...
5
votes
1answer
633 views
How to perform simple collision detection?
Imagine two squares sitting side by side, both level with the ground like so:
A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if all of ...
5
votes
2answers
611 views
Geometry System of Populous: The Beginning
I want to to develop a game like Populous: The Beginning with my friend. But we could not find out what type of geometry they have used for the world.
We know that
- all tiles have the same size
- ...
5
votes
1answer
98 views
trapped inside a Graph : Find paths along edges that do not cross any edges
This is a graph based platformer level and the round shapes are creatures.
I am looking for a path traveling along edges that does not cross other edges(To simulate the creature crawling on the ...
5
votes
3answers
1k views
2D isometric: screen to tile coordinates
I'm writing an isometric 2D game and I'm having difficulty figuring precisely on which tile the cursor is. Here's a drawing:
where xs and ys are screen coordinates (pixels), xt and yt are tile ...
5
votes
2answers
846 views
Generating geometry when using VBO
Currently I am working on a project in which I generate geometry based on the players movement. A glorified very long trail, composed of quads.
I am doing this by storing a STD::Vector, and removing ...
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
6answers
243 views
How do I calculate distance from a point to a rectangle?
I have a 2D rectangle with x, y position, height and width, and a randomly positioned point nearby.
Is there a way to check if this point might collide with the rectangle if it is closer than a ...
4
votes
2answers
237 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
1answer
156 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
242 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
1k views
How do I align the matrix used in SpriteBatch and the matrix used in BasicEffect?
I'm writing a Windows tool that uses XNA and allows the user to place textures on the screen.
I'm using a 'camera' for the SpriteBatch used to draw the textures, e.g:
Matrix matrixForSpriteBatch = ...
4
votes
1answer
872 views
Creating similar effects of Geometry Wars in 2D only
I want to create a game with similar effects to that of "Geometry Wars"... for those who have never played the game, basically, massive amounts of 'bending' and 'warping' effects are done on the ...
4
votes
2answers
336 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
619 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
471 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
3answers
902 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
266 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
349 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
1answer
1k views
Morph a sphere to a cube and a cube to a sphere with GLSL
I'm getting started with GLSL with quartz composer.
I have a patch with a particle system in which each particle is mapped into a sphere with a blend value. With blend=0 particles are in random ...
3
votes
1answer
2k 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 ...
3
votes
3answers
678 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
110 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
187 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 ...
