jool

Members
  • Content count

    2
  • Joined

  • Last visited

About jool

  • Rank
    Newbie

Recent Profile Visitors

162 profile views
  1. Support for tracked module formats

    FlodJS looks really nice, but it doesn't seem to be working on Firefox still, even though Firefox has support for WebAudio now. Anybody have any idea why?
  2. p2.body.addpolygon: how coords work?

    I've been having the same issue and it was close to driving me crazy. As JP91 wrote the issue is caused when P2 adjusts the polygon vertices so that center of mass is in the exact middle (I assume). However this also seems to change the body.x & y in a way that I couldn't get to work properly. In the end I went opened Phaser.js, scrolled down to the polygon function in P2: Body.prototype.fromPolygon and removed: this.adjustCenterOfMass(); Body.prototype.fromPolygon = function(path,options){ options = options || {}; // Remove all shapes for(var i=this.shapes.length; i>=0; --i) this.removeShape(this.shapes[i]); var p = new decomp.Polygon(); p.vertices = path; // Make it counter-clockwise p.makeCCW(); if(typeof(options.removeCollinearPoints)=="number"){ p.removeCollinearPoints(options.removeCollinearPoints); } // Check if any line segment intersects the path itself if(typeof(options.skipSimpleCheck) == "undefined"){ if(!p.isSimple()) return false; } // Save this path for later this.concavePath = p.vertices.slice(0); for(var i=0; i<this.concavePath.length; i++){ var v = [0,0]; vec2.copy(v,this.concavePath[i]); this.concavePath[i] = v; } // Slow or fast decomp? var convexes; if(options.optimalDecomp) convexes = p.decomp(); else convexes = p.quickDecomp(); var cm = vec2.create(); // Add convexes for(var i=0; i!==convexes.length; i++){ // Create convex var c = new Convex(convexes[i].vertices); // Move all vertices so its center of mass is in the local center of the convex for(var j=0; j!==c.vertices.length; j++){ var v = c.vertices[j]; vec2.sub(v,v,c.centerOfMass); } vec2.scale(cm,c.centerOfMass,1); c.updateTriangles(); c.updateCenterOfMass(); c.updateBoundingRadius(); // Add the shape this.addShape(c,cm); } this.adjustCenterOfMass(); this.aabbNeedsUpdate = true; return true;};I think maybe this should be fixed in the official version also, as you can run adjustCenterOfMass() yourself, but you can't undo it. =)