pivot point
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); } } }
Mouse3D moving light
Mouse3D is bound to the interactiveSceneManager of your viewport. So to get the 3d “renderHitData” of where your mouse is, you need to:
Mouse3D.enabled = true; viewport.interactive = true; mouse3D = viewport.interactiveSceneManager.mouse3D;
Then you can get 3d data from your mouse3D object like you would any other DisplayObject3D. Just remember the mouse will need to be over an object with a “material.interactive = true” to get any data back.
package { import flash.events.Event; import flash.ui.Mouse; import org.papervision3d.core.utils.Mouse3D; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.shadematerials.PhongMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class Mouse3DExample extends BasicView { private var mouse3D:Mouse3D; private var pivotPoint:DisplayObject3D; private var light:PointLight3D; public function Mouse3DExample() { var headerText:headerContainer = new headerContainer(); headerText.header.text = "Mouse over the sphere to move the light"; addChild(headerText); viewport.interactive = true; Mouse3D.enabled = true; mouse3D = viewport.interactiveSceneManager.mouse3D; light = new PointLight3D(true); pivotPoint = new DisplayObject3D(); var material:PhongMaterial = new PhongMaterial(light, 0xcc0000, 0x000000, 10); material.interactive = true; var sphere:Sphere = new Sphere(material, 500, 30, 30); sphere.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, objectOverHandler); sphere.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, objectOutHandler); var smallSphere1:Sphere = new Sphere(new PhongMaterial(light, 0x00cc00, 0x000000, 10), 100, 10, 10); var smallSphere2:Sphere = new Sphere(new PhongMaterial(light, 0x0000cc, 0x000000, 10), 100, 10, 10); smallSphere1.x = -500; smallSphere1.y = 500; smallSphere2.x = 400; smallSphere2.y = -600; pivotPoint.addChild(smallSphere1); pivotPoint.addChild(smallSphere2); scene.addChild(sphere); scene.addChild(pivotPoint); scene.addChild(light); addEventListener(Event.ENTER_FRAME, enterFrameHandler); } private function objectOverHandler(event:InteractiveScene3DEvent):void { Mouse.hide(); } private function objectOutHandler(event:InteractiveScene3DEvent):void { Mouse.show(); } private function enterFrameHandler(event:Event):void { pivotPoint.yaw(1); pivotPoint.pitch(.5); light.copyTransform(mouse3D); light.moveBackward(100); singleRender(); } } }
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
- Ocatarinabelachichix on about
- Rajiv on faq
- Rajiv on 3ds max texture baking for Papervision3D
- Anupam Biswas on Maya Texture Baking
- Anupam Biswas on Maya Texture Baking
- Arindam Mojumder on requests
- Arindam Mojumder on requests
- Arindam Mojumder on Full Screen Cube
- Arindam Mojumder on faq
- Mimosa123321 on requests
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



