DebugDraw is not showing up.

Software: Away3D 4.x

vikramarka, Newbie
Posted: 10 May 2013 06:54 AM   Total Posts: 10

Hi there!
I am very much new to awqy3d and awayphysics. I am facing a problem with my game. Hope someone can help me.

I am trying to build a spoon egg game and I am creating both egg and spoon shapes using AWPConvexHullShape. The problem is the egg is appearing a little bit above from the spoon and I cant figure it why! The code I am using is

scene.addChild(spoonModel);
     var 
spoonShape:AWPConvexHullShape = new AWPConvexHullShape(spoonModel.geometry);
     
spoonBody = new AWPRigidBody(spoonShape,spoonModel,0);
     
spoonBody.friction 4;
     
spoonBody.position = new Vector3D(0,0,-150);
     
spoonBody.rotationY = -90;
     
physicsWorld.addRigidBody(spoonBody);
     
scene.addChild(eggModel);
     var 
eggShape:AWPConvexHullShape = new AWPConvexHullShape(eggModel.geometry);
     
eggBody = new AWPRigidBody(eggShape,eggModel,1);
     
eggBody.position = new Vector3D(0,100,10);
     
eggBody.mass 10;
     
eggBody.rotationY = -90;
     
eggBody.friction 4;
     
physicsWorld.addRigidBody(eggBody); 


I don’t have any clue about what was happening because I cant see the debugdraw also. I have searched for any tutorial about debugdraw and I found none.

It would be very grateful for me If I got through this.

   

vikramarka, Newbie
Posted: 13 May 2013 05:42 AM   Total Posts: 10   [ # 1 ]

Hi,

Is this because I am using starling with away3d.

   

John Brookes, Moderator
Posted: 13 May 2013 10:18 AM   Total Posts: 732   [ # 2 ]

The gap is probably the collsion margin.
http://away3d.com/forum/viewthread/777/

As for debug Draw

set the type of debug
debugDraw.debugMode = AWPDebugDraw.DBG_DrawCollisionShapes

Then in enterFrame
debugDraw.debugDrawWorld();

   

vikramarka, Newbie
Posted: 13 May 2013 10:33 AM   Total Posts: 10   [ # 3 ]

Hi John!
Thanks for the reply! I have read the thread you posted. I tried by scaling down the spoon model and applying physics and scaling up. Still the same problem! also the egg is not stable on the head of the spoon. It is falling as though it is on a height. Actually it had to set correctly on the head of the spoon!

   

John Brookes, Moderator
Posted: 13 May 2013 01:20 PM   Total Posts: 732   [ # 4 ]

I should pay attention wink

AWPConvexHullShape is for convex meshes

A spoon is concave, so thats why your egg seems to be floating.

Try the AWPGImpactMeshShape.zip in this thread.
http://away3d.com/forum/viewthread/3601/

   

vikramarka, Newbie
Posted: 14 May 2013 05:54 AM   Total Posts: 10   [ # 5 ]

Hi John, Thanks for the reply.
I have used the AWPGImpactMeshShape for the spoon and for the egg I have used AWPConvexHullShape. The egg is acting a bit weird now. I have scaled down the egg so that I can see whats happening. The egg is colliding with the walls of the spoon for a while and after that it is falling from the spoon.
You can see the egg behavior here: http://www.youtube.com/watch?v=SbambhZHpuk&feature=youtu.be

I am using dev version of awayphysics.

   

vikramarka, Newbie
Posted: 14 May 2013 05:58 AM   Total Posts: 10   [ # 6 ]

By the way, Is there any way to create a oval shape in away physics?

   

John Brookes, Moderator
Posted: 14 May 2013 08:16 AM   Total Posts: 732   [ # 7 ]

Sorry I cant tell much from that video.

Just tried a quick test with the Gimpact and it seems to work ok.

Random guess..
scale up your mesh vertices (eg MeshHelper.applyScales) before adding to your shape.
Bullet doesnt like small meshes.

As for oval, currently no. AWPSphere doesnt work with localScaling.

For the egg try a compound shape of spheres.

   

vikramarka, Newbie
Posted: 14 May 2013 09:30 AM   Total Posts: 10   [ # 8 ]

Hi John..

I am sorry.. It actually worked after using both the away3d and awayphysics dev versions. Previously I was using master version of away3d.

Thanks for your patience to answer me.

   

vikramarka, Newbie
Posted: 15 May 2013 08:18 AM   Total Posts: 10   [ # 9 ]

Another question, this is not regarding the problem above.
How to make the gravity always at the bottom? If I rotate the phone with home button at the bottom, the gravity should point to the bottom. If I held it up horizontally it the gravity should point down. I tested with accelerometer but could not get it 100% correct.

Here is the code that I am using right now!

EggRace.physicsWorld.gravity = new Vector3D(-accelerationX*30,-20,-accelerationY*50);

I put the y value as -20, because I thought initially the gravity should be downwards. But I don’t think it is correct approach.

Can anyone tell me the correct approach please.. ?

Sorry If it feels that I am asking too many questions.. smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X