Papervision3D with Box2DFlash Part 2
Please view the previous “Hello World” example before looking at this one.
In part 2, we’re adding walls and cubes with the code below:
private function createWalls():void { var wallShapeDef:b2PolygonDef = new b2PolygonDef(); var wallBodyDef:b2BodyDef = new b2BodyDef(); var wall:b2Body; //Left and Right Shape Definition wallShapeDef.SetAsBox(100/WORLD_SCALE, (HEIGHT+40)/WORLD_SCALE/2); // Left wallBodyDef.position = new b2Vec2(-95 / WORLD_SCALE, HEIGHT/WORLD_SCALE/2); wall = world.CreateBody(wallBodyDef); wall.CreateShape(wallShapeDef); // Right wallBodyDef.position = new b2Vec2((WIDTH+95) / WORLD_SCALE, HEIGHT/WORLD_SCALE/2); wall = world.CreateBody(wallBodyDef); wall.CreateShape(wallShapeDef); }
private function createCubes():void { for (var i:Number = 0; i < 10; i++) { var boxWidth:Number = Math.random() * 20 + 10; var boxBody:b2BodyDef = new b2BodyDef(); boxBody.position = new b2Vec2(Math.random() * WIDTH / WORLD_SCALE, Math.random() * 50 /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 = .9; box.CreateShape(boxShape); box.SetMassFromShapes(); var materialsList:MaterialsList = new MaterialsList(); materialsList.addMaterial(new WireframeMaterial(Math.random() * 0xffffff), "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

