PDA

View Full Version : Camera Scripted Plugin Dilema!


EverZen
05-16-2008, 02:55 PM
Hi Guys,

I am trying to write a very simple camera scripted plugin which adds some really simple positioning features to the current camera UI.

To do this I have written the start of the scripted plugin, and specified it to extend "TargetCamera". I have then attempted to add a very basic UI in a new Rollout (trying to tag it onto the existing targetcamera UI options!). The trouble is that when I add it, the rollout does not appear!!

Here is the code:




plugin Camera TCameraAdv
name:"Target_Adv"
--classID:#(0x5a3d7fcb, 0x658a4934)
classID:#(0x6c9ea66, 0x171df6b5)
category:"Standard"
extends:TargetCamera
(

-------------------------------------------------------------------------------------------------------------------------
--FUNCTIONS
-------------------------------------------------------------------------------------------------------------------------


-------------------------------------------------------------------------------------------------------------------------
--UI
-------------------------------------------------------------------------------------------------------------------------
parameters CamPosStore rollout:RJCamPosStoreRO
(

)

rollout RJCamPosStoreRO "Transform Storage" width:160 height:240
(
groupBox grp1 "Camera Position Storage" pos:[4,4] width:152 height:196
listBox CamPosStore "" pos:[12,20] width:136 height:10
button RecCamPos "Record Position" pos:[8,160] width:144 height:16
button DelCamPos "Delete Position" pos:[8,180] width:144 height:16
button AssCamPos "Assign Camera Postion" pos:[4,204] width:152 height:32
)



)--End of Camera Adv




The Rollout doesnt appear!!! But when I set up the same plugin to extend FreeCamera it words fine! Like this...




plugin Camera TCameraAdvFree
name:"Target_Adv_Free"
classID:#(0x5a3d7fcb, 0x658a4934)
category:"Standard"
extends:FreeCamera
(

-------------------------------------------------------------------------------------------------------------------------
--FUNCTIONS
-------------------------------------------------------------------------------------------------------------------------


-------------------------------------------------------------------------------------------------------------------------
--UI
-------------------------------------------------------------------------------------------------------------------------
parameters CamPosStore rollout:RJCamPosStoreRO
(

)

rollout RJCamPosStoreRO "Transform Storage" width:160 height:240
(
groupBox grp1 "Camera Position Storage" pos:[4,4] width:152 height:196
listBox CamPosStore "" pos:[12,20] width:136 height:10
button RecCamPos "Record Position" pos:[8,160] width:144 height:16
button DelCamPos "Delete Position" pos:[8,180] width:144 height:16
button AssCamPos "Assign Camera Postion" pos:[4,204] width:152 height:32
)



)--End of Camera Adv




Can anyone tell me what is going wrong with the Target Camera plugin! Cause I am well confused. Unfortunately, we all tend to use more Target cameras, so if I cant fix this dilema then things are looking pretty bleak!!

Thanks for your time guys :)

Rich

davestewart
05-16-2008, 06:28 PM
That's pretty weird.

I'm not the leading light on custom attributes in any shape or form, but could you not just add a CA rollout? This has the added advantage of not needing people to have your scripted plugin file, and once the attributes are applied, they just stay there.

advCamPropsCA = attributes advancedCameraProperties
(
parameters main rollout:params
(
targetPositions type:#matrix3tab tabSizeVariable:true
cameraPositions type:#matrix3tab tabSizeVariable:true
positionNames type:#stringtab tabSizeVariable:true
)

rollout params "Position Parameters"
(
groupBox grp1 "Camera Position Storage" pos:[4,4] width:152 height:196
listBox CamPosStore "" pos:[12,20] width:136 height:10
button RecCamPos "Record Position" pos:[8,160] width:144 height:16

function addItem newItem:"" =
(
local items = CamPosStore.items
append items ("Position " + (items.count + 1) as string)
CamPosStore.items = items
)

function updateItems =
(
local items = for i = 1 to cameraPositions.count collect ("Position " + i as string)
CamPosStore.items = items
)

function setPosition =
(
append cameraPositions $.transform
append targetPositions $.target.transform
updateItems()
)

function getPosition index =
(
$.transform = cameraPositions[index]
$.target.transform = targetPositions[index]
)

on RecCamPos pressed do setPosition()
on CamPosStore doubleclicked index do getPosition index
on params open do updateItems()

)
)

custAttributes.add $ advCamPropsCA BaseObject:true



Any good to ya?

ZeBoxx2
05-16-2008, 09:18 PM
and if using a button to apply it is an issue, look up the #nodeCreated callback. Just monitor that, check if the newly-created node is a camera, and attach then; fully-automatic. For Target cameras you might have to actually check the objects' array end, as two nodes get created, I think; a camera and the targetObject - but haven't tested

EverZen
05-17-2008, 11:00 AM
Not sure why I over looked the CA solution in the first place! Thanks for getting me back on track with it. Definitely gonna look into that #nodecreated callback too, cause that could definitely smooth out adding the features.

The need not to have all our render nodes referencing another plugin will also be a considerable bonus.

nice one Dave and Rich! The help is seriously appreciated. I let you know how it all works out, but I reckon your ideas have nailed it!

Cheers,

Rich

ZeBoxx2
05-17-2008, 12:41 PM
Cool :)

That said, I confirmed the issued you mentioned initially and I haven't particularly figured out a work-around/fix for it either. I thought that addPluginRollouts had to be involved somehow, but for some reason, I can't even get the 'tool create' to trigger any events. Targeted Nodes must be dealt with in funny ways internally.

davestewart
05-17-2008, 07:32 PM
No worries Rich,
I'm glad to help.

I quite liked the concept, so I finished it off at my end, too. If you want to take a look at how I did it, you can find it here: http://www.keyframesandcode.com/code/category/development/maxscript/maxscript-animation/

Cheers!
Dave

CGTalk Moderation
05-17-2008, 07:32 PM
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.