[Papervision3D] 2D coords from 3D in AS2

Trevor Burton worldofpaper at googlemail.com
Mon Jul 16 12:22:50 EDT 2007


possibly, yeah, i'll have a look - i haven't actually used Papervision for a
while so...

but sounds like you could be on the right track... i'm leaving work shortly
- i'll have a tinker with it when i get home if i get the chance...

T

On 7/16/07, jlm <jlm at justinfront.net> wrote:
>
> I am wondering if you are all making it too complex, I created some
> prototypes for flash awhile back that allowed you to use lineTo as 3d so I
> understand roughly where your coming from Trevor with the z equation.
>
> But it needn't be that difficult???
>
> looking quickly through the classes I found that in face3d's render, there
> is 2d drawing references, are these the same as the screen (using
> localToGlobal),
>
>         // Draw triangle
>                 container.moveTo( x0, y0 );
>                 container.lineTo( x1, y1 );
>                 container.lineTo( x2, y2 );
>
> so if you modified the face class to store a reference to container and
> x0,
> y0, x1,.....
>
> then modified the mesh and plane classes in a similar way... to store the
> corner face info...
>
> then could we not extract the info when we need to?
>
> Since you both know papervision much better than me, is it worth me going
> ahead and giving it a go or is my logic floored somewhere, just seems it
> is
> the render that is important time to get the info??
>
> I can't use the mouse hit info as it only gives hit coordinates? not
> corner
> ones, I need corners so I can map the video to the surface before tweening
> the corners in 2d.
>
> justin
>
>
>
> >On Mon, 16 Jul 2007 16:03:48  0100 "Trevor Burton"
> <worldofpaper at googlemail.com> wrote.
> >You're right, and you'd have to take into account the camera's position
> and
> >orientation, too - which starts to make it fairly complex - mouse events
> are
> >the way to go for user interaction.
> >
> >On 7/16/07, John Grden <neoriley at gmail.com> wrote:
> >>
> >> and the other issue that makes calculating it less attractive is that
> when
> >> you're doing the reverse projection, you have to calculate hit
> detection
> or
> >> deal with sorting issues.
> >>
> >> What if a if you have 2 other objects that are actually in the way?
> *You*
> >> know you can't see the face/object, but the object doesn't know this
> and
> >> hence we have a major issue with calculating 3D to 2D.
> >>
> >> So, it gets down to the actual faces level at this point, and I think
> >> using the flash player's ability to dispatch mouse events in
> conjunction
> >> with face containers starts to make alot of sense for this type use
> case.
> >>
> >> But then, again, I'm thinking out loud ;)
> >>
> >> On 7/16/07, Trevor Burton <worldofpaper at googlemail.com > wrote:
> >> >
> >> > Ok - here's a little tutorial... first of all a reminder about going
> >> > from 2D to 3D:
> >> >
> >> > to take an object from 2D to 3D you need to make it smaller the
> farther
> >> > away it is from the viewer, and vice versa - if we call the ratio of
> size to
> >> > distance perspectiveRatio then you can calculate perspectiveRatio
> like
> so:
> >> >
> >> > perspectiveRatio = perspectiveDepth / (perspectiveDepth   z)
> >> >
> >> > where perspectiveDepth is a number that represents the distance from
> the
> >> > viewer's eye to the screen (not really, but if you think of it like
> that
> >> > it's simpler).
> >> >
> >> > and where z is the distance into the screen that the object is.
> >> >
> >> > The answer would seem to lie in Vertices3D's project() function -
> >> >
> >> >  on line 138 (in my latest copy - not sure if it's up to date) you'll
> >> > find this line:
> >> >
> >> > persp  = focus / (focus   s_z) * zoom;
> >> >
> >> > followed by:
> >> >
> >> > screen.x = s_x * persp;
> >> > screen.y = s_y * persp;
> >> >
> >> > so s_x and s_y should be the original co-ordinates of the object -
> >> > before the perspective calculation is applied.
> >> >
> >> > i'll have a think about it and post a solution when i get time
> >> > tonight... unless someone beats me to it.
> >> >
> >> > T
> >> >
> >> > On 7/16/07, John Grden < neoriley at gmail.com> wrote:
> >> > >
> >> > > yeah I would love it if someone could come up with that formula -
> I've
> >> > > played and played and looked around for being able to do reverse
> projection
> >> > > calcs( I call it that, but that's not the technical term for it I
> don't
> >> > > think )
> >> > >
> >> > > I did talk to someone who had some experience with this and they
> seem
> >> > > to indicate that the calcs would be exponential in that you'd have
> to
> >> > > calculate rays back to the viewable area etc.  I haven't gone any
> further
> >> > > than that unfortunately, and I'm not sure he understood the problem
> >> > > completely, but his explanation did make some sense.
> >> > >
> >> > > In one test, I thought I had something going using Flash's 2D
> matrix,
> >> > > but it quickly fell apart ;)  That 3D dimension is a fun one ;)
> >> > >
> >> > > On 7/16/07, jlm <jlm at justinfront.net> wrote:
> >> > > >
> >> > > > I have been looking for some way to get the corners of a plane
> into
> >> > > > 2D, so I
> >> > > > can use sandy's distort class to map a video, and then tween it
> to
> a
> >> > > > quad
> >> > > > shape.
> >> > > >
> >> > > > I found this but do not believe there is projection class in
> >> > > > papervision
> >> > > > as2, and I am not sure what object.relative would be.
> >> > > >
> >> > > > var v:Vertex2D = (new Vertex3D(0,0,0)).project(new
> >> > > > Projection(Matrix3D.multiply(camera.getView(), object.relative
> ()),
> >> > > > camera.focus, camera.zoom));
> >> > > >
> >> > > > link
> >> > > >
> >> > > >
>
> http://groups.google.com/group/away3d-dev/browse_thread/thread/898a78770fc3911d
> >> > > >
> >> > > > trying to do something like
> >> > > >
> >> > > > private function release( _container )
> >> > > > {
> >> > > >
> >> > > > // ideas on how to make this?
> >> > > > var corners_array: Array = papervisionToGlobal( _container );
> >> > > >
> >> > > > renderVideo(corners_array);
> >> > > >
> >> > > > }
> >> > > >
> >> > > >
> >> > > > any help appreciated.
> >> > > >
> >> > > > Thanks
> >> > > >
> >> > > > Justin
> >> > > >
> >> > > >
> >> > > >
> >> > > > _______________________________________________
> >> > > > Papervision3D mailing list
> >> > > > Papervision3D at osflash.org
> >> > > > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > [  JPG  ]
> >> > > _______________________________________________
> >> > > Papervision3D mailing list
> >> > > Papervision3D at osflash.org
> >> > > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >> > >
> >> > >
> >> >
> >> >
> >> > --
> >> > Trevor Burton
> >> > http://www.paperworld3d.com
> >> > _______________________________________________
> >> > Papervision3D mailing list
> >> > Papervision3D at osflash.org
> >> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >> >
> >> >
> >>
> >>
> >> --
> >> [  JPG  ]
> >>
> >> _______________________________________________
> >> Papervision3D mailing list
> >> Papervision3D at osflash.org
> >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >>
> >>
> >
> >
> >--
> >Trevor Burton
> >http://www.paperworld3d.com
> >
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>



-- 
Trevor Burton
http://www.paperworld3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20070716/e6ce67fd/attachment.html 


More information about the Papervision3D mailing list