ORIENTATION: Look At Target


#1

[code](–MAGMAFLOW2–
global MagmaFlowEditor_EditBLOPHistory = #()
magmaNode.note=""
node0 = magmaNode.createNode “InputObject”
magmaNode.setNumNodeInputs node0 0
magmaNode.setNumNodeOutputs node0 1
magmaNode.setNodeProperty node0 “object” (getNodeByName “Point001”)
magmaNode.DeclareExtensionProperty node0 “Exposed”
magmaNode.SetNodeProperty node0 “Exposed” true
magmaNode.DeclareExtensionProperty node0 “Name”
magmaNode.SetNodeProperty node0 “Name” “LookAtTarget”
magmaNode.DeclareExtensionProperty node0 “Position”
magmaNode.SetNodeProperty node0 “Position” [-200.462,203.769]

node1 = magmaNode.createNode “Output”
magmaNode.setNumNodeInputs node1 1
magmaNode.setNumNodeOutputs node1 0
magmaNode.setNodeProperty node1 “channelName” “Orientation”
magmaNode.setNodeProperty node1 “channelType” “float16[4]”
magmaNode.DeclareExtensionProperty node1 “Position”
magmaNode.SetNodeProperty node1 “Position” [1339.54,243.769]

node2 = magmaNode.createNode “InputChannel”
magmaNode.setNumNodeInputs node2 0
magmaNode.setNumNodeOutputs node2 1
magmaNode.setNodeProperty node2 “channelName” “Position”
magmaNode.setNodeProperty node2 “channelType” “”
magmaNode.DeclareExtensionProperty node2 “Name”
magmaNode.SetNodeProperty node2 “Name” “Particle Position”
magmaNode.DeclareExtensionProperty node2 “Position”
magmaNode.SetNodeProperty node2 “Position” [-200.462,373.769]

node3 = magmaNode.createNode “PropertyQuery”
magmaNode.setNumNodeInputs node3 2
magmaNode.setNumNodeOutputs node3 1
magmaNode.setNodeProperty node3 “properties” #(“Pos”)
magmaNode.DeclareExtensionProperty node3 “Position”
magmaNode.SetNodeProperty node3 “Position” [-40.4615,183.769]
magmaNode.setNodeInputDefaultValue node3 2 0

node4 = magmaNode.createNode “Subtract”
magmaNode.setNumNodeInputs node4 2
magmaNode.setNumNodeOutputs node4 1
magmaNode.DeclareExtensionProperty node4 “Position”
magmaNode.SetNodeProperty node4 “Position” [249.538,283.769]
magmaNode.setNodeInputDefaultValue node4 1 1.0
magmaNode.setNodeInputDefaultValue node4 2 0.0

node5 = magmaNode.createNode “Normalize”
magmaNode.setNumNodeInputs node5 1
magmaNode.setNumNodeOutputs node5 1
magmaNode.DeclareExtensionProperty node5 “Position”
magmaNode.SetNodeProperty node5 “Position” [439.538,273.769]

node6 = magmaNode.createNode “ToWorld”
magmaNode.setNumNodeInputs node6 1
magmaNode.setNumNodeOutputs node6 1
magmaNode.setNodeProperty node6 “inputType” “Point”
magmaNode.DeclareExtensionProperty node6 “Position”
magmaNode.SetNodeProperty node6 “Position” [30,360]
magmaNode.DeclareExtensionProperty node6 “Selected”
magmaNode.SetNodeProperty node6 “Selected” true

node7 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node7 0
magmaNode.setNumNodeOutputs node7 1
magmaNode.setNodeProperty node7 “forceInteger” false
ctrl=Point3_XYZ(); ctrl.value = [0,0,1]
magmaNode.setNodeProperty node7 “controller” ctrl
magmaNode.DeclareExtensionProperty node7 “Exposed”
magmaNode.SetNodeProperty node7 “Exposed” true
magmaNode.DeclareExtensionProperty node7 “Name”
magmaNode.SetNodeProperty node7 “Name” “UpVector”
magmaNode.DeclareExtensionProperty node7 “Position”
magmaNode.SetNodeProperty node7 “Position” [-200.462,493.769]

node8 = magmaNode.createNode “VectorCross”
magmaNode.setNumNodeInputs node8 2
magmaNode.setNumNodeOutputs node8 1
magmaNode.DeclareExtensionProperty node8 “Position”
magmaNode.SetNodeProperty node8 “Position” [609.538,423.769]

node9 = magmaNode.createNode “VectorsToQuat”
magmaNode.setNumNodeInputs node9 3
magmaNode.setNumNodeOutputs node9 1
magmaNode.DeclareExtensionProperty node9 “Position”
magmaNode.SetNodeProperty node9 “Position” [990,260]
magmaNode.setNodeInputDefaultValue node9 1 [1,0,0]
magmaNode.setNodeInputDefaultValue node9 2 [0,1,0]
magmaNode.setNodeInputDefaultValue node9 3 [0,0,1]

node10 = magmaNode.createNode “VectorCross”
magmaNode.setNumNodeInputs node10 2
magmaNode.setNumNodeOutputs node10 1
magmaNode.DeclareExtensionProperty node10 “Position”
magmaNode.SetNodeProperty node10 “Position” [659.538,143.769]

node11 = magmaNode.createNode “Normalize”
magmaNode.setNumNodeInputs node11 1
magmaNode.setNumNodeOutputs node11 1
magmaNode.DeclareExtensionProperty node11 “Position”
magmaNode.SetNodeProperty node11 “Position” [799.538,463.769]

node12 = magmaNode.createNode “Normalize”
magmaNode.setNumNodeInputs node12 1
magmaNode.setNumNodeOutputs node12 1
magmaNode.DeclareExtensionProperty node12 “Position”
magmaNode.SetNodeProperty node12 “Position” [829.538,93.7692]

try(magmaNode.setNodeInput node1 1 node9 1)catch()
try(magmaNode.setNodeInput node3 1 node0 1)catch()
magmaNode.setNodeInput node3 2 -1 1
try(magmaNode.setNodeInput node4 1 node6 1)catch()
try(magmaNode.setNodeInput node4 2 node3 1)catch()
try(magmaNode.setNodeInput node5 1 node4 1)catch()
try(magmaNode.setNodeInput node6 1 node2 1)catch()
try(magmaNode.setNodeInput node8 1 node5 1)catch()
try(magmaNode.setNodeInput node8 2 node7 1)catch()
try(magmaNode.setNodeInput node9 1 node11 1)catch()
try(magmaNode.setNodeInput node9 2 node12 1)catch()
try(magmaNode.setNodeInput node9 3 node5 1)catch()
try(magmaNode.setNodeInput node10 1 node5 1)catch()
try(magmaNode.setNodeInput node10 2 node11 1)catch()
try(magmaNode.setNodeInput node11 1 node8 1)catch()
try(magmaNode.setNodeInput node12 1 node10 1)catch()

)

