PDA

View Full Version : Problem Wiring Parameters


HCompston
09-20-2006, 03:46 PM
Hello Again

Not had much success in getting any help with my last query :) so will try another.

I have created some custom attributes on a camera using a script. The camera itself is created the same way and is linked to various Helpers.

I need to wire the custome attribustes to a noise controller on the cameras rotation.

This is the code I have tried but it doesnt appear to work!

paramwire.connect MyCam.baseobject[#NStrength] MyCam.controller.rotation[#Noise] "NStrength"

MyCam is a variable in the script that is used to hold the camera while it is created. NStrength is the name of the value in the cameras custom attributes.

Now as this ia part of a much larger script I created the camera along with its custom attribs then modified the line to see if I could excute it outside the main body of the script.

This would be

paramwire.connect $MyCam.baseobject[#NStrength] $MyCam.controller.rotation[#Noise] "NStrength"

The object being called MyCam

I get a No Get Function for Quat 0 0 0 1 error?

Any Ideas?

Harry

HCompston
09-21-2006, 04:22 PM
Does no-one hava any ideas? Or is this problem so simple and it is an insult to answer ;)


H

DennisRoche
09-21-2006, 10:13 PM
I did read your original post but I didn't know how to help but lets see what we can figure out...

You have a camera with a custom attribute NStrength. And you want to add a noise controller to another object in the scene and wire the noise_strength property to the camera's NStrength?

Are you creating these other objects as part of larger script or do they already exist in the scene?

to be continued... i've got a class to teach - i'll be back later to help you
continued... :)

what does the paramWire.connect return?

i am trying to get an idea of what it happening... sorry if i'm asking the annoying questions. i would like to help and learn at the same time.

i don't think you are feeding the paramWire function the data that it needs.

HCompston
09-23-2006, 10:12 AM
Hi Dennis

Thanks for getting back.


This is part of a larger script which creates a camera and it relative helpers. The script also includes a noise controller on the camera and the controls to adjust it as cusomt attributes on the same camera. I need to wire up the controls to the controller. Now I have tried the wire up code and it does work to link one object to another however when I use it in this script it doesnt work. It has been returning "No Get Function for Quat 0 0 0 1 error" and sometimes Wanted 3 got 2 arguments.

If this doesnt help I can post the script itself, if I can logon to the VPN. If not I will post it monday.

Thanks

Harry

DennisRoche
09-29-2006, 01:20 AM
If you could post the script that would be great.

cheers :)

DennisRoche
10-04-2006, 06:04 AM
thanks harry for sending me the script. i had a look at it and rewrote it.


------------------------------------------
-- CreateNoiseCamera.ms
-- 03/09/2006
------------------------------------------

------------------------------------------
-- START
------------------------------------------

------------------------------------------
-- ATTRIBUTES
------------------------------------------

cameraNoiseAC = attributes noiseControlsAtts
(
parameters noiseControls rollout:noiseControlsRollout
(
noiseStrengthX type:#float ui:spn_noiseStrengthX default:0
noiseStrengthY type:#float ui:spn_noiseStrengthY default:0
noiseStrengthZ type:#float ui:spn_noiseStrengthZ default:0
noiseFrequency type:#float ui:spn_noiseFrequency default:0.5
)

rollout noiseControlsRollout "Noise"
(
group "Strength" (
spinner spn_noiseStrengthX "X" type:#float align:#center
spinner spn_noiseStrengthY "Y" type:#float align:#center
spinner spn_noiseStrengthZ "Z" type:#float align:#center
)
group "Frequency" (
spinner spn_noiseFrequency "Frequency" type:#float align:#center
)
)
)

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

fn createPointHelper toCamera helperName size:50 wireColor:Blue isBox:true = (
theHelper = Point()
if isBox then (
theHelper.box = true
theHelper.cross = false
)
theHelper.size = size
theHelper.pos = toCamera.pos
theHelper.name = (toCamera.name)+"_"+helperName
theHelper.wirecolor = wireColor

return theHelper
)

