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]

Reply via email to