Script to Create Target Camera Relative to Object

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2013
ah yes, I knew it was too good to be true. of course the extra 'move' line I added is relative to world coordinates, so it doesn't work properly when people are seated at an angle... hm.
 
  06 June 2013
Originally Posted by ibrews: Ah! Just saw your post Denis. When I evaluate yours, I get a Runtime Error: 'Unable to decode value: "9""

But near as I can tell, my method works with the simple 'move' line... or am I missing something?

yes... you are missing that the camera has to be moved in the parent coordinate system... so your line has to be:

 in coordsys parent move c [0,50,600]


i don't understand why my code is not working... try this

 try(destroydialog SpectatorCameraDialog) catch()
 rollout SpectatorCameraDialog "Spectator Camera" width:200
 (
 	local cameraname = "Spectator_Camera"
 	
 	edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
 	button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
 
 	
 	on cameraname_tx changed text do 
 	(
 		cameraname = text
 	)
 	on createcam_bt pressed do undo "Create Cameras" on
 	(
 		cams = for node in selection collect 
 		(
 			name = node.name + "_" + cameraname
 			tm = (transmatrix [0, units.decodevalue "9\'\'", units.decodevalue "-5\'\'"])*node.transform
 			c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) transform:tm parent:node
 		)
 		select cams
 	)
 )
 createdialog SpectatorCameraDialog
 
 
  06 June 2013
Originally Posted by denisT: i don't understand why my code is not working?
[/code]

I ask myself this question every day
__________________
Looking in the right side. [bgaTools]
 
  06 June 2013
Nope! Still a runtime error. Now it says 'Unable to decode value: "9\'\'"

Also, this code gives me the error: 'No ""move"" function for undefined'

try(destroydialog SpectatorCameraDialog) catch()
 rollout SpectatorCameraDialog "Spectator Camera" width:200
 (
 	local cameraname = "Spectator_Camera"
 	
 	edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
 	button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
 
 	
 	on cameraname_tx changed text do 
 	(
 		cameraname = text
 	)
 	on createcam_bt pressed do undo "Create Cameras" on
 	(
 		cams = for node in selection collect 
 		(
 			name = node.name + "_" + cameraname
			c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) lens:21.661 fov:79.4535 transform:node.transform parent:node
 		)
 		select cams
		in coordsys parent move c [150,0,500]
 	)
 )
 createdialog SpectatorCameraDialog
 
  06 June 2013
here is it. it works now:

try(destroydialog SpectatorCameraDialog) catch()
 rollout SpectatorCameraDialog "Spectator Camera" width:200
 (
	 local cameraname = "Spectator_Camera"
	 
	 edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
	 button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
 
	 
	 on cameraname_tx changed text do 
	 (
		 cameraname = text
	 )
	 on createcam_bt pressed do undo "Create Cameras" on
	 (
		 cams = for node in selection collect 
		 (
			 name = node.name + "_" + cameraname
			 tm = (transmatrix [0, units.decodevalue "9'", units.decodevalue "-5'"])*node.transform
			 c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) transform:tm parent:node
		 )
		 select cams
	 )
 )
 createdialog SpectatorCameraDialog
 
 
  06 June 2013
yes it does! thank yeh kindly sir.

Now on to tutorials so I can learn what all this means!
 
  06 June 2013
Just put "in coordsys local" in front of "move"

Funny thread

EDIT: Oh, i missed the second page. So just ignore this
__________________
My Demoreel 2011:
http://www.youtube.com/watch?v=Gfq-4VoeAPU
 
  06 June 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:16 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.