i have an ofVec3f as an ofParameter and i don’t know how to update just one coordinate value.
for example i have :
I am able to get separate values using
float distance = position.get().z;
But how can i just set the z coordinate ?
thanks a lot
Hum… well… ok !
I love ofParameter
Well, in fact i am facing this problem :
Read-only variable is not assignable
ive never needed to do such but, anyways, as it doesn’t work for ofVec
try the following.
ofVec3f v = position.get();
v.x = ofGetMouseX();
Yep, i will do like that as a turnaround.
If by any chance somebody knows a straighter solution…
there’s no way to update individual components of ofParameter, the cause is that ofParameter is meant to always notify it’s event when it changes but there’s no way for ofParameter to know which would be it’s value after a call to a mutable operation on the variable it holds.
You can call any const method or access any of it’s variables for read only on an ofParameter like:
But you can’t access any of it’s mutable mehtods or change the value of it’s variables. The only way to mutate an ofParameter contents is to set it’s full value again, so you would need to do something like:
pos = ofVec3f(pos->x, pos->y, 50);
ok. Thanks for the great explanation.
I will do like suggested.