What I need is a way to get the 2D (i.e. screen) co-ordinates of an
Object3D without use of the mouse - any ideas?
Yes, there's no easy default way.
However, something like
var v:Vertex2D = (new Vertex3D(0,0,0)).project(new
Projection(Matrix3D.multiply(camera.getView(), object.relative()),
camera.focus, camera.zoom));
should return object's center position on screen - probably should be
added to View3D's api.
wbr,
Alexander
What I'm trying to do is implement a trackball-type rotation.
On Jun 27, 3:55 pm, "Alexander Zadorozhny"
<alexander.zadoroz...@gmail.com> wrote:
> Hi Voodoo
>
> Yes, there's no easy default way.
> However, something like
>
> var v:Vertex2D = (new Vertex3D(0,0,0)).project(new
> Projection(Matrix3D.multiply(camera.getView(), object.relative()),
> camera.focus, camera.zoom));
>
> should return object's center position on screen - probably should be
> added to View3D's api.
>
> wbr,
> Alexander
>
function 2Dto3D(view:View3D, screenX:Number, screenY:Number,
screenZ:Number = 10000) {
var persp:Number = zoom / (1 + screenZ /
view.camera.focus);
var inv:Matrix3D = Matrix3D.inverse(getView());
var worldX:Number;
var worldY:Number;
var worldZ:Number;
worldX = screenX / persp * inv.n11 + screenY / persp *
inv.n12 + screenZ * inv.n13 + inv.n14;
worldY = screenX / persp * inv.n21 + screenY / persp *
inv.n22 + screenZ * inv.n23 + inv.n24;
worldZ = screenX / persp * inv.n31 + screenY / persp *
inv.n32 + screenZ * inv.n33 + inv.n34;
return new Number3D(worldX,worldY,worldZ);
}
Cheers,
Josh
On Jun 30, 1:15 pm, "Collin Cusce" <rafaja...@gmail.com> wrote:
> Still a problem. Any ideas?
>
> On 6/29/07, Collin Cusce <rafaja...@gmail.com> wrote:
>
>
>
> > Nah, that's not the problem...
>
> > Notice as you move the mouse the distance between the target and the mouse
> > becomes greater as the distance from the mouse to the origin becomes
> > greater. It doesnt scale.
>
> > On 6/29/07, Peter Kapelyan <flashn...@gmail.com> wrote:
>
> > > Yes it works!
> > > Now just shift mouse stage over - for the scene shift it on the X minus
> > > whole or half stage.width...
> > > It look right to me
>
> > > On 6/29/07, Collin Cusce <rafaja...@gmail.com > wrote:
>
> > > > Doesnt work.
> > > > see?
>
> > > >http://larry.onlinekarma.net/Flex%20Builder%202/Stalaga/bin/Stalaga.swf
>
> > > > On 6/29/07, Peter Kapelyan <flashn...@gmail.com > wrote:
>
> > > > > 1. your camera is center
> > > > > 2. place crosshair at camera...
> > > > > 3. crosshair.lookAt();crosshair.moveBackward(somenum)
> > > > > 4. crosshair.moveLeft()/crosshair.moveRight() based off stage.mousex
>
> > > > > This should work?
> > > > > -Pete
>
> I've had a look around but can't find any native function...
Function screen(object:Object3D, vertex:Vertex = null):ScreenVertex is
back at the Camera3D class.
camera.screen(mesh) returns mesh center on screen, and
camera.screen(mesh, vertex) returns vertex relative to the mesh on the
screen.
wbr,
Alexander
public function screen(object:Object3D, vertex:Vertex3D =
null):Vertex2D {
if (vertex == null) vertex = new Vertex3D(0,0,0);
return vertex.project(new
Projection(Matrix3D.multiply(getView(), object.transform), focus,
zoom));
}
That's how the function should look in the old rev if you need to add
it to Camera3D ...Camera3D then needs to import Vertex3D, Vertex2D and
core.render.Projection.
Side note: I just spent an angst-ridden few hours trying to shoehorn
my code into the new revision -- it's a lot of code, hundreds and
hundreds of errors -- I finally just gave up and committed myself to
making modifications on an as-needed basis. I want to get onto the new
version for my next project, but is there word on the reunion with
PV3D? Is there going to be another major change to the code base
anytime soon?
I'm confused about the Camera3D.screen method returning a
ScreenVertex, though, which has x,y,z. How is that converted to x,y on
screen?
Thanks,
-Gabriel
On Jul 16, 7:40 am, "Alexander Zadorozhny"
<alexander.zadoroz...@gmail.com> wrote:
> Hi Voodoo
>
> > I've had a look around but can't find any native function...
>
> Function screen(object:Object3D, vertex:Vertex = null):ScreenVertexis
> back at the Camera3D class.
> camera.screen(mesh) returns mesh center on screen, and
> camera.screen(mesh, vertex) returns vertex relative to the mesh on the
> screen.
>
> wbr,
> Alexander
>
public function screenZ(object:Object3D, vertex:Vertex3D =
null):Vertex2D {
if (vertex == null) {
vertex = new Vertex3D(0,0,0);
}
moveForward(focus);
rotationX -= 90;
moveBackward(focus);
var v2:Vertex2D = vertex.project(new
Projection(Matrix3D.multiply(getView(), object.transform), focus,
zoom));
moveForward(focus);
rotationY += 90;
moveBackward(focus);
return v2.x;
}
...but it works...
> > camera.screen (mesh, vertex) returns vertex relative to the mesh on the
> > screen.
>
> > wbr,
> > Alexander
>
> > On 6/26/07, voodoowizard <kyom...@googlemail.com > wrote:
>
> > > I've had a look around but can't find any native function...
>
> > > What I need is a way to get the 2D (i.e. screen) co-ordinates of an
> > > Object3D without use of the mouse - any ide
On Sep 7, 10:26 am, "Rob Bateman" <rob.bate...@gmail.com> wrote:
> holy crap!
>
> yes, the new ScreenVertex removes the need for this... terrible thing! depth
> of field is set as a z property. I guess it would also make sense to have a
> scaling value carried inside, because at present you'd have to do perspScale
> = camera.zoom/(1+sVertex.z/camera.focus) which is a little incovenient...
>
> Rob
>
> > > > camera.screen(mesh, vertex) returns vertex relative to the mesh on the
> > > > screen.
>
> > > > wbr,
> > > > Alexander
>
> > > > On 6/26/07, voodoowizard <kyom...@googlemail.com> wrote:
>
> > > > > I've had a look around but can't find any native function...
>
> > > > > What I need is a way to get the 2D (i.e. screen) co-ordinates of an
> > > > > Object3D without use of the mouse - any ide
>
> --
> Rob Bateman
> Flash Development & Consultancy
>
> Work: 0207 4823328
> Mobile: 07714 329 073
>
> > Projection(Matrix3D.multiply (getView(), object.transform), focus,
> > zoom));
> > moveForward(focus);
> > rotationY += 90;
> > moveBackward(focus);
> > return v2.x;
> > }
>
> > ...but it works...
>
> > On Sep 6, 1:17 am, Gabriel Jensen < gabr...@pizmogames.com> wrote:
> > > First off, props to the devs for all their hard work. I'm developing a
> > > 3D puzzle game for my site pizmogames.com , and Away3D is really