Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dkollmann

I updated the physics plugin to version 2.1a as it contains some features that I need. I am willing to share my updated version but as it is only available for people with a license I was wondering where I should put it.

1 decade ago by fugufish

github! we share all plugins there. Look at the Code section of the forums

1 decade ago by dominic

The Box2D plugin itself is publicly available - it's only the complete Box2D demo game that is not. The plugin is located here:
https://github.com/phoboslab/impact-box2d

So you can put your code on github as well or just provide it as a ZIP download somewhere.

Thanks!

1 decade ago by dkollmann

Not sure why it lists me as [unknown] but I uploaded my updated code here: https://github.com/dkollmann/impact-box2d

I optimised the lib.js but it is still much bigger than the original lib. Don't know if the original lib.js had stuff missing.

1 decade ago by StuartTresadern

Hi, I am using box2D 2.1a update but when I set the debugDrawer it seems to corrupt the canvas !. Has anyone else got the debugDrawer working using 2.1a ? I had the same game showing the debug collisions with the original conversion by dominic.

this.m_sprite.canvas is undefined. is reported in the console debug.

1 decade ago by korzen303

Hi, how can I use ig.world.Raycast(callback, pointA, pointB) function?

I've got it running on a server side in Java, but I am not sure how to create callback function in JS. So far I've tried two options:
ig.world.RayCast(
 function(fixture, point, normal, fraction )
 { 
  this.infoText = "Frac: " +fraction;
  return fraction;
 }, 
 startVec, 
 endVec) );

and

var clbbck =  function(fixture, point, normal, fraction )
 { 
  this.infoText = "Frac: " +fraction;
  return fraction;
 };

ig.world.RayCast(clbbck, startVec, endVec);

but without any luck. The callback is not invoked at all
Cheers

1 decade ago by TigerJ

Quote from dkollmann
I updated the physics plugin to version 2.1a as it contains some features that I need. I am willing to share my updated version but as it is only available for people with a license I was wondering where I should put it.


wherever you put the plugin you can also post about it here http://www.pointofimpactjs.com/plugins/index.php

1 decade ago by korzen303

I have found a bug in Box2D.js in world.RayCast(). You need to change initialization of maxFraction in RayCastInput from null to 1. Or add argument 1 to all invocations of RayCastInput constructors. It was caused by lack of the default value of the parameter in a constructor of RayCastInput.

1 decade ago by korzen303

Hi,

I am getting this error in after I bake my game (using Impact 1.19):

missing ) in parenthetical
...rn c*-a*i.y+h*a*i.x+(i.x*(k.x+-b*f-j.x--a*e)+i.y*(k.y+b*g-j.y-a*d))};b2.LineJoin...

so there is something wrong with 2.1a lib file.

I've tried to use latest not obfuscated box2d.js 2.1a version, but not sure what to change to make it compatible with Impact

Thanks in advance for help!

1 decade ago by Arantor

Assuming it's the one from the Git repo listed above, the original code has:

k.x+-b*f-j.x- -a*e

Which when minified becomes the x--a construct. What needs to happen is that the -a needs to be wrapped in brackets for minification:

k.x+-b*f-j.x-(-a)*e

