Select Faces By Camera not working

beta 3
max 2012 sp2

Tried the Select Faces By Camera tutorial after I was unable to make a Genome that selected faces based on the dot product of the view normal and the view vector. The example in the tutorial was also unsuccessful. I’m not sure if it’s the ToSpace that’s not working or what, as I keep crashing when I try to debug. Each time I hit Update, a different set of faces is selected. Seems random.

[code](–MAGMAFLOW2–
global MagmaFlowEditor_EditBLOPHistory = #()
global MagmaFlowEditor_Genome_MeshIterationMode = #face
magmaNode.note=""
node0 = magmaNode.createNode “InputChannel”
magmaNode.setNumNodeInputs node0 0
magmaNode.setNumNodeOutputs node0 1
magmaNode.setNodeProperty node0 “channelName” “FaceNormal”
magmaNode.setNodeProperty node0 “channelType” “”
magmaNode.DeclareExtensionProperty node0 “Position”
magmaNode.SetNodeProperty node0 “Position” [200,110]
magmaNode.DeclareExtensionProperty node0 “Selected”
magmaNode.SetNodeProperty node0 “Selected” true

node1 = magmaNode.createNode “Output”
magmaNode.setNumNodeInputs node1 1
magmaNode.setNumNodeOutputs node1 0
magmaNode.setNodeProperty node1 “channelName” “FaceSelection”
magmaNode.setNodeProperty node1 “channelType” “int8”
magmaNode.DeclareExtensionProperty node1 “Position”
magmaNode.SetNodeProperty node1 “Position” [440,110]
magmaNode.DeclareExtensionProperty node1 “Selected”
magmaNode.SetNodeProperty node1 “Selected” true

node2 = magmaNode.createNode “ToWorld”
magmaNode.setNumNodeInputs node2 1
magmaNode.setNumNodeOutputs node2 1
magmaNode.setNodeProperty node2 “inputType” “Point”
magmaNode.DeclareExtensionProperty node2 “Name”
magmaNode.SetNodeProperty node2 “Name” “ToWorld”
magmaNode.DeclareExtensionProperty node2 “Position”
magmaNode.SetNodeProperty node2 “Position” [340,110]
magmaNode.DeclareExtensionProperty node2 “Selected”
magmaNode.SetNodeProperty node2 “Selected” true

node14 = magmaNode.createNode “ToSpace”
magmaNode.setNumNodeInputs node14 1
magmaNode.setNumNodeOutputs node14 1
magmaNode.setNodeProperty node14 “inputType” “Point”
magmaNode.setNodeProperty node14 “node” (getNodeByName “Camera001”)
magmaNode.DeclareExtensionProperty node14 “Name”
magmaNode.SetNodeProperty node14 “Name” “ToSpace”
magmaNode.DeclareExtensionProperty node14 “Position”
magmaNode.SetNodeProperty node14 “Position” [510,60]
magmaNode.DeclareExtensionProperty node14 “Selected”
magmaNode.SetNodeProperty node14 “Selected” true

node19 = magmaNode.createNode “Breakout”
magmaNode.setNumNodeInputs node19 1
magmaNode.setNumNodeOutputs node19 3
magmaNode.DeclareExtensionProperty node19 “Position”
magmaNode.SetNodeProperty node19 “Position” [720,100]
magmaNode.DeclareExtensionProperty node19 “Selected”
magmaNode.SetNodeProperty node19 “Selected” true

node16 = magmaNode.createNode “Less”
magmaNode.setNumNodeInputs node16 2
magmaNode.setNumNodeOutputs node16 1
magmaNode.setNodeInputDefaultValue node16 2 0.0
magmaNode.DeclareExtensionProperty node16 “Position”
magmaNode.SetNodeProperty node16 “Position” [850,40]
magmaNode.DeclareExtensionProperty node16 “Selected”
magmaNode.SetNodeProperty node16 “Selected” true

try(magmaNode.setNodeInput node1 1 node16 1)catch()
try(magmaNode.setNodeInput node2 1 node0 1)catch()
try(magmaNode.setNodeInput node14 1 node2 1)catch()
try(magmaNode.setNodeInput node19 1 node14 1)catch()
try(magmaNode.setNodeInput node16 1 node19 3)catch()
magmaNode.setNodeInput node16 2 -1 1

)[/code]

magmaNode.setNodeProperty node2 "inputType" "Point" magmaNode.setNodeProperty node14 "inputType" "Point" should be

magmaNode.setNodeProperty node2 "inputType" "Normal" magmaNode.setNodeProperty node14 "inputType" "Normal"

The Transform nodes have option to transform a Vector in 3 different ways:
“Point” transforms using the whole TM, including translation
“Vector” transforms without the translation part, bit includes eventual scaling component
“Normal” transforms using only the rotation part of the TM, excluding translation AND scale

In your case, FaceNormal is a normal and when you multiply it by the whole TM of the camera, it gets shifted in space and distorted.

The tutorial says

Once I changed both nodes to “Normal” mode, the selection appeared as expected.

I will edit the Tutorial so that the “Switch the mode to “Normal”” is on a new line as a separate step, and I will add a NOTE explaining why that’s vital.

Thanks.

Not to heap more automagical wishes onto the pile, but would it make sense to detect based on the name of the incoming connection what to use?

It’s working “as expected” but it’s not making reliably correct selections. Randomly, some of the faces are incorrectly set. This might be a similar problem to the pushy teapot bug I sent before. As you move the camera in itty bitty increments in local Z, random sets of faces get unselected.

This is the same problem as the other scene you posted with the bizarre vertex popping. The BitArray object was creating a race condition in my code that assumed writing to a channel was thread-safe as long as only one thread read/wrote to that index at a time. It is now fixed for a new build expected today.

I used to do that in Krakatoa.
Should fix it, but would have to expand it to respect other transforms, too.
So if you insert the ToWorld, it would see “FaceNormal” and switch (this used to work but is broken now).
But then you insert the ToSpace and it would have to check and see that ToWorld is already in Normal mode and also switch (this has never worked, but would be cool).

Feel free to wish for automagical stuff, as long as it is on the scripted side. We just cannot change much in the actual plugin at this point, unless it is a bug fix.

Done, from now on adding a transform operator after an EXISTING node will check to see if that node is an InputChannel with “*Normal” channel, or is another transform operator (in which case it will copy that other node’s setting).

Right now it won’t change the type if you manually connect, will see if I can do something about that, too.
Also, if you change the channel’s name, it won’t automatically update all following nodes to a different transform setting.

I’m still getting issues with random vertices popping as of beta 4. Should we be submitting?

Yes. Can you also confirm that disabling threading using the property “ThreadingEnabled” exposed on the Genome modifier (via. MXS) prevents this problem?

Crap, I did something to that file and now it doesn’t pop. Sorry.