Notifications
Clear all

[Closed] intersectRayEx broken?

 PEN

Haven’t used this one in a while and decided to use it for a test that I was doing and found that I can’t get it to hit anything.

hit=intersectRayEx $Sphere001 (ray $Point001.pos $Point001.transform.row3)

Z vector is pointing right at it and I get undefined.

Can any one confirm this? I’m in Max 2012

6 Replies
1 Reply
(@system)
Joined: 11 months ago

Posts: 0

Something is missing – I ran this code from the docs and it works:


 s = sphere material:(standardMaterial diffuseMap:(checker()))
 showTextureMap s.material s.material.diffuseMap on
 --
 -- Add a normal modifier to make the sphere into a mesh
 addModifier s (normalModifier())
 r = ray [-100,5,0] (s.center-[-100,5,0])
 --
 -- Get the Intersection details
 arr = (intersectRayEx s r)
 

seems to be working here, did you create your point in the top view? My point row 3 is [0,0,1] so if my point in directly under the sphere it hits fine. If its created in the front for example, the row 3 will be [0,-1,0], and so will only hit the sphere from the back

is the $Sphere001 a mesh?
Unlike intersectRay(), the intersectRayEx() method will not work if the node is a Standard or Extended Primitive – the node’s stack must evaluate to a mesh.


delete objects
(
	sp = sphere radius:10
	r = ray [0,0,-15] [0,0,1]
	format "1)	ray:	%
	rayEx:	%
" (intersectRay sp r) (intersectRayEx sp r)
	addmodifier sp (Edit_Mesh())
	format "2)	ray:	%
	rayEx:	%
" (intersectRay sp r) (intersectRayEx sp r)
)

also have a look at RayMeshGridIntersect interface it’s quite a bit quicker.

 PEN

It is just because it wasn’t a mesh:S Thanks for the input. I know the other is faster, I was just using this for testing code as it take less to write it.