material
Collada with CellShader and PointLight3D
Pretty much the same as the last example, but this one has a Cell Shader overlaying the BitmapMaterial. Also, the light follows the camera as the camera orbits the collada model.
Drag mouse to orbit. Scroll wheel to zoom.

source
package { import flash.display.Bitmap; import flash.events.MouseEvent; import flash.utils.ByteArray; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.shaders.CellShader; import org.papervision3d.materials.shaders.ShadedMaterial; import org.papervision3d.objects.parsers.DAE; import org.papervision3d.view.BasicView; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class CellShadedCollada extends BasicView { [Embed(source="assets/c.DAE", mimeType = "application/octet-stream")] private var daeAsset:Class; [Embed(source="assets/materials/c.png")] private var materialAsset:Class; private var cameraPitch:Number = 90; private var cameraYaw:Number = 270; private var isOrbiting:Boolean = false; private var previousMouseX:Number; private var previousMouseY:Number; private var light:PointLight3D; public function CellShadedCollada() { var byteArray:ByteArray = new daeAsset() as ByteArray; var dae:DAE = new DAE(); dae.load(byteArray); var bitmap:Bitmap = new materialAsset() as Bitmap; var bitmapMaterial:BitmapMaterial = new BitmapMaterial(bitmap.bitmapData, true); light = new PointLight3D(); var cellShader:CellShader = new CellShader(light, 0xffffff, 0x000000, 10); var shadedMaterial:ShadedMaterial = new ShadedMaterial(bitmapMaterial, cellShader); dae.materials.addMaterial(shadedMaterial, "cMaterial"); scene.addChild(dae); startRendering(); stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler); } private function mouseWheelHandler(event:MouseEvent):void { camera.moveForward(10 * event.delta); } private function onMouseDown(event:MouseEvent):void { isOrbiting = true; previousMouseX = event.stageX; previousMouseY = event.stageY; } private function onMouseUp(event:MouseEvent):void { isOrbiting = false; } private function onMouseMove(event:MouseEvent):void { var differenceX:Number = event.stageX - previousMouseX; var differenceY:Number = event.stageY - previousMouseY; if(isOrbiting) { cameraPitch += differenceY; cameraYaw += differenceX; cameraPitch %= 360; cameraYaw %= 360; cameraPitch = cameraPitch > 0 ? cameraPitch : 0.0001; cameraPitch = cameraPitch < 90 ? cameraPitch : 89.9999; previousMouseX = event.stageX; previousMouseY = event.stageY; camera.orbit(cameraPitch, cameraYaw); light.position = camera.position; } } } }
3ds max texture baking for Papervision3D
Pablo Bandin made an excellent video tutorial on baking textures with 3ds max for Papervision3D:
http://pablobandin.wordpress.com/2008/11/29/howto-3dmax-texture-baking-papervision/
Thanks Pablo.
Plane with two different sides
Create two planes, rotate the back plane 180 degrees, then group them together in a parent DisplayObject3D.
package { import flash.display.Bitmap; import flash.display.MovieClip; import flash.events.Event; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.MovieMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.view.BasicView; [SWF(width="640", height="480", frameRate="60", backgroundColor="#000000")] public class TwoSidedPlane extends BasicView { [Embed(source="assets/fish.jpg")] public var fishAsset:Class; private var planeGroup:DisplayObject3D; private var planeFront:Plane; private var planeBack:Plane; private var fishMaterial:BitmapMaterial; private var movieMaterial:MovieMaterial; private var textField:TextField; public function TwoSidedPlane() { viewport.interactive = true; camera.zoom = 100; //this will hold both your planes in a group planeGroup = new DisplayObject3D(); //standard way to grab bitmap from embedded image var fishBitmap:Bitmap = new fishAsset() as Bitmap; fishMaterial = new BitmapMaterial(fishBitmap.bitmapData, true); planeFront = new Plane(fishMaterial); //a simple movieclip to hold our text field var movieClip:MovieClip = new MovieClip(); movieClip.graphics.lineStyle(5,0xcc0000); movieClip.graphics.drawRect(0,0,300,270); //text field and formatting junk textField = new TextField(); var textFormat:TextFormat = new TextFormat("Arial"); textFormat.size = 34; textFormat.color = 0xcc0000; textField.autoSize = TextFieldAutoSize.LEFT; textField.defaultTextFormat = textFormat; textField.text = "default"; movieClip.addChild(textField); movieMaterial = new MovieMaterial(movieClip, true, true, true); //smooth out the text movieMaterial.smooth = true; movieMaterial.interactive = true; planeBack = new Plane(movieMaterial); planeBack.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, objectOverHandler); planeBack.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, objectOutHandler); planeGroup.addChild(planeFront); /*rotate the plane in the "back" so it looks like the back side of the front*/ planeBack.rotationY = 180; planeGroup.addChild(planeBack); scene.addChild(planeGroup); startRendering(); } private function objectOverHandler(e:InteractiveScene3DEvent):void { textField.text = "That tickles!"; viewport.buttonMode = true; } private function objectOutHandler(e:InteractiveScene3DEvent):void { textField.text = "I'm lonely!"; viewport.buttonMode = false; } override protected function onRenderTick(event:Event=null):void { planeGroup.yaw(1); renderer.renderScene(scene, camera, viewport); } } }
BitmapViewportMaterial Example
You can easily render one scene into a usable material using BitmapViewportMaterial.
package { import flash.events.Event; import flash.filters.GlowFilter; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.BitmapViewportMaterial; import org.papervision3d.materials.shadematerials.FlatShadeMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.BasicView; import org.papervision3d.view.BitmapViewport3D; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class BitmapViewportMaterialExample extends BasicView { private var viewport2:BitmapViewport3D; private var scene2:Scene3D; private var sphere:Sphere; private var plane:Plane; public function BitmapViewportMaterialExample() { viewport.containerSprite.filters = [new GlowFilter(0xcc0000, 1, 10, 10, 4)]; //adds a red outline to the plane //will be rendered inside of the plane viewport2 = new BitmapViewport3D(); scene2 = new Scene3D(); var light:PointLight3D = new PointLight3D(); var sphereMaterial:FlatShadeMaterial = new FlatShadeMaterial(light, 0xcc0000); sphere = new Sphere(sphereMaterial, 400, 20, 20); scene2.addChild(sphere); //create a material of the above scene^^^ var material:BitmapViewportMaterial = new BitmapViewportMaterial(viewport2, true); material.doubleSided = true; plane = new Plane(material); scene.addChild(plane); startRendering(); } override protected function onRenderTick(event:Event = null):void { plane.localRotationY = viewport.containerSprite.mouseX; sphere.yaw(-1); //render the material scene renderer.renderScene(scene2, camera, viewport2); //render the main scene renderer.renderScene(scene, camera, viewport); } } }
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- FDT Super Awesome March Deal
- FDT Theme Designer
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
Recent Comments
- list of lpn courses on SpringCamera3D and Driving a Car
- rn to bsn in montgomery al on archive
- PowerPoint Recovery on Eclipse Theme Designer Preview
- cheat mw3 on Test if a plane is within the view of the camera (aka testing if culled)
- Goa Hotels on Looking around the inside of a Sphere
- cheat gratuit on Looking around the inside of a Sphere
- Application Development on Robotlegs + Flight + Union Platform
- nexium on Moving Faces
- buy nexium on Holy Sphere
- buy aldara online on Tweening a “moveForward()” behavior
Categories
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160



