Notifications
Clear all

[Closed] 2 Questions: Update Script Controller, Quaternions

Question 1:
I transform script controller that makes a on plane stay in the target centre of a Physical camera that has no target:
I use the formula: cam = camera
and the script is this:

 "(transmatrix [0,0, -cam.target_distance])* cam.transform
cam is added a node to the transform_script. 

So I was using this to align the plane with the camera and centre it., but I noticed that the property .pos dissapeared from the plane.
if I type in “plane.pos” i get: “Unknown property: “pos” …”
if i use “plane.transform.pos” I get the expected result.
however I can’t use hasproperty to check if the plane I am changing has the property it give me:

hasproperty $ "pos" = false 

every time?
I was using the line plane.pos = plane.pos to get the object to update interactively (it has a few script controllers attached to it).
but if I use plane.transform.pos = plane.transform.pos
nothing much happens.
So my question 1 is – how to I get interactivity in a script controller properly. I am using a node or object variable like it says to do. I believe that DependsOn is now redudant…

Question2:
I wanted to get a ray from a camera without a target object.
I have a matrix3 variable that is the camera’s transform matrix.
From that I can as for the rotation part matrix3.rotation
and it gives me a quaternion of rotation transform.
That should have an axis of rotation and a revolution number.
i can get the axis by quaternion.axis
but this does not give me the vector to use in a ray to use in rayintersectscene function…
if I do this:

tempval = ((transmatrix [0,0, -cam.target_distance])* cam.transform).row4 - camera.pos 
NewRay = ray camera.pos tempval

It works
but that just feels so inelegant…
is there another way so I can just work with the quaternion.

1 Reply

#1 I don’t think you need any “special” update… everything should be updated automatically:

delete objects

p = plane()
c = freecamera()
t = p.transform.controller = transform_script()
t.addnode "cam" c
t.setexpression "pretranslate cam.transform [0,0,-cam.target_distance]" 


#2 the camera’s ray is (ray <camera>.pos -<camera>.dir)
(or position and negative row3 (Z axis) of transform matrix)