[/code]


#2

Turns out this doesn’t actually work. Not sure why.

  1. Finds a vector between the particle and a point 1b(normalizes)
  2. Creates an up-vector (straight up)
  3. Takes the cross product of the Normal and the up-vector to create a bi-normal. 3b) Normalies bi-normal just for good measure
  4. Takes the cross product of the bi-normal and the normal and should creates a tangent.
  5. Uses the 3x Unit Vector -> Quaternian conversion node.
  6. Plugs it into Orientation.
    PRT Loader Testing.zip (51.4 KB)

#3

Select the VectorsToQuat operator and hit CTRL+W to swap the top two inputs.
The Point To Position axis goes into Z as you have it. Also it might need to be inverted to point from the Position to the Point. The cross product with the UP axis should go into the X, but it went into the Y…

When I downloaded your Magma the other day, I put it on some particles that meshed with Frost, and had the same issue and had to swap the order of the input vector to get the plane shapes to look at the camera with their flat sides instead of their edges…


#4

Thanks, I knew it must have been something simple. I thought I had tried all of the XYZ combinations. Guess I missed one! Should work now.

Still putting your Maxscript vector math DVD knowledge to use. :smiley:


#5

Absolutely same here. From what it sounds, the overall experience wasn’t good for CG Academy, but those DVDs were invaluable.