yes, ray and tris needs to be in same space. I've sended you my RayDebugger
class, should be visually obvious.
Working atm on other stuff using rays, I do see the trunk ray class can use
more handy stuffs.
So I hope in near future be able update it with more friendly, less expensive
and usefull hittests/returns
stay tuned
Fabrice
On May 5, 2010, at 1:09 PM, Michael Iv wrote:
> I was looking at the following function in BitmapMaterial Class:
> if(showNormals){
>
> _nn.rotate(tri.faceVO.face.normal,
> tri.view.cameraVarsStore.viewTransformDictionary[tri.source]);
>
> _sv0x = (tri.v0x + tri.v1x + tri.v2x) / 3;
> _sv0y = (tri.v0y + tri.v1y + tri.v2y) / 3;
>
> _sv1x = (_sv0x - (30*_nn.x));
> _sv1y = (_sv0y - (30*_nn.y));
>
> _session.renderLine(_sv0x, _sv0y, _sv1x, _sv1y, 0, 0xFF00FF,
> 1);
> }
> }
>
> And I can see ( if I am right) that you are setting _nn roation multiplying
> face normal by face matrix that was received from camera space .
> May be that is what has to be done when getting faces for getIntersection ?
>
> On Tue, May 4, 2010 at 12:11 PM, devlander <[email protected]> wrote:
> ok Fabrice.
> Please notify us if you can get something working ( this is a critical
> feature for my project ).
>
> Thanks for your support.
>
> On May 4, 9:44 am, Fabrice3D <[email protected]> wrote:
> > Looking at it asap as I need it as well...
> >
> > On May 4, 2010, at 7:18 AM, Michael Iv wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Now I can see I am not only one having that problem
> >
> > > Sent from my iPhone
> >
> > > On May 4, 2010, at 3:49 AM, devlander <[email protected]> wrote:
> >
> > >> =================================================================
> > >> Please forget about my previous post (many copy&past mistakes in the
> > >> code snippet)
> > >> =================================================================
> >
> > >> Here is my code (corrected):
> >
> > >> private function _pickMesh(mesh:Mesh):PickingResult {
> >
> > >> var pr:PickingResult = new PickingResult(); // Store picking
> > >> data here
> >
> > >> var rayPos:Number3D = view3D.camera.unproject(view3D.mouseX,
> > >> view3D.mouseY);
> >
> > >> var rayDir:Number3D = new Number3D();
> > >> rayDir.x = rayPos.x;
> > >> rayDir.y = rayPos.y;
> > >> rayDir.z = rayPos.z;
> > >> rayDir.normalize();
> > >> rayPos.add(rayPos, view3D.camera.position);
> >
> > >> var ray:Ray = new Ray();
> > >> var pickedPoint:Number3D;
> >
> > >> for each (var face:Face in mesh.faces) {
> >
> > >> pickedPoint = ray.getIntersect(rayPos , rayDir ,
> > >> face.v0.position , face.v1.position , face.v2.position);
> >
> > >> if (pickedPoint!=null) {
> > >> pr.hasHit = true;
> > >> pr.point = pickedPoint;
> > >> pr.face = face;
> > >> break;
> > >> }
> > >> }
> >
> > >> pr.mesh = mesh;
> >
> > >> return pr;
> >
> > >> }
> >
> > >> The problem is I always get null.
> >
> > >> Note: Since my mesh is a child of an Objectcontainer3D element I have
> > >> called mesh.applyRotations()
> > >> to make sure all the mesh faces are computed relative to the world
> > >> coord system.
> >
> > >> I suspect there is a problem in the computation of the ray params
> > >> (position or direction).
> >
> > >> Fabrice can you confirm that the signature of the Ray.getIntersect
> > >> method is as follow (no info is given in the class):
> >
> > >> p0: ray direction (or is it position ?)
> > >> p1: ray position [in world coord system] (or is it direction?)
> > >> v0: face.v0.position [in global world coord system]
> > >> v1: face.v1.position [in global world coord system]
> > >> v2: face.v2.position [in global world coord system]
> >
> > >> Thanks for any help on this.
> >
> > >> On May 4, 2:33 am, devlander <[email protected]> wrote:
> > >>> Hello, i am having the exact same problem here.
> >
> > >>> I am trying to determine the intersection on a 3D object at a given
> > >>> viewport location (view3D.mouseX, view3D.mouseY):
> >
> > >>> Here is my code:
> >
> > >>> private function _pickMesh(mesh:Mesh):PickingResult {
> >
> > >>> var pr:PickingResult = new PickingResult(); // Store picking
> > >>> data
> > >>> here
> >
> > >>> var rayPos:Number3D = view3D.camera.unproject(view3D.mouseX,
> > >>> view3D.mouseY);
> >
> > >>> // info retreived from here
> > >>>
> > >>> //http://www.mail-archive.com/[email protected]/msg09318.html
> >
> > >>> var rayDir:Number3D = new Number3D();
> > >>> rayDir.x = pMouse.x;
> > >>> rayDir.y = pMouse.y;
> > >>> rayDir.z = pMouse.z;
> > >>> rayDir.normalize();
> > >>> rayPos.add(rayPos, _view3D.camera.position);
> >
> > >>> var ray:Ray = new Ray();
> > >>> var pickedPoint:Number3D;
> >
> > >>> for each (var face:Face in mesh.faces) {
> >
> > >>> pickedPoint = ray.getIntersect(rayPos , rayDir ,
> > >>> face.v0.position ,
> > >>> face.v1.position , face.v2.position);
> >
> > >>> if (pickedPoint!=null) {
> > >>> pr.hasHit = true;
> > >>> pr.point = pickedPoint;
> > >>> pr.face = face;
> > >>> break;
> > >>> }
> > >>> }
> >
> > >>> pr.mesh = mesh;
> >
> > >>> return pr;
> >
> > >>> }
> >
> > >>> The problem is I always get null.
> >
> > >>> Note: Since my mesh is a child of an Objectcontainer3D element I have
> > >>> called mesh.applyRotations()
> > >>> to make sure all the mesh faces are computed relative to the world
> > >>> coord system.
> >
> > >>> I suspect there is a problem in the computation of the ray params
> > >>> (position or direction).
> >
> > >>> Fabrice can you confirm that the signature of the Ray.getIntersect
> > >>> method is as follow (no info is given in the class):
> >
> > >>> p0: ray direction (or is it position ?)
> > >>> p1: ray position [in world coord system] (or is it direction?)
> > >>> v0: face.v0.position [in global world coord system]
> > >>> v1: face.v0.position [in global world coord system]
> > >>> v2: face.v0.position [in global world coord system]
> >
> > >>> Thanks
> >
> > >>> On May 4, 12:17 am, Michael Iv <[email protected]> wrote:
> >
> > >>>> Fabrice i am trying it already for 4 hours with Sphere , but it
> > >>>> returns null
> > >>>> most of the time
> >
> > >>>> ///// it runs on enter frame////////////////
> > >>>> for(var i:int=0;i<_sf.faces.length;++
> > >>>> i){
> >
> > >>>> trace(_ray.getIntersect(_ray.orig,_ray.dir,_sf.faces[i].v0.position,_sf.faces[i].v1.position,_sf.faces[i].v2.position));
> > >>>> }
> > >>>> and basi
> >
> > >>>> On Tue, May 4, 2010 at 1:15 AM, Fabrice3D <[email protected]> wrote:
> > >>>>> dir, origin, v0, v1, v2
> > >>>>> to check if a ray hits a triangle
> >
> > >>>>> Fabrice
> >
> > >>>>> On May 3, 2010, at 9:43 PM, Michael Iv wrote:
> >
> > >>>>> Someone can tell me what are* v0,v1,v2* in*
> > >>>>> Ray.getIntersect(p0:Number3D,
> > >>>>> p1:Number3D, v0:Number3D, v1:Number3D, v2:Number3D):Number3D* ???
> > >>>>> Just can't find any example explaining these
> >
> > >>>>> Thanks!
> >
> > >>>>> --
> > >>>>> Michael Ivanov ,Programmer
> > >>>>> Neurotech Solutions Ltd.
> > >>>>> Flex|Air |3D|Unity|
> > >>>>>www.neurotechresearch.com
> > >>>>> Tel:054-4962254
> > >>>>> [email protected]
> > >>>>> [email protected]
> >
> > >>>> --
> > >>>> Michael Ivanov ,Programmer
> > >>>> Neurotech Solutions Ltd.
> > >>>> Flex|Air |3D|Unity|www.neurotechresearch.com
> > >>>> Tel:054-4962254
> > >>>> [email protected]
> > >>>> [email protected]
>
>
>
> --
> Michael Ivanov ,Programmer
> Neurotech Solutions Ltd.
> Flex|Air |3D|Unity|
> www.neurotechresearch.com
> Tel:054-4962254
> [email protected]
> [email protected]
>