game-physics

KDTree Splitting

穿精又带淫゛_ 提交于 2019-11-28 22:17:30
问题 I am currently writing a KDTree for a physics engine (Hobby project). The KDTree does not contain points. Instead it contains Axis Aligned bounding boxes which bound the different objects in the environment. My problem is deciding on how to split the KDTree nodes when they get full. I am trying 2 methods: Method1: Always split the node exactly in half on the biggest axis. This has the advantage of a pretty evenly spaced out tree. Big disadvantage: If objects are concentrated in small area of

AI of spaceship's propulsion: land a 3D ship at position=0 and angle=0

邮差的信 提交于 2019-11-28 17:13:48
This is a very difficult problem about how to maneuver a spaceship that can both translate and rotate in 3D, for a space game. The spaceship has n jets placing in various positions and directions. Transformation of i -th jet relative to the CM of spaceship is constant = Ti . Transformation is a tuple of position and orientation (quaternion or matrix 3x3 or, less preferable, Euler angles). A transformation can also be denoted by a single matrix 4x4. In other words, all jet are glued to the ship and cannot rotate. A jet can exert force to the spaceship only in direction of its axis (green). As a

Kalman Filter for Android

纵然是瞬间 提交于 2019-11-28 16:33:46
问题 Is there a Kalman filter implementation I can use to fliter my gyroscope and acceleration data from an Android Phone? 回答1: Have a look at this project: http://library.rl-community.org/wiki/Helicopter_(Java) They are using kalman filters for gyrosensors etc and it's java too ... you can download the source and probably use some of it pretty easy in android. You should also check out rsbweb.nih.gov/ij/plugins/kalman.html and www.vni.com/products/imsl/jmsl/v30/api/com/imsl/stat/KalmanFilterEx1

Is there an upper limit on velocity when using box2d?

断了今生、忘了曾经 提交于 2019-11-28 13:23:51
I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f. According to this , the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during painting. It doesn't seem to make any difference at all. Is there some step or setting I'm missing here ?

Sprite Kit physicsBody.resting behavior

旧街凉风 提交于 2019-11-28 12:14:11
I am using Swift and Sprite Kit to develop a game on XCode Beta 6. In order to detect if all nodes are sleeping, i check their physicsBody.resting property. In update method i print out the result. import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate { var hero:SKSpriteNode! override func didMoveToView(view: SKView) { self.physicsWorld.gravity = CGVectorMake(0, 0) self.physicsWorld.contactDelegate = self self.physicsBody = SKPhysicsBody(edgeLoopFromRect:self.frame) hero = SKSpriteNode(imageNamed: "Spaceship") hero.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY

Cocos2dx - Unable to set velocity = 0.0

你离开我真会死。 提交于 2019-11-28 11:35:04
问题 I'm making an pool game with cocos2dx. First, i setup the edgeBox with this parameters PhysicsMaterial(1.0f, 1.0f, 0.8f) And then these 2 balls PhysicsMaterial(1.0f, 1.0f, 0.5f) On the update function, i want slow down balls time by time without gravity (like making ground friction) by adding physicsBody->setLinearDamping(0.3); On the update function, i set the minimum velocity, if the velocity of each ball reaches lower than 15, reset velocity to 0,0 auto MV = 15; auto v1 = player1-

SKPhysicsBody bodyWithPolygonFromPath memory leaks

a 夏天 提交于 2019-11-28 11:14:11
I have a strange memory leaks when creating Sprite Kit physics bodies with custom shapes. This is how my implementation looks: CGFloat offsetX = self.frame.size.width * self.anchorPoint.x; CGFloat offsetY = self.frame.size.height * self.anchorPoint.y; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 4 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 66 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 35 - offsetX, 57 - offsetY); CGPathCloseSubpath(path); self.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path]; CGPathRelease(path);

Create vectors and collisions

北慕城南 提交于 2019-11-28 05:33:29
问题 I have a ball and a stick (for a billiard game). First the ball is placed in a position of a table. On clicking the ball the stick appears, in such a way that we can determine the angle by which stick is placed by clicking the ball (on clicking we determine the angle of mouse with respect to centre of ball and place the stick at that angle touching the ball). So now the stick is also in the table. Now I am dragging the stick along that angle only, if dragged in another angle than the initial

Wanted to make an object bounce inside a circle, ended up making the object move along the rim of the circle

雨燕双飞 提交于 2019-11-28 02:24:20
Here's the code in question: public void calculate() { // Center of circle is at (250, 250). //THIS ALGORITHM IS NOW PROVEN TO BE WORSE THAN I FEARED... /* What it does: * Moves object around in a circle. * Does not move the object towards the center. * Object always stays on the rim of the circle. * * Algorithm I used. (DOES NOT WORK): * N is normalized vector. * R = -2*(V dot N)*N + V */ vx += Accelero.X * 0.1; vy += Accelero.Y * 0.1; double nx = x - 250; double ny = y - 250; double nd = Math.hypot(nx, ny); if (nd == 0) nd = 1; nx /= nd; ny /= nd; double dotProduct = vx * nx + vy * ny; vx +=

Transforms are added…endlessly

…衆ロ難τιáo~ 提交于 2019-11-28 01:33:20
I'm creating a simple asteroids-like game in CSS and JS using the DOM over canvas for...experimentation purposes. My code is pretty small in this example to make it easy to see what's going on below. The ultimate goal: Let arrow keys smoothly rotate and translate the spaceship around the window without creating an infinite amount of transforms. I think I'm 90% there : Use the arrow keys to control the snippet below. 'use strict'; function defineDistances() { var distance = {}; distance.up = -1; distance.right = 1; distance.down = 1; distance.left = -1; return distance; } function defineKeys()