Papervision3D with Box2DFlash Part 4 - Distance Joint
Please check the previous examples on box2dflash before jumping into this one.
This time around, we’re going to create a “Distance Joint” on the large heavy box in the middle:
private function createDistanceJoint():void { var boxWidth:Number = 50; var boxBody:b2BodyDef = new b2BodyDef(); boxBody.position = new b2Vec2(WIDTH/2/WORLD_SCALE, 420/WORLD_SCALE); var box:b2Body = world.CreateBody(boxBody); var boxShape:b2PolygonDef = new b2PolygonDef(); boxShape.SetAsBox(boxWidth/WORLD_SCALE, boxWidth/WORLD_SCALE); boxShape.density = .7; boxShape.friction = .3; boxShape.restitution = .4; box.CreateShape(boxShape); //instead of "SetMassFromShapes", I'm setting the box //mass extremely high to keep it swinging back and forth var massData:b2MassData = new b2MassData(); massData.mass = 1000; box.SetMass(massData); var joint:b2DistanceJointDef = new b2DistanceJointDef(); var anchor:b2Vec2 = new b2Vec2(); anchor = new b2Vec2(WIDTH/2/WORLD_SCALE, 250/WORLD_SCALE); joint.Initialize(box, world.m_groundBody, box.GetWorldCenter(), anchor); world.CreateJoint(joint); //start the box swinging box.m_linearVelocity = new b2Vec2(10, 0); var materialsList:MaterialsList = new MaterialsList(); materialsList.addMaterial(new WireframeMaterial(0xcc0000, 1, 6), "all"); var cube:Cube = new Cube(materialsList, boxWidth * 2, boxWidth * 2, boxWidth * 2); scene.addChild(cube); box.m_userData = cube; }
No comments yet.
Leave a comment
Search
Recent Posts
- MorphController - Mighty Morphing Papervision3D
- End dump
- Test if a plane is within the view of the camera (aka testing if culled)
- Materials Reference
- Perlin Blob
- Dynamic Text on a Plane
- Maya Texture Baking
- Creating a Custom VectorVision Font
- Workshop video and example dump
- 3D Math Book Recommendation
- Heading to New York. brb ;)
- Launching Flex4.org
- Flex 4 Layouts and Groups
- Flex 4 States
- How to click on stuff in Papervision3D - Viewport, ViewportLayers, InteractiveScene3DEvent, Mouse3D, and MovieMaterial Buttons
Recent Comments
- alexxcz on MorphController - Mighty Morphing Papervision3D
- andre venancio on 3D Math Book Recommendation
- DS on Dynamic Text on a Plane
- John Lindquist on Maya Texture Baking
- Itai on Maya Texture Baking
- Javier on End dump
- samBrown on End dump
- tf on archive
- Pan on requests
- Martin Lindelöf on requests

