Notifications
Clear all

[Closed] OrbitCam problem

First, thanks to GavenB and his video tutorials and Bobo’s CG-Academy disks, I’ve learned so much.

I have written this OrbitCam script to make a quick turntable setup. So far the script makes a target camera linked to a dummy and renames the camera to “OrbitCam”.

The problem is the camera is not moved to the camRad spinner value. When the The “Make OrbitCam” button is pressed the camera is set to 0,0,0.

rollout myOC “OrbitCam”
(
spinner camRad “Camera Radius” range:[0,1000,100] type:#integer
button makeCam “Make OrbitCam”

  on makeCam pressed do

      (

      y_offset = 0

          (
              (
              Cam = Targetcamera isSelected:on target:(Targetobject   transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
              $.name = "OrbitCam"
              Dummy pos:[0,0,0] isSelected:on
              select $OrbitCam
              $.parent = $Dummy01
              )
          move Cam [0,y_offset,0]
          y_offset = y_offset + camRad.value
          )
      )

)
CreateDialog myOC width:200 hight:400

Any help would be great

thanks

4 Replies

You need an action for the spinner also the way you have it for the button (on camRad changed val do …). Also too many brackets with no purpose in there and try avoiding using “$” in scripts. Use the object name instead or “Selection”

Thanks vasilescu_anton

I’m clearly in over my head, but what the hey. Were could I find out more about “actions”?

thanks

Ok, I’ve got the chance to work a bit on your script and here is what I came up with:


rollout myOC "OrbitCam"
(
spinner camRad "Camera Radius" range:[0,1000,100] type:#integer
button makeCam "Make OrbitCam"
 
local TurnTableCam = undefined 
local TurnTableCamDummy = undefined
on makeCam pressed do
(
TurnTableCam = TargetCamera name:#OrbitCam isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
TurnTableCamDummy = Dummy pos:[0,0,0]
TurnTableCam.parent = TurnTableCamDummy
TurnTableCamDummy.pos = [0,camRad.value,0]
)
on camRad changed val do
(
TurnTableCamDummy.pos = [0,camRad.value,0]
)
)
CreateDialog myOC width:200 hight:400

The above code uses the dummy to change the position of the object and also if you change the value of the spinner the dummy will be moved.

By actions I refferd to the “events” you can add to interface elements. If you look in the reference for spinner or any other interface element you’ll find everything you need about them.

WOW, Thanks for your work. You really streamlined the script.

In deconstructing your script I was reading about “local” variables. Very interesting, As you suggested I read up on “events” and I see why you used “local” variables instead of global. To keep the [font=Verdana]function definition local to a utility or rollout. [/font]

In your first post you said to avoid using $ Use the object name instead or “Selection”. I will need to read more and study the following lines.

TurnTableCamDummy = Dummy pos:[0,0,0]

TurnTableCam.parent = TurnTableCamDummy

TurnTableCamDummy.pos = [0,camRad.value,0]

Again, much thanks for your time. I hope some day to contribute instead of only take.

othoap