Developers!
This post is intended to bring several annotations since my first look at this wonderful “framework”. I don’t have a great English, but good vibrations I hope.
The first contact was curiously strange, I just download it and for weeks it steels untouchable because i had a lot of work at same time. The first time I could open the flash for study I try just to put something on the stage by pv3d.
(tip) - If u doesn’t know anybody who knows pv3d u can talk with people who works with 3d commons software’s. The same principles are used on pv3d as well you should read many tutorials and the right documentation of the version/release downloaded (important, LOL).
(My Objects in 3d) - Well, was not easy to understand the basics of pv3d. Try this basic template to get pv3d working at flash.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | package { //import many classes, yeah but only for tests! import caurina.transitions.Tweener; import org.papervision3d.scenes.*; import org.papervision3d.cameras.*; import org.papervision3d.objects.*; import org.papervision3d.objects.special.*; import org.papervision3d.objects.primitives.*; import org.papervision3d.materials.*; import org.papervision3d.materials.special.*; import org.papervision3d.materials.shaders.*; import org.papervision3d.materials.utils.*; import org.papervision3d.lights.*; import org.papervision3d.render.*; import org.papervision3d.view.*; import org.papervision3d.events.*; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.core.utils.*; import org.papervision3d.core.utils.virtualmouse.VirtualMouse; import flash.ui.*; import flash.utils.*; import flash.geom.*; import flash.display.*; import flash.events.*; import flash.filters.*; public class great_white_tpl extends Sprite { //variables papervision private var viewport:Viewport3D; private var scene:Scene3D; private var camera:Camera3D; private var renderer:BasicRenderEngine; public function great_white_tpl(){ initPapervision3D(); } public function initPapervision3D():void{ viewport = new Viewport3D(600, 400, true, true, true, true ); addChild(viewport); scene = new Scene3D(); camera = new Camera3D(); renderer = new BasicRenderEngine(); camera.zoom = 7; //rendering.... this.addEventListener(Event.ENTER_FRAME, render); } private function onMouse3dEvent ( ev: InteractiveScene3DEvent ): void { } private function render(e:Event){ renderer.renderScene(scene, camera, viewport); } } } |
Now you need to get a material, one “primitive object” and just put the material on an object. Then u can add this child to your scene3D. For tests i always use WireframesMaterial to play with something like a basic grid.
1 2 3 4 5 6 7 8 | //materials public var test_m:WireframeMaterial; //primitives public var test_p:Plane; test_m = new WireframeMaterial( 0x000000, 20, 1); test_p = new Plane(test_m, 100, 100, 2); scene.addChild(test_p); |
When have an item at stage from pv3d you have the flash proprieties of movieClips and now those specials like the proprieties “Z”, “rotationX”, “rotationY” and “rotationZ”. If you use Tweener for transitions you can use here too. Now get many items (materials and primitives objects) and change the special proprieties they got and make sth cool.
1 2 3 | test_p.z = 100; test_p.rotationZ = 100; test_p.rotationY = 100; |
Pv3d also have an extra object for the objects3d it can be use for store previous statements, check above.
1 | test_p.extra = {x: test_p._x, rafabarros:'anything here' } |
(Playing with Camera3d) - Here things come more difficulties not hard but not easy. Ok, let me explain it’s hard to do what are you intend for but it’s easy to modify proprieties and do anything like a “travel movement”. When you get pro skills this can be really simple. Camera3d on pv3d its sth like a real camera if u move the x, y, z all objects on Scene3d will be changed. If you are confused try to simulate objects in your real desk with random things just to practice the movements then back to action script. “write less, think more”.
1 2 3 4 5 6 7 8 | //(Methods on Materials) test_m.smooth = true; test_m.animated = true; test_m.interactive = true; //(Methods on Objects) test_p.useOwnContainer = true; |
Hmm you are asking how these objects can be interactive?
Right! (I was asking myself too), first ball you should understand what is listener’s and how it works on as3, pv3d use the same principles of the commons events, try this example for interact with an object3d.
1 2 3 4 5 | test_p.addEventListener (InteractiveScene3DEvent.OBJECT_OVER, onMouseOver ); private function onMouseOver( ev: InteractiveScene3DEvent ): void { trace(ev.currentTarget); } |
So now you have specials proprieties, know how to do events with objects 3d, know about playing with camera. Folks I think this is the basics of pv3d, want you comment!
XD