collision-detection

OpenGL Vertex buffer object, can I access the vertex data for other uses such as collision detection?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 14:34:11
I'm currently using the GLTools classes that come along with the Superbible 5th edition. I'm looking in the GLTriangleBatch class and it has the following code: // Create the master vertex array object glGenVertexArrays(1, &vertexArrayBufferObject); glBindVertexArray(vertexArrayBufferObject); // Create the buffer objects glGenBuffers(4, bufferObjects); #define VERTEX_DATA 0 #define NORMAL_DATA 1 #define TEXTURE_DATA 2 #define INDEX_DATA 3 // Copy data to video memory // Vertex data glBindBuffer(GL_ARRAY_BUFFER, bufferObjects[VERTEX_DATA]); glEnableVertexAttribArray(GLT_ATTRIBUTE_VERTEX);

One-way platform collisions in Sprite Kit

回眸只為那壹抹淺笑 提交于 2019-12-03 13:56:46
问题 I am making a Doodle Jump clone game in Swift and the issue is that when the player jumps, it hits its head on the bottom of the platform and doesn't pass through. How can I make the player pass over the platform and jump through them? I have my code here: import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate { var hero = SKSpriteNode(imageNamed: "hero"); var stepSizeTest = SKSpriteNode(imageNamed: "step"); var start = false; var jumpSpeed = CGFloat(0); var gravity = CGFloat(0);

Collision Detection between Accelerating Spheres

此生再无相见时 提交于 2019-12-03 13:54:22
I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well, however, one thing that I need help with is the math of the collision detection algorithm. The iterative simulation of movement that I am using is basically as follows: (Note: 3D Vectors are ALL CAPS.) For each obj obj.ACC = Sum(all acceleration influences) obj.POS = obj.POS + (obj.VEL * dT) + (obj.ACC * dT^2)/2 (*EQ.2*) obj.VEL = obj.VEL + (obj.ACC * dT) Next Where: obj.ACC is the acceleration vector of the object obj

XNA C# 2D Platformer Game

偶尔善良 提交于 2019-12-03 13:19:31
问题 I'm trying to make (figure out how to..) a 2d platformer in XNA. I know how to create a tile grid and how to perform collision detection. I perform collision detection on the 9 bounding tiles of the player, but I'd like to know if there's a better way to perform collision detection. I've read Braid doesn't use tiles but pieced images or something, how do you perform collision detection on those? and is that better than using tiles? 回答1: Assuming you don't mind using a third party tool to do

Java HashMap detect collision

若如初见. 提交于 2019-12-03 12:38:34
问题 Is there a way to detect collision in Java Hash-map ? Can any one point out some situation's where lot of collision's can take place. Of-course if you override the hashcode for an object and simply return a constant value collision is sure to occur.I'm not talking about that.I want to know in what all situations other that the previously mentioned do huge number of collisions occur without modifying the default hashcode implementation. 回答1: I have created a project to benchmark these sort of

2D Polygon Collision Detection

↘锁芯ラ 提交于 2019-12-03 12:06:40
Does anyone know a simple way to check if two polygons, especially rectangles, are colliding? I found a simple way to see if two are touching by just checking if any lines on the two rectangles are colliding, but this will not work if one polygon is in another. Does anyone know a more efficient way to do this or just a way that works? Also, can someone please give me a formula for it or something like that and not just your thoughts on the subject. Thanks Look up the Separating Axis Theorem. There's a tutorial here . It's quick, elegant, robust, not too hard, and has lots of resources. Check

What's a good, simple, 2D rectangles-only collision detection algorithm?

一世执手 提交于 2019-12-03 10:42:08
I'm designing a collision detection game tutorial for young adults, so I want this to be as simple as possible to make it easier to explain. The requirements are very simple. The world is 2D and contains only rectangles (of arbitrary sizes). BSP and even quadtrees seems like it would be overkill (again, the emphasis is on simplicity) but I would like something more efficient than brute forcing through all n(n-1)/2 possible collisions. 2D, rectangles only, and simple. Can anyone point to an algorithm I can look up? Is a quadtree algorithm what I'm looking for? EDIT: Also, the rectangles will

How do I create collision detections for my bouncing balls?

本小妞迷上赌 提交于 2019-12-03 09:57:36
问题 I have coded an animation (in python) for three beach balls to bounce around a screen. I now wish to have them all collide and be able to bounce off each other. I would really appreciate any help that can be offered. import pygame import random import sys class Ball: def __init__(self,X,Y): self.velocity = [1,1] self.ball_image = pygame.image.load ('Beachball.jpg'). convert() self.ball_boundary = self.ball_image.get_rect (center=(X,Y)) self.sound = pygame.mixer.Sound ('Thump.wav') self.rect =

Calcuate x/y point that 2 moving balls will collide

旧街凉风 提交于 2019-12-03 09:36:54
问题 Im trying to make what is (essentially) a simple pool game, and would like to be able to predict where a shot will go once it hits another ball. The first part is, I believe, to calculate if the cueball will hit anything, and if it does, where it collides. I can work out collision points for a line and a ball, but not 2 balls. So given the x/y positions and velocities of 2 balls, how do I calculate the point at which they collide? (PS: Im aware I can do this by calculating the distance

Algorithms for collision detection between concave polygons

南楼画角 提交于 2019-12-03 08:26:32
Is there any good algorithm for detection between concave polygons? I'd appreciate any help as so far I've only found algorithms for detection between convex polygons. Ali Rasim Kocal You may find this paper interesting. This is old, but still relevant and there doesn't seem to be alot of answers for this question, so here goes: For polygons whose overall shape does not change (may rotate and scale, but relationships between vertices may not change), there are ways to pre-process the vertex data to achieve an and/or series of tests for the lines in the polygon to test if the other polygon