setLightParameters doesn't work as in documentation

Typically: "How do I... ", "How can I... " questions
Post Reply
ask4jubad
Posts: 21
Joined: 21 Sep 2021, 07:46

setLightParameters doesn't work as in documentation

Post by ask4jubad »

I would like to change the diffuse and specular components of one of the default lights in my simulation using the following:

Code: Select all

sim.setLightParameters(lightHandleA, 1, None, [difA1, difA2, difA3], [0,0,0])
but it returns the following error:
Exception: b"42: Incorrect table size. (in function 'sim.setLightParameters')"
Mind you, difA1 - difA3 are all float numbers between 0 and 1.

In specific terms, how can I get this done?

Please support with this.

coppelia
Site Admin
Posts: 10379
Joined: 14 Dec 2012, 00:25

Re: setLightParameters doesn't work as in documentation

Post by coppelia »

Hello,

you are right. The Python version needs a bit different handling. Try by replacing None with [0,0,0].

Cheers

ask4jubad
Posts: 21
Joined: 21 Sep 2021, 07:46

Re: setLightParameters doesn't work as in documentation

Post by ask4jubad »

Thanks Coppelia.

Can you tell me about how to do the handling in python then please? I mean to be able to change the diffuse and specular components across the range and not just turn on/of the light.

Thanks

coppelia
Site Admin
Posts: 10379
Joined: 14 Dec 2012, 00:25

Re: setLightParameters doesn't work as in documentation

Post by coppelia »

What about:

Code: Select all

    sim.setLightParameters(lightHandle,1,[0,0,0],[1,1,1],[0,0,0]) # light is white
    sim.setLightParameters(lightHandle,1,[0,0,0],[1,0,0],[0,0,0]) # light is red
    sim.setLightParameters(lightHandle,0,[0,0,0],[1,0,0],[0,0,0]) # light is off
    etc.
cheers

ask4jubad
Posts: 21
Joined: 21 Sep 2021, 07:46

Re: setLightParameters doesn't work as in documentation

Post by ask4jubad »

Thanks it worked.

I think updating the documentation a bit would save a lot of time.

I see that it is currently written as:
Python synopsis

Code: Select all

sim.setLightParameters(int objectHandle,int state,None,list diffusePart,list specularPart)
The setToNULL parameter does not work with None (at least for me and I have reproduced this three times) rather [0, 0, 0] worked.

My recommendation is to update it thus:

Code: Select all

sim.setLightParameters(int objectHandle,int state,[0,0,0],list(3)diffusePart,list(3)specularPart)
The clarity will be helpful.

Post Reply