Thanks Bob working perfectly now, hopefully they'll help us out in the next release :)
Do you think this could be converted to work in away3dlite also? On Jun 18, 10:59 am, Bob Warfield <[email protected]> wrote: > He doesn't want to create a screen object. In his case, for performance > reasons, but there are some problems with the screen object approach too > that I found. > > Wanting to do this is a common enough problem and comes up a lot if you go > looking for a solution in these forums. Not so many good answers to be > found though. It'd be great if some functionality was added to Away3D to > handle it correctly so people could quit asking. > > For my app, I wound up hacking some code from View3D: > > *private* *function* mouseTo3D(screenX:Number, screenY:Number, > screenZ:Number = 0):Number3D > > { > > * var* persp:Number = view.camera.zoom / view.camera.focus; > > * var* inv:Matrix3D = *new* Matrix3D(); > > inv = view.camera.invViewMatrix; > > * var* n3D:Number3D = *new* Number3D; > > n3D.x = screenX / persp * inv.sxx + screenY / persp * inv.sxy + screenZ > * inv.sxz + inv.tx; > > n3D.y = screenX / persp * inv.syx + screenY / persp * inv.syy + screenZ > * inv.syz + inv.ty; > > n3D.z = screenX / persp * inv.szx + screenY / persp * inv.szy + screenZ > * inv.szz + inv.tz; > > * return* n3D; > > } > > I was trying to create a continuous display of the coordinates of the mouse > cursor. I had several problems creating transparent planes for this > purpose. First, mouse move events are apparently not processed unless you > are rendering. I'm not rendering unless something changed because I have a > lot of other things to process and don't want to overhead. Second, the > View3D code hardwires the perspective model of PerspectiveLens and I'm using > the OrthogonalLens (reflected in the code above). It'd be nice if it would > get the info from the lens and not hardwire it. > > The biggest problem with this code is coming up with the right screenZ for > the mouse cursor. As you can see, I assume it is 0 most of the time, but if > the camera is in certain positions (haven't tracked it down) this gives a > way wrong answer. > > Cheers, > > BW > > On Fri, Jun 18, 2010 at 7:49 AM, savagelook > <[email protected]>wrote: > > > > > Are the away3d clipping/culling methods not working for you? > > >http://groups.google.com/group/away3d-dev/browse_thread/thread/ccbcab... > > The Camera3D.screen() method says in the source that the screen object > > can be passed for the first argument in place of an object. So for > > you it would be: > > > var sv:ScreenVertex = view.camera.screen(view.scene, yourVector3D); > > var x:Number = sv.x + view.x; > > var y:Number = sv.y + view.y; > > > On Jun 18, 10:26 am, Th3Sh33p <[email protected]> wrote: > > > I understand that a function such as this ... > > > > private function getScreenPos(ob:Object3D):Point{ > > > var posn:Vector3D = ob.viewMatrix3D.position > > > var screenX:Number = posn.x / posn.z; > > > var screenY:Number = posn.y / posn.z; > > > return new Point(screenX,screenY) > > > > } > > > > ...can find the 2D position of the 3D object, but how would I go about > > > finding the 2D position of a vector3D that hasn't been added to the > > > scene? > > > > I'm using this to find if a 3d object will appear on the screen if I > > > add it, that way I won't waste precious processing power on a unseen > > > object. > > > > Any help appreciated :)
