Lines3D.hitTestObject

View: New views
2 Messages — Rating Filter:   Alert me  

Lines3D.hitTestObject

by M-A Lavoie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a Lines3D, with only one line, and a couple Plane objects on the scene. I want to check if the line intersects with one of the planes.

It seems like Lines3D.hitTestObject returns true all the time, even if it's not touching anything. I believe it is because the bounding sphere of the line is huge.

What would be the best way to check if a line intersects with a DO3D ?


Thanks,
M-A

_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Re: Lines3D.hitTestObject

by M-A Lavoie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I think I found a way. 

I store the end point of my line (determined by the mouse position) into a Number3D, then iterate throught the do3d's on my scene, using the normalize and multiplyEq methods to find the position along the line at the same Z than the do3D. I can then hitTestPoint with that position ...

I'm just not sure about the normalize and multiplyEq methods... Is that the right way to do it ?


var pt : Number3D = new Number3D(e.renderHitData.x,e.renderHitData.y,e.renderHitData.z);

for(var ref:* in _view.scene.objects) {

var d:DisplayObject3D = _view.scene.objects[ref] as DisplayObject3D;

pt.normalize();
pt.multiplyEq(d.z);
if(d.hitTestPoint(pt.x,pt.y,pt.z)) {
touch = true;
}
}



On 09-06-26, at 11:21, Marc-Andre Lavoie wrote:

Hi,

I have a Lines3D, with only one line, and a couple Plane objects on the scene. I want to check if the line intersects with one of the planes.

It seems like Lines3D.hitTestObject returns true all the time, even if it's not touching anything. I believe it is because the bounding sphere of the line is huge.

What would be the best way to check if a line intersects with a DO3D ?


Thanks,
M-A
_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org