Search Results

Search found 21 results on 1 pages for 'papervision3d'.

Page 1/1 | 1 

  • Flex, Papervision3d: basic scenes, cameras, planes issue

    - by user157880
    // Import Papervision3D import org.papervision3d.Papervision3D; import org.papervision3d.scenes.; import org.papervision3d.cameras.; import org.papervision3d.objects.; import org.papervision3d.materials.; public var scene:Scene3D; public var camera:Camera3D; public var target:DisplayObject3D; public var screenshotArray: Array;//array to store pictures public var radius:Number; public var image:Image; private function initPapervision():void { target= new DisplayObject3D(); camera= new Camera3D(target); 1067: Implicit coercion of a value of type org.papervision3d.objects:DisplayObject3D to an unrelated type Number. scene= new Scene3D(thisContainer); 1137: Incorrect number of arguments. Expected no more than 0. scene.addChild( new DisplayObject3D() , "center" ); } public function handleCreationComplete():void { image = new Image(); image.source = "one_t.jpg"; image.maintainAspectRatio = true; image.scaleContent = false; image.autoLoad = false; image.addEventListener(Event.COMPLETE, handleImageLoad); image.load(); initPapervision(); } public function handleImageLoad(event:Event):void { init3D(); // onEnterFrame addEventListener( Event.ENTER_FRAME, loop3D ); addEventListener( MouseEvent.MOUSE_MOVE , handleMouseMove); } public function init3D():void { addScreenshots(20); } public function handleMouseMove(event:MouseEvent):void { camera.y = Math.max( thisContainer.mouseY*5 , -450 ); } public function addScreenshots(planeCount:Number):void { var obj:DisplayObject3D = scene.getChildByName ("center"); screenshotArray = new Array(planeCount); var texture:BitmapData = new BitmapData(image.content.loaderInfo.width, image.content.loaderInfo.height, false, 0); texture.draw(image); // Create texture with a bitmap from the library var materialSpace :MaterialObject3D = new BitmapMaterial(texture); materialSpace.doubleSided = true; materialSpace.smooth = false; radius = 500; camera.z = radius + 50; camera.y = 50; for (var i:Number = 0; i < planeCount; i++ ) { screenshotArray[i] = new Object() <b>screenshotArray[i].plane = new Plane( materialSpace, 100, 100, 2, 2 );</b> 1180: Call to a possibly undefined method Plane. // Position plane var rotation:Number = (360/planeCount)* i ; var rotationRadians:Number = (rotation-90) * (Math.PI/180); screenshotArray[i].rotation = rotation; screenshotArray[i].plane.z = (radius * Math.cos(rotationRadians) ) * -1; screenshotArray[i].plane.x = radius * Math.sin(rotationRadians) * -1; screenshotArray[i].plane.y = 100; screenshotArray[i].plane.lookAt(obj); // Add to scene scene.addChild( screenshotArray[i].plane ); } <b>scene.renderCamera(camera);</b> <i>1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.</i> } public function loop3D(event:Event):void { var obj:DisplayObject3D = scene.getChildByName ("center"); for (var i:Number = 0; i < screenshotArray.length ; i++ ) { var rotation:Number = screenshotArray[i].rotation; rotation += (thisContainer.mouseX/50)/(screenshotArray.length/10); var rotationRadians:Number = (rotation-90) * (Math.PI/180); screenshotArray[i].rotation = rotation; screenshotArray[i].plane.z = (radius * Math.cos(rotationRadians) ) * -1; screenshotArray[i].plane.x = radius * Math.sin(rotationRadians) * -1; screenshotArray[i].plane.lookAt(obj); } //now lets render the scene <b>scene.renderCamera(camera);</b> <i>1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.</i> } ]]

    Read the article

  • How to Load a VRML model on PaperVision3d?

    - by DomingoSL
    Hello, im very new at papervision3d, i know in order to display a .DAE model i use this import flash.events.Event; import org.papervision3d.objects.parsers.DAE; [SWF(width=640, height=480, backgroundColor=0x808080, frameRate=30)] public class Earth extends PV3DARApp { private var _earth:DAE; public function Earth() { addEventListener(Event.INIT, _onInit); init('Data/camera_para.dat', 'Data/flarlogo.pat'); } private function _onInit(e:Event):void { _earth = new DAE(); _earth.load('model/amorfo.dae'); But how can i do in order to use VRML models (.WRL). Thanks.

    Read the article

  • flash core engine by Dinesh [closed]

    - by hdinesh
    This post was a dump of the following code (without the highlights). No question, just a dump. Please update this q. with a real question to have it reopened. You (the asker) risk to be flagged as spammer (if not already) and a bad reputation. This is a q/a site, not a site to promote your own code libraries. package facers { import flash.display.*; import flash.events.*; import flash.geom.ColorTransform; import flash.utils.Dictionary; import org.papervision3d.cameras.*; import org.papervision3d.scenes.*; import org.papervision3d.objects.*; import org.papervision3d.objects.special.*; import org.papervision3d.objects.primitives.*; import org.papervision3d.materials.*; import org.papervision3d.events.FileLoadEvent; 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.InteractiveScene3DEvent; import org.papervision3d.events.*; import org.papervision3d.core.utils.*; import org.papervision3d.core.geom.renderables.Vertex3D; import caurina.transitions.*; public class Main extends Sprite { public var viewport :BasicView; public var displayObject :DisplayObject3D; private var light :PointLight3D; private var shadowPlane :Plane; private var dataArray :Array; private var material :BitmapFileMaterial; private var planeByContainer :Dictionary = new Dictionary(); private var paperSize :Number = 0.5; private var cloudSize :Number = 1500; private var rotSize :Number = 360; private var maxAlbums :Number = 50; private var num :Number = 0; public function Main():void { trace("START APPLICATION"); viewport = new BasicView(1024, 690, true, true, CameraType.FREE); viewport.camera.zoom = 50; viewport.camera.extra = { goPosition: new DisplayObject3D(),goTarget: new DisplayObject3D() }; addChild(viewport); displayObject = new DisplayObject3D(); viewport.scene.addChild(displayObject); createAlbum(); addEventListener(Event.ENTER_FRAME, onRenderEvent); } private function createAlbum() { dataArray = new Array("images/thums/pic1.jpg", "images/thums/pic2.jpg", "images/thums/pic3.jpg", "images/thums/pic4.jpg", "images/thums/pic5.jpg", "images/thums/pic6.jpg", "images/thums/pic7.jpg", "images/thums/pic8.jpg", "images/thums/pic9.jpg", "images/thums/pic10.jpg", "images/thums/pic1.jpg", "images/thums/pic2.jpg", "images/thums/pic3.jpg", "images/thums/pic4.jpg", "images/thums/pic5.jpg", "images/thums/pic6.jpg", "images/thums/pic7.jpg", "images/thums/pic8.jpg", "images/thums/pic9.jpg", "images/thums/pic10.jpg"); for (var i:int = 0; i < dataArray.length; i++) { material = new BitmapFileMaterial(dataArray[i]); material.doubleSided = true; material.addEventListener(FileLoadEvent.LOAD_COMPLETE, loadMaterial); } } public function loadMaterial(event:Event) { var plane:Plane = new Plane(material, 300, 180); displayObject.addChild(plane); var _x:int = Math.random() * cloudSize - cloudSize/2; var _y:int = Math.random() * cloudSize - cloudSize/2; var _z:int = Math.random() * cloudSize - cloudSize/2; var _rotationX:int = Math.random() * rotSize; var _rotationY:int = Math.random() * rotSize; var _rotationZ:int = Math.random() * rotSize; Tweener.addTween(plane, { x:_x, y:_y, z:_z, rotationX:_rotationX, rotationY:_rotationY, rotationZ:_rotationZ, time:5, transition:"easeIn" } ); } protected function onRenderEvent(event:Event):void { var rotY: Number = (mouseY-(stage.stageHeight/2))/(900/2)*(1200); var rotX: Number = (mouseX-(stage.stageWidth/2))/(600/2)*(-1200); displayObject.rotationY = viewport.camera.x + (rotX - viewport.camera.x) / 50; displayObject.rotationX = viewport.camera.y + (rotY - viewport.camera.y) / 30; viewport.singleRender(); } } } package designLab.events { import flash.display.BlendMode; import flash.display.Sprite; import flash.events.Event; import flash.filters.BlurFilter; // Import designLab import designLab.layer.IntroLayer; import designLab.shadow.ShadowCaster; import designLab.utils.LayerConstant; // Import Papervision3D import org.papervision3d.cameras.*; import org.papervision3d.scenes.*; 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.InteractiveScene3DEvent; import org.papervision3d.events.*; import org.papervision3d.core.utils.*; import org.papervision3d.core.geom.renderables.Vertex3D; public class CoreEnging extends Sprite { public var viewport :BasicView; // Create BasicView public var displayObject :DisplayObject3D; // Create DisplayObject public var shadowCaster :ShadowCaster; // Create ShadowCaster private var light :PointLight3D; // Create PointLight private var shadowPlane :Plane; // Create Plane private var layer :LayerConstant; // Create constant resource layer private static var instance :CoreEnging; // Create CoreEnging class static instance // CoreEnging class static instance mathod function public static function getinstance() { if (instance != null) return instance; else { instance = new CoreEnging(); return instance; } } // CoreEnging constrictor public function CoreEnging () { trace("INFO: Design Lab Application : Core Enging v0.1"); layer = new LayerConstant(); viewport = new BasicView(900, 600, true, true, CameraType.FREE); // pass the width, height, scaleToStage, interactive, cameraType to BasicView viewport.camera.zoom = 100; // Define the zoom level of camera addChild(viewport); createFloor(); // Create the floor displayObject = new DisplayObject3D(); // Create new instance of DisplayObject viewport.scene.addChild(displayObject); // Add the DisplayObject to the BasicView light = new PointLight3D(); // Create new instance of PointLight light.z = -50; // Position the Z of create instance light.x = 0; //Position the X of create instance light.rotationZ = 45; //Position the rotation angel of the Z of create instance light.y = 500; //Position the Y of create instance shadowCaster = new ShadowCaster("shadow", 0x000000, BlendMode.MULTIPLY, .1, [new BlurFilter(20, 20, 1)]); // pass shadowcaster name, color, blend mode, alpha and filters shadowCaster.setType(ShadowCaster.SPOTLIGHT); // Define the shadow type addEventListener(Event.ENTER_FRAME, onRenderEvent); // Add frame render event } // Start create floor public function createFloor() { var spr:Sprite = new Sprite(); // Create Sprite spr.graphics.beginFill(0xFFFFFF); // Define the fill color for sprite spr.graphics.drawRect(0, 0, 600, 600); // Define the X, Y, width, height of the sprite var sprMaterial:MovieMaterial = new MovieMaterial(spr, true, true, true); //Create a texture from an existing sprite instance shadowPlane = new Plane(sprMaterial, 2000, 2000, 1, 1); // create new instance of the Plane and pass the texture material, width, height, segmentsW and segmentsH shadowPlane.rotationX = 80; //Position the rotation angel of the X of Plane shadowPlane.y = -200; //Position the Y of Plane viewport.scene.addChild(shadowPlane); // Add the Plane to the BasicView } // switch method function of the page layer control public function addLayer(type:String) { switch (type) { case layer.INTRO: var intro:IntroLayer = new IntroLayer(); break; } } // Create get mathod function for DisplayObject public function getDisplayObject():DisplayObject3D { return displayObject; } // Create get mathod function for BasicView public function getViewport():BasicView { return viewport; } // Rendering function protected function onRenderEvent(event:Event):void { var rotY: Number = (mouseY-(stage.stageHeight/2))/(900/2)*(1200); var rotX: Number = (mouseX-(stage.stageWidth/2))/(600/2)*(-1200); displayObject.rotationY = viewport.camera.x + (rotX - viewport.camera.x) / 50; displayObject.rotationX = viewport.camera.y + (rotY - viewport.camera.y) / 30; // Remove the shadow shadowCaster.invalidate(); // create new shadow on DisplayObject move shadowCaster.castModel(displayObject, light, shadowPlane); viewport.singleRender(); } } } package designLab.layer { import flash.display.Sprite; import flash.events.Event; // Import designLab import designLab.materials.iBusinessCard; import designLab.events.CoreEnging; // Import Papervision3D import org.papervision3d.objects.primitives.Cube; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.MovieMaterial; public class IntroLayer { // IntroLayer constrictor public function IntroLayer() { trace("INFO: Load Intro layer"); var indexDP:DP_index = new DP_index(); //Create the library MovieClip var blackMaterial:MovieMaterial = new MovieMaterial(indexDP, true); //Create a texture from an existing library MovieClip instance blackMaterial.smooth = true; blackMaterial.doubleSided = false; var mycolor:ColorMaterial = new ColorMaterial(0x000000); //Create solid color material var mycard:iBusinessCard = new iBusinessCard(blackMaterial, blackMaterial, mycolor, 372, 10, 207); // Create custom 3D cube object to pass the Front, Back, All, CubeWidth, CubeDepth and CubeHeight CoreEnging.getinstance().getDisplayObject().addChild(mycard.create3DCube()); // Add the custom 3D cube to the DisplayObject } } } package designLab.materials { import flash.display.*; import flash.events.*; // Import Papervision3D import org.papervision3d.materials.*; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.primitives.Cube; public class iBusinessCard extends Sprite { private var materialsList :MaterialsList; private var cube :Cube; private var Front :MovieMaterial = new MovieMaterial(); private var Back :MovieMaterial = new MovieMaterial(); private var All :ColorMaterial = new ColorMaterial(); private var CubeWidth :Number; private var CubeDepth :Number; private var CubeHeight :Number; public function iBusinessCard(Front:MovieMaterial, Back:MovieMaterial, All:ColorMaterial, CubeWidth:Number, CubeDepth:Number, CubeHeight:Number) { setFront(Front); setBack(Back); setAll(All); setCubeWidth(CubeWidth); setCubeDepth(CubeDepth); setCubeHeight(CubeHeight); } public function create3DCube():Cube { materialsList = new MaterialsList(); materialsList.addMaterial(Front, "front"); materialsList.addMaterial(Back, "back"); materialsList.addMaterial(All, "left"); materialsList.addMaterial(All, "right"); materialsList.addMaterial(All, "top"); materialsList.addMaterial(All, "bottom"); cube = new Cube(materialsList, CubeWidth, CubeDepth, CubeHeight); cube.x = 0; cube.y = 0; cube.z = 0; cube.rotationY = 180; return cube; } public function setFront(Front:MovieMaterial) { this.Front = Front; } public function getFront():MovieMaterial { return Front; } public function setBack(Back:MovieMaterial) { this.Back = Back; } public function getBack():MovieMaterial { return Back; } public function setAll(All:ColorMaterial) { this.All = All; } public function getAll():ColorMaterial { return All; } public function setCubeWidth(CubeWidth:Number) { this.CubeWidth = CubeWidth; } public function getCubeWidth():Number { return CubeWidth; } public function setCubeDepth(CubeDepth:Number) { this.CubeDepth = CubeDepth; } public function getCubeDepth():Number { return CubeDepth; } public function setCubeHeight(CubeHeight:Number) { this.CubeHeight = CubeHeight; } public function getCubeHeight():Number { return CubeHeight; } } } package designLab.shadow { import flash.display.Sprite; import flash.filters.BlurFilter; import flash.geom.Point; import flash.geom.Rectangle; import flash.utils.Dictionary; import org.papervision3d.core.geom.TriangleMesh3D; import org.papervision3d.core.geom.renderables.Triangle3D; import org.papervision3d.core.geom.renderables.Vertex3D; import org.papervision3d.core.math.BoundingSphere; import org.papervision3d.core.math.Matrix3D; import org.papervision3d.core.math.Number3D; import org.papervision3d.core.math.Plane3D; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.MovieMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; public class ShadowCaster { private var vertexRefs:Dictionary; private var numberRefs:Dictionary; private var lightRay:Number3D = new Number3D() private var p3d:Plane3D = new Plane3D(); public var color:uint = 0; public var alpha:Number = 0; public var blend:String = ""; public var filters:Array; public var uid:String; private var _type:String = "point"; private var dir:Number3D; private var planeBounds:Dictionary; private var targetBounds:Dictionary; private var models:Dictionary; public static var DIRECTIONAL:String = "dir"; public static var SPOTLIGHT:String = "spot"; public function ShadowCaster(uid:String, color:uint = 0, blend:String = "multiply", alpha:Number = 1, filters:Array=null) { this.uid = uid; this.color = color; this.alpha = alpha; this.blend = blend; this.filters = filters ? filters : [new BlurFilter()]; numberRefs = new Dictionary(true); targetBounds = new Dictionary(true); planeBounds = new Dictionary(true); models = new Dictionary(true); } public function castModel(model:DisplayObject3D, light:PointLight3D, plane:Plane, faces:Boolean = true, cull:Boolean = false):void{ var ar:Array; if(models[model]) { ar = models[model]; }else{ ar = new Array(); getChildMesh(model, ar); models[model] = ar; } var reset:Boolean = true; for each(var t:TriangleMesh3D in ar){ if(faces) castFaces(light, t, plane, cull, reset); else castBoundingSphere(light, t, plane, 0.75, reset); reset = false; } } private function getChildMesh(do3d:DisplayObject3D, ar):void{ if(do3d is TriangleMesh3D) ar.push(do3d); for each(var d:DisplayObject3D in do3d.children) getChildMesh(d, ar); } public function setType(type:String="point"):void{ _type = type; } public function getType():String{ return _type; } public function castBoundingSphere(light:PointLight3D, target:TriangleMesh3D, plane:Plane, scaleRadius:Number=0.8, clear:Boolean = true):void{ var planeVertices:Array = plane.geometry.vertices; //convert to target space? var world:Matrix3D = plane.world; var inv:Matrix3D = Matrix3D.inverse(plane.transform); var lp:Number3D = new Number3D(light.x, light.y, light.z); Matrix3D.multiplyVector(inv, lp); p3d.setNormalAndPoint(plane.geometry.faces[0].faceNormal, new Number3D()); var b:BoundingSphere = target.geometry.boundingSphere; var bounds:Object = planeBounds[plane]; if(!bounds){ bounds = plane.boundingBox(); planeBounds[plane] = bounds; } var tbounds:Object = targetBounds[target]; if(!tbounds){ tbounds = target.boundingBox(); targetBounds[target] = tbounds; } var planeMovie:Sprite = Sprite(MovieMaterial(plane.material).movie); var movieSize:Point = new Point(planeMovie.width, planeMovie.height); var castClip:Sprite = getCastClip(plane); castClip.blendMode = this.blend; castClip.filters = this.filters; castClip.alpha = this.alpha; if(clear) castClip.graphics.clear(); vertexRefs = new Dictionary(true); var tlp:Number3D = new Number3D(light.x, light.y, light.z); Matrix3D.multiplyVector(Matrix3D.inverse(target.world), tlp); var center:Number3D = new Number3D(tbounds.min.x+tbounds.size.x*0.5, tbounds.min.y+tbounds.size.y*0.5, tbounds.min.z+tbounds.size.z*0.5); var dif:Number3D = Number3D.sub(lp, center); dif.normalize(); var other:Number3D = new Number3D(); other.x = -dif.y; other.y = dif.x; other.z = 0; other.normalize(); var cross:Number3D = Number3D.cross(new Number3D(plane.transform.n12, plane.transform.n22, plane.transform.n32), p3d.normal); cross.normalize(); //cross = new Number3D(-dif.y, dif.x, 0); //cross.normalize(); cross.multiplyEq(b.radius*scaleRadius); if(_type == DIRECTIONAL){ var oPos:Number3D = new Number3D(target.x, target.y, target.z); Matrix3D.multiplyVector(target.world, oPos); Matrix3D.multiplyVector(inv, oPos); dir = new Number3D(oPos.x-lp.x, oPos.y-lp.y, oPos.z-lp.z); } //numberRefs = new Dictionary(true); var pos:Number3D; var c2d:Point; var r2d:Point; //_type = SPOTLIGHT; pos = projectVertex(new Vertex3D(center.x, center.y, center.z), lp, inv, target.world); c2d = get2dPoint(pos, bounds.min, bounds.size, movieSize); pos = projectVertex(new Vertex3D(center.x+cross.x, center.y+cross.y, center.z+cross.z), lp, inv, target.world); r2d = get2dPoint(pos, bounds.min, bounds.size, movieSize); var dx:Number = r2d.x-c2d.x; var dy:Number = r2d.y-c2d.y; var rad:Number = Math.sqrt(dx*dx+dy*dy); castClip.graphics.beginFill(color); castClip.graphics.moveTo(c2d.x, c2d.y); castClip.graphics.drawCircle(c2d.x, c2d.y, rad); castClip.graphics.endFill(); } public function getCastClip(plane:Plane):Sprite{ var planeMovie:Sprite = Sprite(MovieMaterial(plane.material).movie); var movieSize:Point = new Point(planeMovie.width, planeMovie.height); var castClip:Sprite;// = new Sprite(); if(planeMovie.getChildByName("castClip"+uid)) return Sprite(planeMovie.getChildByName("castClip"+uid)); else{ castClip = new Sprite(); castClip.name = "castClip"+uid; castClip.scrollRect = new Rectangle(0, 0, movieSize.x, movieSize.y); //castClip.alpha = 0.4; planeMovie.addChild(castClip); return castClip; } } public function castFaces(light:PointLight3D, target:TriangleMesh3D, plane:Plane, cull:Boolean=false, clear:Boolean = true):void{ var planeVertices:Array = plane.geometry.vertices; //convert to target space? var world:Matrix3D = plane.world; var inv:Matrix3D = Matrix3D.inverse(plane.transform); var lp:Number3D = new Number3D(light.x, light.y, light.z); Matrix3D.multiplyVector(inv, lp); var tlp:Number3D; if(cull){ tlp = new Number3D(light.x, light.y, light.z); Matrix3D.multiplyVector(Matrix3D.inverse(target.world), tlp); } //Matrix3D.multiplyVector(Matrix3D.inverse(target.transform), tlp); //p3d.setThreePoints(planeVertices[0].getPosition(), planeVertices[1].getPosition(), planeVertices[2].getPosition()); p3d.setNormalAndPoint(plane.geometry.faces[0].faceNormal, new Number3D()); if(_type == DIRECTIONAL){ var oPos:Number3D = new Number3D(target.x, target.y, target.z); Matrix3D.multiplyVector(target.world, oPos); Matrix3D.multiplyVector(inv, oPos); dir = new Number3D(oPos.x-lp.x, oPos.y-lp.y, oPos.z-lp.z); } var bounds:Object = planeBounds[plane]; if(!bounds){ bounds = plane.boundingBox(); planeBounds[plane] = bounds; } var castClip:Sprite = getCastClip(plane); castClip.blendMode = this.blend; castClip.filters = this.filters; castClip.alpha = this.alpha; var planeMovie:Sprite = Sprite(MovieMaterial(plane.material).movie); var movieSize:Point = new Point(planeMovie.width, planeMovie.height); if(clear) castClip.graphics.clear(); vertexRefs = new Dictionary(true); //numberRefs = new Dictionary(true); var pos:Number3D; var p2d:Point; var s2d:Point; var hitVert:Number3D = new Number3D(); for each(var t:Triangle3D in target.geometry.faces){ if( cull){ hitVert.x = t.v0.x; hitVert.y = t.v0.y; hitVert.z = t.v0.z; if(Number3D.dot(t.faceNormal, Number3D.sub(tlp, hitVert)) <= 0) continue; } castClip.graphics.beginFill(color); pos = projectVertex(t.v0, lp, inv, target.world); s2d = get2dPoint(pos, bounds.min, bounds.size, movieSize); castClip.graphics.moveTo(s2d.x, s2d.y); pos = projectVertex(t.v1, lp, inv, target.world); p2d = get2dPoint(pos, bounds.min, bounds.size, movieSize); castClip.graphics.lineTo(p2d.x, p2d.y); pos = projectVertex(t.v2, lp, inv, target.world); p2d = get2dPoint(pos, bounds.min, bounds.size, movieSize); castClip.graphics.lineTo(p2d.x, p2d.y); castClip.graphics.lineTo(s2d.x, s2d.y); castClip.graphics.endFill(); } } public function invalidate():void{ invalidateModels(); invalidatePlanes(); } public function invalidatePlanes():void{ planeBounds = new Dictionary(true); } public function invalidateTargets():void{ numberRefs = new Dictionary(true); targetBounds = new Dictionary(true); } public function invalidateModels():void{ models = new Dictionary(true); invalidateTargets(); } private function get2dPoint(pos3D:Number3D, min3D:Number3D, size3D:Number3D, movieSize:Point):Point{ return new Point((pos3D.x-min3D.x)/size3D.x*movieSize.x, ((-pos3D.y-min3D.y)/size3D.y*movieSize.y)); } private function projectVertex(v:Vertex3D, light:Number3D, invMat:Matrix3D, world:Matrix3D):Number3D{ var pos:Number3D = vertexRefs[v]; if(pos) return pos; var n:Number3D = numberRefs[v]; if(!n){ n = new Number3D(v.x, v.y, v.z); Matrix3D.multiplyVector(world, n); Matrix3D.multiplyVector(invMat, n); numberRefs[v] = n; } if(_type == SPOTLIGHT){ lightRay.x = light.x; lightRay.y = light.y; lightRay.z = light.z; }else{ lightRay.x = n.x-dir.x; lightRay.y = n.y-dir.y; lightRay.z = n.z-dir.z; } pos = p3d.getIntersectionLineNumbers(lightRay, n); vertexRefs[v] = pos; return pos; } } } package designLab.utils { public class LayerConstant { public const INTRO:String = "INTRO"; // Intro layer string constant } }*emphasized text*

    Read the article

  • Papervision3D: mouseEnabled = false on DisplayObject3D

    - by Josh
    How do I make a DisplayObject3D have mouseEnabled = false. I have a Sprite behind the Papervision3D scene listening for mouse events and so i need to let it pick up those mouse events through some of the DisplayObject3D objects. I've tried adding the DisplayObject3D to a separate ViewportLayer and setting thats mouseEnabled to false but that doesn't seem to work. Please help! Thanks.

    Read the article

  • Putting a MovieMaterial behind a DAE model in Papervision3D

    - by didibus
    Hi, I'm doing a project using FLARManager augmented reality and the Papervision3D library. Unfortunately, Papervision is giving me a lot of problems. My scene3D contains a DAE model and a plane. The plane has a MovieMaterial and is playing a video through FLVPlayback. The DAE and the plane are both inside the same DisplayObject3D container. FLARManager transforms the container so that everything appears through the angle of the marker. My DAE model is a TV, the screen of the TV is transparent. I want to have my Plane inside of my DAE model, so that the Movie playing on the plane material appears to be what is playing on the TV. The problem is that, even if the plane has a lower Z index then the TV, it always appears in front of the TV. How do I have my plane and its MovieMaterial appear behind the TV, so that some of its corners are cut out by the TV and the part of the TV thats transparent let me see the Movie? If its impossible, anyone has an idea of how I could get the desired effect of having a movie play on the screen of my DAE tv model? Thank You.

    Read the article

  • error insert text in papervision typography class

    - by safeDomain
    hi evryone , i am encounter with a small problem i want to make a 3d rtl text animation with papervision this code generet a problem to this : [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference. but when using a english text this error dont genereta my code : package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.scenes.Scene3D import org.papervision3d.view.Viewport3D import org.papervision3d.cameras.Camera3D import org.papervision3d.render.BasicRenderEngine import org.papervision3d.typography.Font3D import org.papervision3d.typography.fonts.HelveticaBold import org.papervision3d.typography.Text3D import org.papervision3d.materials.special.Letter3DMaterial import flash.text.engine.FontDescription import flash.text.engine.ElementFormat import flash.text.engine.TextElement import flash.text.engine.TextBlock import flash.text.engine.TextLine /** * ... * @author vahid */ public class Main extends Sprite { private var fd:FontDescription private var ef:ElementFormat private var te:TextElement protected var st:String; private var scene:Scene3D private var view:Viewport3D private var camera:Camera3D private var render:BasicRenderEngine private var vpWidth:Number = stage.stageWidth; private var vpHeight:Number = stage.stageHeight; private var text3d:Text3D private var font3d:Font3D //private var font:HelveticaBold private var textMaterial:Letter3DMaterial private var text:String public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // rtl block fd = new FontDescription () ef = new ElementFormat (fd) te = new TextElement ("?????? ?????? ???? ?????? ?? papervision", ef) text = te.text //3d block scene = new Scene3D () view = new Viewport3D (vpWidth,vpHeight,true,true,false,false) camera = new Camera3D () render = new BasicRenderEngine() addChild (view) this.addEventListener (Event.ENTER_FRAME , renderThis) textMaterial = new Letter3DMaterial(0xFF0000,1) font3d = new HelveticaBold() text3d = new Text3D (text, font3d, textMaterial) scene.addChild (text3d) } protected function renderThis(e:Event):void { text3d.rotationY +=5 render.renderScene(scene,camera,view) } } } i am using flashdevelop. please help me thank's

    Read the article

  • Debugging FLEX/AS3 memory leaks

    - by Scott Evernden
    I have a pretty big Flex & Papervision3D application that creates and destroys objects continually. It also loads and unloads SWF resource files too. While it's running the SWF slowly consumes memory til about 2GB when it croaks the player. Obviously I am pretty sure I let go of reference to instances I no longer want with expectation the GC will do its job. But I am having a heck of a time figuring out where the problem lies. I've tried using the profiler and its options for capturing memory snapshots, etc - but my problem remains evasive. I think there are known problems using debug Flash player also? But I get no joy using the release version either. How do you go about tracking down memory leak problems using FLEX/AS3 ? What are some strategies, tricks, or tools you have used to locate consumption

    Read the article

  • Papervision 3D: How can I force dimensions on a collada file

    - by imadethisthing
    Hey everyone, I'm working with Collada files and I need them to be a certain size. When instantiating them in pv3d you set the filename, materials, and scale. Scale works like a percentage, and there's no way to get the width, height, or depth of the DAE once in flash. I want to be able to specify the size of DAE in 3D space relative to other pv3d native geometry.

    Read the article

  • Adobe Flash or After Effects: How to make a piece of virtual paper blow away?

    - by Allen G
    About a month ago I saw a portfolio website in Flash that featured a stack of cards, and each time you clicked on it, they sort of blew all over the place, thus exposing the backs as videos and pictures. Although I could easily take a bunch of 3D planes and tween them to turn and flip, these cards actually seemed to 'bend'. How is this effect achieved? Sorry I don't have the link to the example. Thanks!

    Read the article

  • How to fix rotations in a Rubik's Cube?

    - by Eindbaas
    I'm trying to create a Rubik's Cube in Flash & Papervision and i'm really stuck here. I'm up to the point where i can rotate any plane of cubes once, but after that...it's messed up because all local coordinate systems are messy. I dont really know where to go from here, can anybody give any advice on what do do? I'm not looking for 'read about transformation matrices', i know i should (and i am doing that), but i'm not really sure what to look for. My idea is that, after each rotation, i should fix each coordinate system of each cube again, but i have no idea how. Any hints on what i want to achieve (in words), and why, are much appreciated. http://dl.dropbox.com/u/250155/rubik/main.html (you can press the K key once ;) )

    Read the article

  • 3ds collada UV mapping problem in Papervision

    - by MonsieurOreilles
    Hi everyone, as I briefly explained in the title, my prblem concerns texturing a collada export in papervision. Basically I was exporting collada models from Cinema 4d with its uv map. I was able to see everything, but the texture was not displaying properly (hidden polygons). So I decided to try with 3dsMax. I used the same code to display the texture : var materials:MaterialsList = new MaterialsList(); var torusMaterial:BitmapFileMaterial = new BitmapFileMaterial("model/tex.png"); torusMaterial.precise = true; materials.addMaterial(torusMaterial, "ID1"); Again, I can see every elements, but this time my model uses only one pixel of my texture. So if I use a red texture and if I color only the pixel at the left bottom corner in green, all my model will be green. Any advice about how to properly wrap the texture around a 3ds export model ? Thank you.

    Read the article

  • Shader vs Shader Material , papervision specific , general insight welcome.

    - by RadAdam
    hello overflow. I asked this question on the pv3d forum and not a single person could, or cared to answer it. Im relatively new to 3d so i apologize if this is common sense to some. I have a sphere , in which i am applying a CellMaterial to. Looks great. I noticed that in the papervision sdk , there is also a CellShader. Should I be using this in congruence with the CellMaterial ? Should it be one or the other ? Is shader , a deprecated practice to Shader Material ? My initial thoughts were that the shader applies to the whole scene , while materials can be applied uniquely to objects. The documentation seems to show otherwise. What benefit if any could be gained by using both a CellShader and a CellMaterial ? id really love to get some ambient inclusion in there some how.

    Read the article

  • interactive (adding listeners to) DAE model in flex + papervision

    - by G. Matthieu
    I have a DAE model that is parsed into several parts. I am able to deal with them separately, such as changing their material or colour but I am having problems adding click or hover listeners over the children. For example, lets say I have a model of a kitty where each facial feature is a child. I want to be able to hover or click the features and have a window pop up explaining the feature. I've tried parsing the model and adding listeners but it doesn't seem to work. Thanks in advance! L

    Read the article

  • Intermittent/staggered loading of an object

    - by cammy
    Hi guys, I've just recently tried my hand at actionscript 3 and have come across a road block. How do I go about rendering the cubes (cube1) intermittently, ie. staggered loading. I need the cubes to load a split second from each other. Below is a snippet of what I have so far: var rows:int = 5; var cols:int = 3; var spacery:int = 100; var spacerx:int = 120; var box_count:int = 8; for(var i:int; i < box_count; i++) { cube1 = new Cube(ml,100,10,80,1,1,1); cube1.y = ((i % rows)) * (cube1.x + spacery); cube1.x = Math.floor(i/rows) * (cube1.x +spacerx); cube1.z = 0; bigBox.addChild(cube1); }

    Read the article

  • How do I 'addChild' an DisplayObject3d from another class? (Papervision3d)

    - by Sandor
    Hi All Im kind of new in the whole papervision scene. For a school assignment I'm making a panorama version of my own room using a cube with 6 pictures in it. It created the panorama, it works great. But now I want to add clickable objects in it. One of the requirements is that my code is OOP focused. So that's what I am trying right now. Currently I got two classes - Main.as (Here i make the panorama cube as the room) - photoWall.as (Here I want to create my first clickable object) Now my problem is: I want to addChild a clickable object from photoWall.as to my panorama room. But he doesn't show it? I think it has something to do with the scenes. I use a new scene in Main.as and in photoWall.as. No errors or warnings are reported This is the piece in photoWall.as were I want to addChild my object (photoList): private function portret():void { //defining my material for the clickable portret var material : BitmapFileMaterial = new BitmapFileMaterial('images/room.jpg'); var material_list : MaterialsList = new MaterialsList( { front: material, back: material } ); // I don't know if this is nessecary? that's my problem scene = new Scene3D(); material.interactive = true; // make the clickable object as a cube var photoList : DisplayObject3D = new Cube(material_list, 1400, 1400, 1750, 1, 4, 4, 4); // positioning photoList.x = -1400; photoList.y = -280; photoList.z = 5000; //mouse event photoList.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, onPress); // this is my problem! I cannot see 'photoList' within my scene!!! scene.addChild(photoList); // trace works, so the function must be loaded. trace('function loaded'); } Hope you guys can help me out here. Would really be great! Thanks, Sandor

    Read the article

  • Include all imports in Air application Bundle?

    - by Carlos Barbosa
    How can I import all files and classes into my AIR bundle... it must take a note that I created first a flex project, and set it's main class as Actionscript (.as) . When I build a release all my imports (org) etc.. are not included in the .AIR installer... i have checked this by installing the app and then after show package contents, notice that the diretory structure exists but it doesn't include any of other .as used as imports... import org.papervision3d.cameras.Camera3D; import org.papervision3d.materials.BitmapFileMaterial; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.DisplayObject3D;

    Read the article

  • Adding button in Actionscript code : Using Flex Builder

    - by dta
    I created a new actionscript project using Flex Builder 3 and tried to run the following file. I get this error : Definitions: fl.controls:Button could not be found. All I want to do is, to add a button to the application. How could I do it? package { import PaperBase; import org.papervision3d.objects.primitives.Cone; import fl.controls.Button; import fl.controls.Label; import fl.events.ComponentEvent; public class cone1 extends PaperBase { public var cone:Cone = new Cone(); protected var sceneWidth:Number; protected var sceneHeight:Number; public function cone1() { sceneWidth = stage.stageWidth sceneHeight = stage.stageHeight; init(sceneWidth*0.5,sceneHeight*0.5);//position of the cone } override protected function init3d():void { cone.scale = 5; cone.pitch(-40) default_scene.addChild(cone); } override protected function processFrame():void { cone.yaw(1);//rotation speed } } }

    Read the article

1