I want to check cursor pointing into meshes or not, then I try to make my method by Ray - BoundingSphere
here is my code
var ray:Ray = new Ray();
var pCam:Vector3D = _view.camera.position;
var pMouse:Vector3D = _view.unproject(_view.mouseX, _view.mouseY);
var mesh:Mesh;
for (var i : int = 0; i < _object3d.numChildren; ++i) {
mesh = Mesh(_object3d.getChildAt(i));
var bound:BoundingVolumeBase = mesh.bounds;
var dx : Number = bound.max.x - bound.min.x; // distance x
var dy : Number = bound.max.y - bound.min.y; // distance y
var radius:Number = Math.sqrt(dx * dx + dy * dy) / 100; // not sure
mesh.showBounds = ray.intersectsSphere(pCam, pMouse, mesh.position, radius); // show mesh’s bound when cursor point on mesh…
}
That method not fully work, when I move it’s position it’s not work !!
** my ray may be wrong there have anyone ensure that?
** I know that sphere radius not exact, there have anyone give me solutions ? ^^a
** my settings, mesh scale (mesh.geometry.scale(50))
** my settings, mesh position (mesh.y -= 300)
Away3d Broomstick, how to picking an meshes ?Software: Away3D 4.x |
||
BayOfXyz, Newbie
Posted: 01 September 2011 02:43 PM Total Posts: 1 |