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]

Reply via email to