[Papervision3D] - finding the 2D hitpoint from Camera-ray on a Cubes face.
Andy Zupko
azupko at zupko.info
Wed Mar 11 07:58:13 PST 2009
hitTestPoint2D does hit detection on the projected faces - its not
shooting a ray. By doing it at 0,0 you hit what is directly in front
of the camera. The renderHitData class contains the triangle3D that
was hit - i dont remember the exact property - but you can find it
pretty easily.
On Mar 11, 2009, at 10:18 AM, o renken wrote:
> Hey Andy,
>
> yes, youre assuming correct. the ray is pointing straight ahead in
> the direction the camera is looking. i attached some pictures below
> to visualize my intention. So in fact i want to know when this ray
> hits a specific face on a cube and of course, where ( 2D Coords on
> this plane).
> (In the pictures its only one(1) case. the camera may have all
> translations and rotations(x,y))
>
>
> Your 'Plane-setup' looks at least clear to me ill try it on this
> way, but iam not sure how you ment to find out when the ray hints
> the plane:
> viewport.hitTestPoint2D(new Point(0,0)); ?
> where do i get a face hit here? where is the ray from - is there a
> ray?
>
> thanks in advance,
> olee
>
>
>
> 2009/3/11 Andy Zupko <azupko at zupko.info>
> I think there needs to be a little more clarity on what you are
> trying to do. You can shoot a ray out of the camera in any
> direction - i assume you are talking about straight ahead?
>
> To pin a plane to a specific face, you could probably create a class
> that is extending do3d. Override project, and then, inside that
> (after the super call) - you can do something like this:
>
> var normal : Number3D = face.faceNormal;
> var point : Number3D = (position of face);
>
> then:
>
> Matrix3D.multiplyVector3x3(cube.transform, normal);
> Matrix3D.multiplyVector4x4(cube.transform, point);
>
> Plane3D.setNormalAndPoint(normal, point);
>
> This will have the plane in world space.
>
> If you want to get to face that is directly ahead of the camera, you
> can do it easily enough:
>
> viewport.hitTestPoint2D(new Point(0,0));
>
> That will return a RenderHitData object which contains the face hit,
> the object, the x/y/z of the hit, UV coordinates, etc.
>
> Otherwise you have to do a LOT more math to get that information
> accurately from a ray.
>
> hth.
>
>
>
> On Mar 11, 2009, at 8:54 AM, o renken wrote:
>
>>
>> Hey Visioners,
>>
>> in my current project i need to find out, when a camera looks a a
>> specific face of a cube and where the camera-ray hits this face
>> ( 2D coordinates)
>> My first thought is to handle this with a plane3D and
>> camera.unproject(). But now iam struggeling a bit with the handling
>> of the needed functions.
>>
>> Obiousely i have to 'pin' the plane3D to the face i want to
>> capture. this have to be done dynamically, cause the cube is able
>> to move and rotate around
>> so its position and rotation wont be the same eyerytime.
>> The camera is sometimes hovered around a target ( variable
>> distance) and sometimes free, with no target. So the
>> directionvector( the ray, correct?) of the camera has to be
>> calculated allone from its position and rotation.
>> Than it has to be compared with the plane3D, which is pinned to the
>> cubes face.
>>
>> In therory iam fine, but as i said, iam struggeling with the
>> correct usage of the methodes in Plane3D:
>>
>> My Question:
>>
>> - Which is the best or at least a good way to pin the plane3D to
>> the specific face of the cube ( also with the cubes tranlsations
>> and rotations)
>> Plane3D.fromThreePoints() ?
>>
>> - how to shoot the ray out of the camera depending to its rotation
>> and translation.
>>
>> - how to find out the 2Dpoint on the specific face of the cube:
>> Plane3D.getIntersectionLineNumbers(cameraPosition, ray) ?
>>
>>
>>
>> Any tips are very appreciated - have a nice day,
>> Olee
>>
>> --
>> http://www.renkster.de/
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
>
>
> --
> http://www.renkster.de/
> <
> 01
> .png
> >
> <
> 02.png><03.png><04.png>_______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090311/f098037c/attachment.html>
More information about the Papervision3D
mailing list