# matthen

Members

9

• Rank
Newbie
1. ## matthen

? A dodecahedron tumbling inside a circumscribing circle. [code] https://t.co/SSRn8X6xUG

2. ## Simulating n-bodies

This is now a full working demo game, where you can explore an infinite universe procedurally generated from a seed. Try it out! http://gravity.matthen.com
3. ## Simulating n-bodies

Another update. There is now a fuel tank guage, and a damage guage. If you orbit close to a planet then you start to mine it for fuel. I also did some work on giving the planets textures. Check it out: http://ec2.matthen.com/gravity/
4. ## Simulating n-bodies

Thanks for the advice on speeding up collision detection. I combine it with calculating the gravitational forces. The below snippet should give some idea: if (dist < r1+r2) { s = 1000*Math.min(100,(1/dist)*(square(((r1+r2 - dist)/(r1+r2))))); collisions.push([objects[i]._id, objects[j]._id]);} else { s = -G * Math.pow(dist,-3);}[source] so there is a repulsive field when two objects get too close together, and that makes them bounce off each other. Calculating dist does require a square root, but both conditions in the if need the square root I suppose. It doesn't use Verlet, just a very standard Runge Kutta. That's fast and seems to get the physics right... at least ellipses close back in on themselves when there are 2 bodies.
5. ## Simulating n-bodies

Cool, thanks for the link. Hermit, have you seen the proposed WebCL? An update on the demo, it now uses some dynamic delta-t to make the physics more smooth if it's lagging behind a bit. You can now zoom in and out, and hopefully the positioning of your spaceship on the screen should be quite smooth- with it being tugged towards nearby masses: http://ec2.matthen.com/gravity/ See if you can maintain your orbit around the planet, as 200 asteroids swarm in.
6. ## Simulating n-bodies

Yeah quad tree was what I was thinking of (storing centre of mass and total mass). I think for my game the overhead of calculating the tree structure won't pay off
7. ## Simulating n-bodies

With all the interactions, but if I find I need to speed it up the first thing I'd do is the particle mesh approximation. I think it runs pretty smoothly on most devices for 100 bodies, which is a good budget for a solar system in the game I'm making. Running the DE solver in a web worker seems to help a lot with speed. M
8. ## Simulating n-bodies

I've updated the demo, Now you have a spaceship in the centre of the screen, and if you click you fire its engines: ec2.matthen.com/gravity It'll start with 20 random planets
9. ## Simulating n-bodies

Hi everyone, I got to a certain stage in my project where I have an orbital gravity simulator that should run quickly. As I progress I'll be updating a live demo on this page: http://ec2.matthen.com/gravity/ At the moment there are 200 planets of different sizes and masses which start on a grid. The physics simulation runs in a different thread to the rendering by using a webworker.
10. ## Antialiased Circle

Hi everyone, I'm using the Graphics stuff from the dev version of Pixi.js. I can draw a circle by doing this: var graphics = new PIXI.Graphics();graphics.lineStyle ( 2 , 0x000000, 1);graphics.beginFill(this.colour);graphics.drawCircle(this.position[0], this.position[1], this.radius); But I was wondering if it is possible to draw it with antialiasing? I note it looks like the webgl contexts are created with {antialias:true} by Pixi. Do I need to make a PNG of a circle? That's less ideal for changing the colours. Thanks, Matt