(Note, I haven't tested it, but I think it should deal with operator precedence as expected in that situation.)

1 decade ago by korzen303

Yep, simple replace/find solved the issue! Thanks Arantor!
Another solution is to modify a bake.php script to skip box2d lib.js and have it as a separate file as it is obfuscated and minimized already.

Cheers!

1 decade ago by korzen303

Hi,

I have fixed a debug drawer, you just need to override two small methods of b2.DebugDrawer and change m_sprite to ig.system.context. Hope it helps as it took me a while to figure it out.


@dkollmann
After trying out please add this and raycast fix to the repo


lib/plugins/box2d/debug.js:
init: function( world, alpha, thickness ) {
 this.world = world;
 this.drawer = new b2.DebugDraw();
 this.drawer.m_sprite = ig.system.context;
 this.drawer.m_drawScale = 1 / b2.SCALE * ig.system.scale;
 this.drawer.m_fillAlpha = alpha || 0.3;
 this.drawer.m_lineThickness = thickness || 1.0;
 this.drawer.m_drawFlags = b2.DebugDraw.e_shapeBit | b2.DebugDraw.e_jointBit |b2.DebugDraw.e_centerOfMassBit;
		
 this.drawer.Y = function(y) 
 {
      //return this.m_sprite.canvas.height - y;
     return y;
 };
			
 this.drawer.Clear = function() {
 //this.m_sprite.clearRect(0, 0, this.m_sprite.canvas.width,  this.m_sprite.canvas.height);
};
},

1 decade ago by Neerav

Does Someone have the updated version of this plugin as I want to use some of the new features of Box2d 2.1a. I tried
https://github.com/dkollmann/impact-box2d
but this link is dead.

If someone knows a place from where I can get a the updated plugin please post here.

1 decade ago by Qandil

Quote from Neerav
Does Someone have the updated version of this plugin as I want to use some of the new features of Box2d 2.1a. I triedbut this link is dead.

If someone knows a place from where I can get a the updated plugin please post here.


Try this link :
Quote from Joncom
There is nothing wrong with posting here, but I imagine you'd get better support in help (only because I suspect people check that forum more frequently than this one).



Try this link

https://github.com/phoboslab/impact-box2d

1 decade ago by Neerav

Thanks for the reply, I will post in the help forum.
Try this link

https://github.com/phoboslab/impact-box2d

I have tried this link, but its not been updated in 2 years.

1 decade ago by Jarkko

Hi

Collin Hover's Impact++ has Box2D 2.1

https://github.com/collinhover/impactplusplus

(my first post ,yay)

1 decade ago by collinhover

Thanks for the plug Jarkko! Yep, Impact++ has Box2D 2.1 with a whole slew of formatting and bug fixes. There were some particularly nasty bugs such as static bodies never going to sleep which shouldn't happen. I added entity, character, and player classes to work with Box2D, which should help. Of note is that all characters are actually constructed automatically to have a box upper body attached to a circle (or circles) motorized by a revolute joint. This makes movement nice and smooth, characters stick to slopes fairly well, and they can run, jump and climb no problem.

That said, Box2D performance is terrible on mobile, with every single Box2D version out there at about 10 fps (and I tried every single one). So technically, although Impact++'s version of Box2D is stable and working nicely, I'm no longer adding onto it because of its mobile performance. You can certainly use it and even contribute to Impact++ to make the Box2D implementation better!

1 decade ago by mimik

Quote from collinhover
That said, Box2D performance is terrible on mobile, with every single Box2D version out there at about 10 fps (and I tried every single one). So technically, although Impact++'s version of Box2D is stable and working nicely, I'm no longer adding onto it because of its mobile performance. You can certainly use it and even contribute to Impact++ to make the Box2D implementation better!


Are you talking about mobile web browser right?
box2d works great on mobiles. You should use Ejecta or CocconJS.
This game works fine on mobile http://vemdel-game.com/ ( in development)
60 FPS.

1 decade ago by collinhover

Yep I'm referring to playing directly on a mobile web browser, not natively wrapping your game using something like Ejecta / CocoonJS. Using these to port/wrap your game will likely give you much better performance, but then you have an app, not a website.

1 decade ago by Jarkko

For those who are, or have been looking for Box2d 2.1 plugin, I found yet another one here:

https://github.com/clok/PiSpace/tree/master/lib/plugins

For some reason I could not make a stable stack of boxes with Collin's version. Probably a scaling issue (I'm no expert)

1 decade ago by mimik

Nice Jarkko!
Ty for that one.
Clean and simple.

If your boxes arent't stable it sound like you have boucing stuff right?
Must be something with the density, friction or some basic function for collision or to low gravity.

1 decade ago by collinhover

If I remember right, I started with PiSpace's Box2D version (Jarkko linked above), but got rid of it for a number of reasons... I know it had a bunch of performance bugs, and it is possible it wouldn't bake or compile due. Giving it a quick scan, it actually has the Box2D library duplicated twice in one file. The line length is ~24k, vs what is should be which is around ~10-12k. I think it is a un-minified version, where the one in Impact++ has all the original variable and method names so it is far easier to edit. I've tried out 5 or more Box2D libraries so far, so I'm just trying to save you time, but I'm also not an expert so definitely try them for yourself!

That said, mimik might be right, some basic property is likely affecting them and making them slide or bounce. Try making the density and friction higher, it will make the boxes very heavy. That is often the most time consuming thing with Box2D, just tweaking values to get stable behavior.

1 decade ago by Jarkko

Collin - Actually it looks like tje code in PiSpace plugin repeats itself two times - so it's a triplication.

As for my stack of boxes, the rectangles "sink" into their neighbours and the tower topples over. Fiddling with the values only makes it go slower or faster but does not get rid of the problem. My scale is 0.1 and the rects are about 60px wide and 25px tall.

With those values, Dominics original plugin works well, except that the tower jolts a bit as if decompressing when the level initially loads.

1 decade ago by collinhover

Hmm, I'm afraid I don't know what is going on then. My guess would be that it is more likely an issue with the Impact++ EntityPhysics class (rather than the Box2D library), but I couldn't tell you what. If you want to dig into it and make a pull request with fixes, I'd love to have your contribution to make Impact++ better! I just don't have time to do it myself =(
Page 1 of 1
« first « previous next › last »