collision-detection

iPhone iOS5 querying OpenGL ES 2.0 pipeline objects if they are hidden in the view or not…“Occlusion”

元气小坏坏 提交于 2019-12-06 02:28:25
问题 EXT_occlusion_query_boolean is new with OS5.0, it looks to me like not a single person on the entire internet has posted about these new extensions nor used this code.... so here they are set up properly...which is not documented anywhere as far as i can tell... you can imagine how they would go in your code from this little sudo code here: import UIKit/UIKit.h import GLKit/GLKit.h import "GLProgram.h" GLuint testBox,hasBeenTested,theParams; //... glGenQueriesEXT(1, &testBox); glBeginQueryEXT

How to handle simultaneous collision so that order of processing does not matter?

随声附和 提交于 2019-12-06 01:16:16
问题 Suppose there are 3 balls colliding at the same time. I find that the order in which I resolve collisions makes a difference in the final result, which ofcourse makes no sense. To explain and keep things simple, consider 3 balls in 1D, all same mass, elastic collision. The numbers at the top are the speeds and the arrows is the direction. Assume they are currently all touching each others, i.e. in collision -->2 -->1 <---3 O O O A B C This shows ball A hitting ball B from the back and ball B

Java Circle to Circle collision detection

一个人想着一个人 提交于 2019-12-06 00:04:03
I am making a circle to circle collision detection program. I can get the balls to move around but when the collision is detected, the balls are quite far overlapped. Any suggestions? Thanks in advance! import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.lang.Math; public class ShapePanel extends JPanel{ private JButton button, startButton, stopButton; private JTextField textField; private JLabel label; private Timer timer; private final int DELAY = 10; ArrayList<Shape> obj = new ArrayList<Shape>(); public static void main(String[] args){

RigidBody2D freeze X position

我们两清 提交于 2019-12-05 23:56:49
I'm wondering if there is a way to emulate the following line of code using Unity's RigidBody2D as opposed to using a normal RigidBody. rigidbody.constraints = RigidbodyConstraints.FreezePositionX; I wanting my players x position to freeze when it collides with something. Whilst I could use the above, it would require I rework all my 2D collisions to work with the 3D collision. A pain I'd rather avoid. This is due to the Box2D engine use to do the simulation. It does not directly provide a constraint on the rigid body itself. It does however provide joints. What you want to look into is a

2D collision between a moving circle and a fixed line segment

折月煮酒 提交于 2019-12-05 23:42:17
问题 In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation. I know the radius of the circle: r I know the coordinates of the circle before the move: (xC1, yC1) I know the coordinates of the circle after the move: (xC2, yC2) I know the coordinates of the extremities of the line segment: (xL1, yL1) - (xL2, yL2) I am having difficulties trying to compute: A boolean : If any part of the circle hits the line segment

iOS Swift didBeginContact not being called

早过忘川 提交于 2019-12-05 22:09:06
问题 I have been struggling for the past two days to get two SKSpriteNodes to register a collision and evoke didBegin#contact . I've set their bit masks ' categoryBitMask ', ' contactTestBitMask ' and ' collisionTestBitMask ' for both objects. I've also set the ' dynamic ' property for both to ' true ' initPhysics() seems to set up the physicsWorld okay. All I'm expecting is that didBegin#Contact is called, but it is not //Set up Physicsbody bit masks let playerCarBitMask: UInt32 = 0x1 << 1 let

SFML Bounding Box Collision Detection

微笑、不失礼 提交于 2019-12-05 19:20:30
I am trying to write a very basic game for my first SFML project. Its a robot with a jointed arm that will be able to pop balloons with his hand only. The problem I am having is that when checking to see if the pincer sprite intersects with the balloon sprite , it returns true all the time, regardless of the placement of the balloon or the robot pincer. I am using transform to place the various parts of the robot arm, and this is whats causing the problem I think, but I don't know why. I have tried using bounding box collision in a separate program where transform is not used and it worked

2D Physics Engine: bouncing ball w/ inelastic collisions does not come to a stop

风流意气都作罢 提交于 2019-12-05 15:52:37
I've created a simple 2d physics engine in Java that uses circular projectiles and straight walls. Currently, with each frame, every projectile's position is advanced by velocity * (1/fps) . Velocity is updated afterwards, once per frame. Collision detection defines a line in point-slope form using the previous and current position, checks if that line intersects with a wall, and if that intersection lies in between the previous position and current position, a collision is registered and the projectile's current position and velocity is updated accordingly. At the moment, there is no rotation

Counting lattice points inside a triangle

不打扰是莪最后的温柔 提交于 2019-12-05 14:06:29
I've points for a big triangle lets call it a, b, c. (a = (x, y) and so on). Now I want to count the number of integral points inside the area enclosed by this triangle, so I first looked at Pick's theorem. The second approach that I considered was generating a list of points bounded by max, min of the triangle, and then checking if each point lies inside the triangle. I used the Barycentric coordinates method to do this. It works however my triangle is pretty huge and my program is basically a brute force across points. How do I improve on this algorithm? My code can be found here: https:/

Is an imageData CanvasPixelArray directly available to a canvas WebGL context?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 11:55:58
I'm using Three.js to draw 3D models onto a webgl canvas renderer above simple DOM elements, and I need to do collision detection between them. My currently working method is to use renderer.domElement.toDataURL(), load this as an imageData object then draw this onto a separate 2D canvas context, then pull the getImageData() pixel array and iterate through using this awesome pixel collision function . This is incredibly slow, and pulls my frame rate down to a nearly unplayable ~5-8 FPS. Without running this hit detection I get about 40-50 FPS. My best guess is that the slowdown is the