Notifications
Clear all

[Closed] Get face info under the mouse cursor?

Is it possible to get the object and face information when the user has the pointer above an object?

The painter interface can do this but then I think you have to be in painter mode, and I don’t want that. What I want to be able to do is to be in subobject mode on an editable_poly A and then if the user clicks on another object B, it will select the face of this object and go into subobject mode on this one.

Thanks for any help
/Andreas

6 Replies

Well, first of all it sounds like you’ll need to use a #SelectionSetChanged callback. In order to get the face under the mouse you’ll need intersectRayEx(), but it returns undefined for EPoly objects. That means you’ll probably need to snapshot the epoly to get a mesh object to work with (you can disable screen redraw so that the user doesn’t see any of this happening). Once you have the triangle face under the mouse (from intersectRayEx), you’ll need to do a sort of ‘look up’ function to get the corresponding n-gon on the epoly that you want to select.

A bit complicated, but do-able I think

RH

Yea I thought about something similar myself. What exactly should I use the selectionsetchanged for? To get the info that the user don’t have a selection anymore, or? Hmm actually the user can have a selection on the object he is working on, just that he moves the mouse and clicks on another object. This seems to be the tricky part. I’m not sue the selection change will give an event if the user clicks on another object in modify mode.

The lookup that you mention should be possible, but somewhat slow.

Thanks for the help
/Andreas

I get it now. Since you’re in SO mode, clicking on the other object doesn’t change the selection. You may need to have a macroScript that calls pickObject and then does the ray test. Adds an extra button/keypress to the process, but I don’t know if there’s another way short of looping through $geometry and testing for intersections – could be slow. As for the triangle-to-poly lookup function, I use one in my CleanCut script that should be fast enough for most purposes:

fn getPolyIndexFromTri poly mesh tri =
(
	triVerts = (meshop.getVertsUsingFace mesh tri) as array
	allVertsFaces = #()
	for vert in triVerts do
	(
		append allVertsFaces ((polyOp.getFacesUsingVert poly vert) as array)
	)
	for face in allVertsFaces[1] do
	(
		if (((findItem allVertsFaces[2] item) != 0) and ((findItem allVertsFaces[3] item) != 0)) do
		(
			return face
		)
	)
)

RH

Yea true hmm. Nice script, I will check it up. Another way that one could get the faces from a mesh that should be faster is to use the Flagging values so you just change the flag value in the mesh and then you look it up in the poly. That should be far faster. However I’m not sure that the editable_mesh even has a flag value.

I must say I think the modify mode is a little irritation in max, it would be better if you could just click another face on another object directly and it switches to this object, now you have to go out of modify, click the object and then go into modify mode and select the sobobjectLevel you want to work with. I think I will use the way you suggested with a keypress. The user just points at the object and press button X and then that face will instantly be selected and you will be in subobject mode there. That should work I hope.

/Andreas

hey andreas! if you really find a way to do this, it would be great if you could post your solution!!! i also have had this problem some time ago with a script, i tried it with shooting rays from the mouse and test for collision, but i totaly failed i finally switched to the painter interface, which is also not working very well, would be cool if there would be some maxscript extensions for stuff like this, or maybe something that should be included into max8 (or even better in 7 ;))

good luck!!

Yea, this would be very useful. It would be a good feature for Polyspeed, since it would skip a few presses for the user.

Perhaps max should change the modify interface so that you can instantly modify all polys in the scene at once.

If I really must I could perhaps write an extention for something like this if it’s not doable in MaxScript. I’m not sure exactly what the extention would do though. the thing is that everything isn’t doable in the max sdk either…

/Andreas