How About a HelloWorld for AwayPhysics?

Software: Away3D 4.x

tcorbet, Jr. Member
Posted: 12 January 2012 07:50 AM   Total Posts: 31

Perhaps a HelloWorld is not required.  A thorough reading of all the postings to the AwayPhysics topics on this forum since they were initiated three months ago might lead to the conclusion that most developers wanting to incorporate some of these facilities in their Away3d application are very savy on the use of the Bullet Physics Engine, so had little trouble in understanding the AwayPhysics port.  For them, a mighty hooray.

Another reading of the postings might indicate that relatively less use has been made of this library than seems ought to be the case, given its power to energize most applications. For those who might fall in the category of holding off because the state of limbo in which Adobe has left Alchemy, I understand.

I fall in a third category, so I am willing to expose to the world my inexperience with the Bullet Physics Engine, and my non-success, so fat, in being able to take advantage of capabilities in the library that I am sure are there.  So, at least selfishly, I would really like to see a HelloWorld example/tutorial to help me get by the stumbling blocks.

So, let me answer the first spate of questions.  Yes, I am using the most current code, yes I am using the Dev branch of the Away3d codebase.  Yes, I have backed off of my participation in the Adobe prerelease programs for FlashPlayer 11.2 and AIR 3.2 because I know that we cannot use anything that depends on Alchemy in those prerelease libraries, nor, especially with the debuggers at that prerelease level.  And, probably the biggest, Yes, is to answer the questions of:  Have you looked at the Bullet Documentation, the Bullet Wiki, the Bullet Forums?

Since you are really relying on the Bullet documentation and the Bullet tutorials as the way for us to understand how to use the AwayPhysics port, that is why I am suggesting that we use HelloWorld instead of the suite of tests you have written., I understand is your equivalent, and it is helpful, but HelloWorld would be even more fundamental.  A working example of HelloWorld would show that the port is at least complete to that entry level of functionality.  A working example of HelloWorld would be an ideal place to make simple side-by-side comparisons between the AwayPhysics classes and their Bullet counterparts.

I think I can give a good, concrete example of why, for a poor newbie, such as me, this would be essential.

Let’s create our first RigidBody.  I vote for a StaticPlaneShape since that seems like a natural ‘floor’ to drop things on and that’s what HelloWorld used, so it seems like a winner because there’s just such a ground floor in BasicTest.

Oops.  If I look at the AWPStaticPlaneShape constructor I see there are two arguments.  Lets go take a look at Bullet, yep, btStaticPlaneShape has two arguments.  I wonder why BasicTest just let some argument with the unhelpful name of ‘constant’ default to zero.  I wonder what Buller programmers use?  So, off to the Bullet Forum.

Humm, not very helpful over there—lots more questions get posted than answers.  But, I got lucky. I managed to mangle up some query despite not knowing what I was really asking about—and someone said that setting that constant to zero seems to make things fail.  No specific description of the failure, but something not good, we guess.

So, since, my HelloWorld does not end up behaving the way I expect, I have to go look at every argument, every default to see if I can by trial and error arrive at some configuration of properties that will work.

There are probably folks who take the healthy position that, if it works, just do it, but when it does not work, instead of bothering you with silly, simple questions, I would like to just be able to look at something that would unequivocally answer the question that this simple example demonstrates.  What is the purpose of the ‘constant’ parameter?  What range of values may it usefully take?  What is the effect of setting some typical values for the ‘constant’ parameter?

If I could see each of the AwayPhysics settings that will allow an object dropped on a floor to bounce correctly, and eventually run away, jsut the way they do in HelloWorld, I think it would answer all those questions about the interaction between gravity and restitution and friction settings which are essential to that very basic behavior.  In all the examples in the AwayPhysics test suite, objects mostly seem to clunk onto the surface, not bounce.  Yes, they bounce off of each other, but not usually off of the floor.  What bounces off of the floor?  Ahah, the ball you shoot by applying an impluse.  yep, sure enough, if instead of just letting a sphere fall by gravity, I shoot it toward the floor, it can be made to bounce—very different from the behavior in HelloWorld.

So, I know most of the folks building things with Away3d love to shoot things, and maybe that’s why they don’t need HelloWorld.  I don’t want to shoot anyone, drive a car through any walls, or slice the head off of any bad guys.  I want some balloons to fly nicely up into the air and the red rubber ball a little girl uses for playing Jacks to to play nicely when she drops it.

HelloWorld, I think, would get me there.


John Brookes, Moderator
Posted: 12 January 2012 10:02 AM   Total Posts: 732   [ # 1 ]

Ooh thats a lot of typing wink


John Brookes, Moderator
Posted: 13 January 2012 12:38 PM   Total Posts: 732   [ # 2 ]

OK after a re read and a snotty email (thanks). I guess thats not what your after.

A plane in bullet is defined by a plane equation (normal and a constant).

The way I think of the constant is its height in its own local space. Whether thats right or wrong it works for me wink

var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0), -100);
would make any object dropped onto the plane sink -100 below where the plane is positioned (although you wouldnt position a plane as its infinate in size) and if the constant was 100 then the dropped object would stop 100 above.

As for dropping things onto a plane and it doesnt bounce. Thats because both the ground and the object your dropping have to have some restitution.

Any thing else just ask smile



Away3D Forum

Member Login