Finding 2d Vertices in a DisplayObject3D
This is kind of a ridiculous example, but it shows how you can loop through all of the vertices of a DisplayObject3D and pull out the 2d x and y coordinates.
The stars start out in random locations then tween to the vertices of the sphere.
package { import gs.TweenMax; import gs.easing.*; import org.papervision3d.core.geom.renderables.Vertex3D; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.view.BasicView; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class Finding2DVertexPoints extends BasicView { private var sphere:Sphere; private var stars:Array = []; private var vertices:Array = []; public function Finding2DVertexPoints() { sphere = new Sphere(new ColorMaterial(), 300, 15, 15); sphere.material.fillAlpha = 0; scene.addChild(sphere); //sphere.geometry.vertices is an array of vertex3D's //each vertex3D contains a vertex3DInstance which //has the 2d x and y property //long-hand sytax: sphere.geometry.vertices[i].vertex3DInstance.x for each(var vertex3D:Vertex3D in sphere.geometry.vertices) { var dummyStar:star = new star(); dummyStar.x = Math.random() * this.width; dummyStar.y = Math.random() * this.height; stars.push(dummyStar); this.addChild(dummyStar); //render once to calculate vertex data singleRender(); //push all the sphere's vertices into an array vertices.push(vertex3D.vertex3DInstance); } startTween(); } private function startTween():void { for(var i:int = 0; i<vertices.length; i++) { var time:Number = 4; var tweenObject:Object = {}; tweenObject.yoyo = true; tweenObject.ease = Quad.easeInOut; //assign the endpoint of the tween to vertices gathered above tweenObject.x = vertices[i].x + width/2; tweenObject.y = vertices[i].y + height/2; tweenObject.scaleX = tweenObject.scaleY = .2; tweenObject.bezierThrough = [{x:Math.random() * width, y:Math.random() * height}]; tweenObject.orientToBezier = true; TweenMax.to(stars[i], time, tweenObject); } } } }
-
Andre
-
Ian
-
bojan
-
Gabriel.Wang(From China)
-
bojan
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
- 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
- MorphController – Mighty Morphing Papervision3D
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
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