fn createCamera cameraName cameraDir:[0,1,0] wireColor:Orange = (
-- create camera
theCamera = FreeCamera()
theCamera.name = cameraName
theCamera.dir = cameraDir
theCamera.wireColor = wireColor

-- create helpers
cameraMover = createPointHelper theCamera "Mover" size:200 wireColor:White isBox:false
cameraHeading = createPointHelper theCamera "Heading" size:150 wireColor:Green
cameraPitch = createPointHelper theCamera "Pitch" size:100 wireColor:Blue
cameraBank = createPointHelper theCamera "Bank" size:50 wireColor:Red

-- parent helpers to camera
theCamera.parent = cameraBank
cameraBank.parent = cameraPitch
cameraPitch.parent = cameraHeading
cameraHeading.parent = cameraMover
cameraBank.rotation = eulerangles -90 0 0

-- lock transform
setTransformLockFlags cameraMover #{4,5,6,7,8,9}
setTransformLockFlags cameraPitch #{1,2,3,5,6,7,8,9}
setTransformLockFlags cameraBank #{1,2,3,4,5,7,8,9}
setTransformLockFlags cameraHeading #{1,2,3,4,5,7,8,9}

-- add noise controller
noiseContoller = Noise_Rotation()
theCamera.rotation.controller = noiseContoller
noiseContoller[#noise_strength].controller = point3_XYZ()
--noiseContoller[#frequency].controller = point3_XYZ() <--- ?
noiseContoller.seed = random 0 1000
noiseContoller.noise_strength = [0,0,0]

-- add noise attributes
emptyMod = emptyModifier()
addModifier theCamera emptyMod
emptyMod.name = "Noise Controls"
custAttributes.add emptyMod cameraNoiseAC

-- link camera attributes to noise controller
noiseControls = emptyMod.noiseControlsAtts
paramWire.connect noiseControls[#noiseStrengthX] theCamera.rotation.controller[#noise_strength][#x] "noiseStrengthX"
paramWire.connect noiseControls[#noiseStrengthY] theCamera.rotation.controller[#noise_strength][#y] "noiseStrengthY"
paramWire.connect noiseControls[#noiseStrengthZ] theCamera.rotation.controller[#noise_strength][#z] "noiseStrengthZ"
--paramWire.connect noiseControls[#noiseFrequency] theCamera.rotation.controller[#frequency] "noiseFrequency" <--- ?

)

------------------------------------------
-- UI
------------------------------------------

rollout createRollout "Create"
(
button btn_createNoiseCamera "Noise Camera" width:100 height:25 align:#center

on btn_createNoiseCamera pressed do
(
createCamera "TestCamera"
)

)

fn main = (
if theWindow != undefined then (
CloseRolloutFloater theWindow
) else (
theWindow = newRolloutFloater "Tools" 200 200
addRollout createRollout theWindow
)
)

main()
------------------------------------------
-- END
------------------------------------------


i couldn't figure out how to connect the frequency attribute - something to do with making the #frequency property available :shrug:

another weird with paramWire is that for every 0.1 that i increment on the modifier it increases the noise controller strength by 5.76 - why it is doing that? to see what i'm talking about: open the noise controller properties (under the motion tab) and then change the spinners camera's Noise Controls modifier

HCompston
10-04-2006, 08:17 AM
Hi Dennis

You certainly have re-wrote it :)

So you managed to wire the strengths ok. I will study this part of the code and see what I did different (wrong).

To be honest I find this lot more difficult to read than my original. As a learner in these things I have a question. Did constructing the script using functions etc make it more efficient? I ask because I have another script which fixes reversed faces on imported objects and it can run out of memory. I was wondering if this was due to inefficient code or just the scale of what it is doing. I did actualy look into writing it using functions, which I have never used yet, but I couldnt justify it as no code is repeated.

Thanks for this. I certainly appreciate the time you have taken and hope to learn from it.

Thanks

Harry

DennisRoche
10-04-2006, 09:38 AM
i did this script to learn as much you - it really only took a few hours of playing around.

writing functions is good practice and it is a nice way to solve a problem by breaking the logic into smaller parts. it can be more efficient as you can manage the memory by limiting the scope of your variables and it is easy to debug.

if you have any question please ask. also if you anyone can help further understand the paramWires, customAttributes, and emptyModifiers that would be great.

HCompston
10-04-2006, 02:05 PM
Hi Dennis


Thats very generous of you. Thanks again for your time. I will take a look at this later once I am back at work.

Thanks

Harry

CGTalk Moderation
10-04-2006, 02:05 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.