AS3 2.1 Port (Alchemy), WCK Update and Kinematic Demos

anitin wrote:
anitin wrote:
In wck the joint component properties are working for someone?

I put a revolute joint in a test and the two bodies conects and works ok, but if i enable the motor, appears to not work, enabling the limits the body appears to be fixed, enabling the spring do nothing. Changing the density of a body causes the flash CS5 to complain with errors and those errors keeps until the body is deleted from the stage. Changing the property restitution of any shape do not works for me, i must to assign the restitution in AS.

These are bugs in component properties, or i am dumb? 😀

And one more thing, i try to copy the properties of a box from the examples but the box from example appears to have less properties that the box i create, and i'm using the same classes definition for both my body and the body example.

What is wrong? The components or my brain?

Best regards.


Well i found the problem, i tested the wck in flash CS4 and the changes i made in the component inspector now works ok, this means that wck components do not work for me in CS5, but i have CS5 because CS4 do not works in Windows 7, someone knows how to solve this issue?

One more thing, in my tests in CS4 i can't drag the bodies in the screen, why?

thank you.


Yes, i got it, the problem is the decimal separator, here in Europe in some countries we use the "," for decimal separator, but CS5 needs the "." separator, changing this in region configuration in Windows, WCK runs ok in CS5.
❓
astrocreep wrote:
the first test:
two edge chains, the left one flat, the right one slightly goes down. vertex 3 of the left shape ist vertex 2 of the right shape. vertex 0 of the right shape is vertex 1 of the left shape. the left one has no vertex 0, the right one no vertex 3. i think this should be the right usage of edge chains? seems to work really good, no crashed etc. the only strange thing is when you grab the circle or the box. try to push them trough the left edge. this will not work (as intended). but when you try to push the box through the right edge from the right side there is no collision. even after dragging it out and in again, the collision is gone. i think you have to drag the object out of the edge's bb the reactivate collisions.

the second test:
sam as test 1, but two modifications: first, the right edge not going down anymore. this is a scenaria which can happen in tiled levels. sliding across the edges works great here (box and poly!). the second change is that i added a vertex0 on the left shape. the circle has no problems at the edge, but the poly causes the alchemy part to crash (i think you mentioned this before?). i started altering the values. the crash will only occur if the y value of vertex 0 and vertex 1 are equal. if the y value of vertex 0 differs, it's working, but then sometimes there's no collision (like the right edge in ex. 1)


I finally had a chance to look at these test beds. In both cases, setting m_hasVertex0 and m_hasVertex3 correctly fixed the problem.

In the first test bed, you are reusing the b2Def.edge object, so m_hasVertex3 needs to be reset to false.

In the second test bed, you are setting m_hasVertex0 to true when there is no adjacent edge. Setting it properly to false fixed the crash.

In a nutshell: Always explicitly set m_hasVertex0 (has adjacent previous edge) and m_hasVertex3 (has adjacent next edge), especially when resusing b2Def.edge.
setting the right vertices to avoid crashes is no problem, if you know what you have to do. the whole thing was only a testcase, because you asked for testing *GG*

the only thing that remains is the drag/roll through problem in example 1 if you grab the objects and push them inside the edge chain from the right side. this doesn't seem to be ok for me, especially this is working correct on the left side!
When I set m_hasVertex3 for the second edge in test 1 it works. Have you tried this (for the second edge)?
Code:
b2Def.edge.m_hasVertex3 = false;
mayobutter wrote:
When I set m_hasVertex3 for the second edge in test 1 it works. Have you tried this (for the second edge)?
Code:
b2Def.edge.m_hasVertex3 = false;


ah damn, you'r absolutely right! i forget that vertex3 was still true in b2Def.
setting density dynamically in wck doesn't seem to work.

the object is one body, with one shape. specifically a square. when it collides with a buoyancy area i change the density (and other properties), no error, and still no effect to density if i wait until next EnterFrame to apply the change.

Code:
density = 50


Code:
public function set density(v:Number) {
   trace("Set density: "+v); //traces 50
   if(b2fixtures) {
      for(var i:int = 0; i < b2fixtures.length; ++i) {
         b2fixtures[i].SetDensity(v);
      }
   }
   else {
      _density = v;
   }
   trace("desnity is now: "+density); //traces 1
}


also, is there a b2Settings.as file to manipulate some of the defaults in wck?
wanting to reduce some bounciness.
sketchbook: Looking at the code, I see no reason why setting density will not work. Could be:

1. Buoyancy has a property called "useDensity" that tells is to use the density of the fixture rather than a constant density for everything.

2. The box is actually a separate BodyShape and you are setting density on the container rather than the actual shape.

As for b2Settings: You'll have to recompile in Alchemy to set a lot of things (because they are #define statements in the C++ code). I've been working on the documentation and there's a bit about recompiling at the bottom of this page:

http://wiki.github.com/jesses/wck/box2d ... chemy-port

You should be safe as long as you don't change anything that results in a different memory layout (like max polygon vertices).
I'm trying to modify the b2Settings.h file and recompile into Alchemy, but I'm getting errors :

Code:
../Box2D/ConvexDecomposition/b2Polygon.cpp:997:5: warning: "/*" within comment
../Box2D/ConvexDecomposition/b2Polygon.cpp:1005:48: warning: "/*" within comment

/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:82: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:83: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:86: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:87: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:92: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
/cygdrive/e/Projects2/Projects/alchemy-cygwin-v0.5a/avm2-libc/include/c++/3.4/ne
w:93: error: 'operator new' takes type 'size_t' ('unsigned int') as first parame
ter
../Box2D/Dynamics/b2World.cpp: In member function 'void b2World::DrawShape(b2Fix
ture*, const b2Transform&, const b2Color&)':
../Box2D/Dynamics/b2World.cpp:946: warning: enumeration value 'e_unknown' not ha
ndled in switch
../Box2D/Dynamics/b2World.cpp:946: warning: enumeration value 'e_typeCount' not
handled in switch
../Box2D/Dynamics/Contacts/b2ContactSolver.cpp: In member function 'void b2Conta
ctSolver::InitializeVelocityConstraints()':
../Box2D/Dynamics/Contacts/b2ContactSolver.cpp:146: warning: unused variable 'cp
'


I followed the instructions on github. Do you know what might be wrong?
Quote:
2. The box is actually a separate BodyShape and you are setting density on the container rather than the actual shape.


i am setting it on the body, even though its a shape property.
i thought this bit of code was to transfer the property setting down to the shape.
Code:
if(b2fixtures) {
      for(var i:int = 0; i < b2fixtures.length; ++i) {
         b2fixtures[i].SetDensity(v);
      }
   }


or is a b2fixture not the same as a shape?
sketchbook: b2fixtures is a property of BodyShape that contains all the fixtures / shapes defined by that BodyShape (via calls to box(), circle(), etc.) So if your body defines no shapes itself, that array will be empty. Your child BodyShape will have the fixture / shape in its b2fixtures array.

Tiblanc: Windows with Cygwin? Yikes, not familiar with that environment. I'm compiling on OS X myself. Had to play around with the command line flags sent to g++ a lot to get it to work. I'd recommend poking around in the Alchemy documentation or playing around with the flags. For example the Alchemy docs recommend compiling like this:

gcc stringecho.c -O3 -Wall -swc -o stringecho.swc

But I ended up with this:

g++ Box2D.c -I.. -O3 -Wall -swc -DOSX -o Box2D.swc

So maybe try dropping the -DOSX flag?

Original thread: https://box2d.org/forum/viewtopic.php?t=4105