Just tried using a perspective lens... Seems to work better. Although I can't explain why the y value needs to be negative in order to move it up. I thought a (10,10) position on the screen would require (-220, 140) for a screen and view size of 460x320. If I put in the following coordinates the object ends up near the 10,10 stage position:
var ray:Number3D = view.camera.unproject(-220, -140); var cameraPosition:Number3D = new Number3D(view.camera.x, view.camera.y, view.camera.z); ray.add(ray, cameraPosition); var p:Plane3D = new Plane3D(); p.fromNormalAndPoint(new Number3D(0, 1, 0),new Number3D(0, 0, 0)); var intersect:Number3D = p.getIntersectionLineNumbers(cameraPosition, ray); _3dObj.x = intersect.x; _3dObj.z = intersect.y; _3dObj.z = intersect.z; view.render(); On Jun 15, 3:10 pm, Michael Iv <[email protected]> wrote: > Tried perspective lens with default zoom?? > > > > > > On Tue, Jun 15, 2010 at 10:07 PM, JeffH <[email protected]> wrote: > > So I tried unsuccessfully using unproject like this: > > > Since _2dObj.x = 10; _2dObj.y = 10: > > var scenepos:Number3D = view.camera.unproject(10,10); // a point 10 > > pixels off the top left corner of the stage > > _3dObj.moveTo(scenepos.x,scenepos.y,scenepos.z); > > > This gives me the following approximate values (and so didn't move the > > 3D object to the upper left): > > scenepos.x = 0.2 , scenepos.y = 55 , scenepos.z = 82 > > > Is it something to do with my camera settings?: > > > view.camera = new HoverCamera3D({zoom:50}); > > view.camera.lens = new OrthogonalLens(); > > view.camera.position = new Number3D(0, -675, -1000); > > view.camera.lookAt(new Number3D(0, 0, 0)); > > > On Jun 15, 2:21 pm, Michael Iv <[email protected]> wrote: > > > I don't have a code for this exact scenario but you can doit this way: > > > Create a dummy object , any kind of sprite (can be invisible if you need) > > or > > > even generic Point class of flash.Get it to the position of view where > > you > > > want your 3d object to move in 2d . Unproject the 2d coordinates into 3d > > > space using camera.unproject() . This method returns Number3d that is > > > scene3d position of your object Then tween your 3d object to that > > position. > > > I think that should work for you. > > > :) > > > > On Tue, Jun 15, 2010 at 8:09 PM, JeffH <[email protected]> wrote: > > > > Hi Michael, > > > > > I really appreciate your help on this. Unfortunately, I feel like I'm > > > > flying blind. The docs don't indicate what unproject does so I'm > > > > unclear how to proceed. What would be really helpful is if you could > > > > post some code that would accomplish the following: > > > > > Given a stage size of 480x320 and a view that is similar in size but > > > > centered, move a 3d object from position 0,0,0 to the stage position > > > > 0,0. That is, move the 3D object from the center of the stage to the > > > > top left corner. If you could show me how unproject works with this > > > > example, that would be great! > > > > > Thanks again. > > > > > On Jun 15, 12:32 pm, Michael Iv <[email protected]> wrote: > > > > > Do unproject ! > > > > > > Sent from my iPhone > > > > > > On Jun 15, 2010, at 7:08 PM, JeffH <[email protected]> wrote: > > > > > > > I'm looking for: > > > > > > > screenPlace(view.camera, 2Dobject, 3Dobject) > > > > > > > function screenPlace(camera,obj2D,obj3D):void { > > > > > > some code > > > > > > obj3D.x = something > > > > > > obj3D.y = something > > > > > > } > > > > > > > Given a 3d object and a 2d location (from the stage), move my 3D > > > > > > object so that it sits on the 2d object's screen position. > > > > > > > On Jun 15, 11:40 am, Michael Iv <[email protected]> wrote: > > > > > >> yes it does , isn't it what you need? > > > > > > >> On Tue, Jun 15, 2010 at 5:36 PM, JeffH <[email protected]> wrote: > > > > > >>> Sorry, I meant "But isn't this is returning the 3D coords for a > > 2D > > > > > >>> point based on a 3D > > > > > >>> objects position?" > > > > > > >>> On Jun 15, 10:35 am, JeffH <[email protected]> wrote: > > > > > >>>> But isn't this is returning the 3D coords for a 3D point based > > on > > > > > >>>> a 3D > > > > > >>>> objects position? I think I need to do the opposite. Move a 3D > > > > > >>>> object > > > > > >>>> (its z=0 btw) to a 2D point based on an object on the stage. > > > > > >>>> Example, > > > > > >>>> move my 3D boat to a marker on a river where the marker is a 2D > > > > > >>>> flash > > > > > >>>> object on the stage. > > > > > > >>>> On Jun 15, 10:24 am, Michael Iv <[email protected]> wrote: > > > > > > >>>>> You are almost correct but you have got to give an offset to > > the > > > > > >>> coordiantes > > > > > >>>>> as view coord system is different from Scene3D > > > > > > >>>>> _spriteX=_screenVertex.x+_view.width*.5; > > > > > >>>>> _spriteY=_screenVertex.y + _view.height*.5; > > > > > > >>>>> On Tue, Jun 15, 2010 at 5:10 PM, JeffH <[email protected]> > > wrote: > > > > > >>>>>> Hi Michael, > > > > > > >>>>>> I'm probably just missing something really easy here but I've > > > > > >>>>>> seen > > > > > >>> the > > > > > >>>>>> following example code which just seems to be for moving a 2D > > > > > >>>>>> object > > > > > >>>>>> to a point in the 3D space. Can you show me an example of how > > I > > > > > >>>>>> would > > > > > >>>>>> move a 3D object based on a 2D point? Thanks for your help! > > > > > > >>>>>> screenPlace(view.camera, myMovieClip, 3Dobject) > > > > > > >>>>>> function screenPlace(camera,who,whob):void { > > > > > >>>>>> var sc:ScreenVertex; > > > > > >>>>>> sc = camera.screen(whob) > > > > > >>>>>> who.x = sc.x + view.x; > > > > > >>>>>> who.y = sc.y + view.y; > > > > > >>>>>> } > > > > > > >>>>>> On Jun 15, 9:36 am, Michael Iv <[email protected]> wrote: > > > > > >>>>>>> use ScreenVertex coordinates by accessing camera.screen() > > > > > >>>>>>> method . > > > > > >>>>>>> :) > > > > > > >>>>>>> On Tue, Jun 15, 2010 at 4:34 PM, JeffH <[email protected]> > > > > > >>>>>>> wrote: > > > > > >>>>>>>> Hi all. I wanted to get the experts' opinions on the best > > way > > > > > >>>>>>>> to > > > > > >>>>>>>> accomplish what I need to do. I have a 3D object (a boat) > > > > > >>>>>>>> that is > > > > > >>> in a > > > > > >>>>>>>> view with the camera set to a position and roll (45) to try > > and > > > > > >>>>>>>> achieve a "simcity" look. The settings are like this: > > > > > > >>>>>>>> view.camera.x = 675; view.camera.y = -675; view.camera.z = > > > > > >>>>>>>> -1300; > > > > > >>>>>>>> view.camera.roll(45); view.camera.lookAt(new Number3D(0, 0, > > > > > >>>>>>>> 0)); > > > > > > >>>>>>>> What I want to do is to move this object based on 2D points > > > > > >>> located on > > > > > >>>>>>>> the stage (for example, a path along a river). What is the > > best > > > > > >>> way to > > > > > >>>>>>>> do this? I did try converting 2D points to 3D by trying to > > get > > > > > >>> the > > > > > >>>>>>>> intersect of a ray off a plane but it doesn't seem to work. > > Not > > > > > >>> sure > > > > > >>>>>>>> if it is because I have a camera roll... I tried this based > > on > > > > > >>> some > > > > > >>>>>>>> other posts (where my 2D point is the var pt): > > > > > > >>>>>>>> var plane:Plane3D = new Plane3D(); > > > > > >>>>>>>> plane.fromNormalAndPoint(new Number3D(0, 1, 0), new > > Number3D(0, > > > > > >>> 0, > > > > > >>>>>>>> 0)); > > > > > >>>>>>>> var cameraPosition:Number3D = new Number3D(view.camera.x, > > > > > >>>>>>>> view.camera.y, view.camera.z); > > > > > >>>>>>>> var ray:Number3D = view.camera.unproject(pt.x, pt.y); > > > > > >>>>>>>> ray.add(ray, cameraPosition); > > > > > >>>>>>>> var intersect:Number3D = > > > > > >>>>>>>> plane.getIntersectionLineNumbers(cameraPosition, ray); > > > > > > >>>>>>>> But, intersect.x does not seem to align with pt.x on the > > > > > >>>>>>>> screen. > > > > > >>>>>>>> Perhaps I am misinterpreting how this should work? Should I > > try > > > > > >>> to > > > > > >>>>>>>> orient the stage (Flash CS4) the same way or can I leave > > that > > > > > >>> "flat" > > > > > >>>>>>>> and translate 2D coordinates to the 3D space? > > > > > > >>>>>>>> Anyway, thanks for any guidance! > > > > > > >>>>>>> -- > > > > > >>>>>>> Michael Ivanov ,Programmer > > > > > >>>>>>> Neurotech Solutions Ltd. > > > > > >>>>>>> Flex|Air > > > > > >>>>>> |3D|Unity|www.neurotechresearch.comhttp:// > > > > > >>>>>> blog.alladvanced.nethttp:// > > > > > >>>>>>www.meetup.com/GO3D-Games-Opensource-3D/ > > > > > >>>>>>> Tel:054-4962254 > > > > > >>>>>>> [email protected] > > > > > >>>>>>> [email protected] > > > > > > >>>>> -- > > > > > >>>>> Michael Ivanov ,Programmer > > > > > >>>>> Neurotech Solutions Ltd. > > > > > >>>>> Flex|Air > > > > > >>> |3D|Unity|www.neurotechresearch.comhttp:// > > > > > >>> blog.alladvanced.nethttp://www.meetup... > > > > > >>>>> Tel:054-4962254 > > > > > >>>>> [email protected] > > > > > >>>>> [email protected] > > > > > > >> -- > > > > > >> Michael Ivanov ,Programmer > > > > > >> Neurotech Solutions Ltd. > > > > > >> Flex|Air |3D|Unity|www.neurotechresearch.comhttp:// > > > > > >> blog.alladvanced.nethttp:// > >www.meetup.com/GO3D-Games-Opensource-3D/ > > > > > >> Tel:054-4962254 > > > > > >> [email protected] > > > > > >> [email protected] > > > > -- > > > Michael Ivanov ,Programmer > > > Neurotech Solutions Ltd. > > > Flex|Air > > |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp:// > >www.meetup.com/GO3D-Games-Opensource-3D/ > > > Tel:054-4962254 > > > [email protected] > > > [email protected] > > -- > Michael Ivanov ,Programmer > Neurotech Solutions Ltd. > Flex|Air > |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.nethttp://www.meetup.com/GO3D-Games-Opensource-3D/ > Tel:054-4962254 > [email protected] > [email protected]
