Could someone please give me an example how to build a colour vector in C++? I always get type cast errors.
Thanks a lot in advance!
Colour-Vector in C++
Colour-Vector in C++
Thomas Schlick | Next Limit Technologies
Re: Colour-Vector in C++
Hi Thomas,
by a colour vector do you mean a colour with four components or a vector of several color objects?
I tested the following code under the run() function of the Cmd_msg_n_times example:
Let us know some more about your case: Objects you want to use to initialize your colours, and so.
by a colour vector do you mean a colour with four components or a vector of several color objects?
I tested the following code under the run() function of the Cmd_msg_n_times example:
Code: Select all
#include <rf_sdk/sdk/color.h>
...
virtual void run ( Cmd* rfEvntCmd )
{
Scene& scene = AppManager::instance()->getCurrentScene();
PB_Emitter emitter = scene.get_PB_Emitter( "Circle01" );
Color col( 255, 0, 0 );
emitter.setParameter( "Color", col );
}
Alex Ribao
RealFlow Team
Next Limit Technologies
RealFlow Team
Next Limit Technologies
Re: Colour-Vector in C++
Thank you very much, Alex.
It is indeed about assigning a color to freshly created object. We're trying to dye objects randomly based on the selection of a GUI. There, the user can choose whether he wants to use random or uniform colors. The approach so far was:
I have to say that I'm not the programmer in this case. It's one of my-developers who is familiar with C++, but from what I've seen in you code segment I think he didn't use the color.h file. He also tried it with floats and four components, but I guess the entire approach isn't correct.
It is indeed about assigning a color to freshly created object. We're trying to dye objects randomly based on the selection of a GUI. There, the user can choose whether he wants to use random or uniform colors. The approach so far was:
Code: Select all
if (scene.getGlobalVariableValue<bool>("gv_rndColour") == true)
{
int colR = static_cast<int>(randValue(0.0f,255.0f));
int colG = static_cast<int>(randValue(0.0f,255.0f));
int colB = static_cast<int>(randValue(0.0f,255.0f));
newColVec.setX(colR);
newColVec.setY(colG);
newColVec.setZ(colB);
}
// Use single colour from GUI, if rndColor = False
else
{
Vector curColVec = scene.getGlobalVariableValue<Vector>("gv_colVec");
newColVec.setX(curColVec.getX());
newColVec.setY(curColVec.getY());
newColVec.setZ(curColVec.getZ());
}
// Set new parameters
curObj.setParameter("Color", newColVec);
Thomas Schlick | Next Limit Technologies
Re: Colour-Vector in C++
Hi again,
yes, it seems the problem is calling setParameter with a Vector instead of a Color object.
The Color constructor based on a Vector seems to work, so the fix is straight forward.
One more thing that might suppose an issue for you is that the Color constructor based on a Vector expects a Vector of floats in range 0.0f..1.0f instead of 0..255.
yes, it seems the problem is calling setParameter with a Vector instead of a Color object.
The Color constructor based on a Vector seems to work, so the fix is straight forward.
One more thing that might suppose an issue for you is that the Color constructor based on a Vector expects a Vector of floats in range 0.0f..1.0f instead of 0..255.
Alex Ribao
RealFlow Team
Next Limit Technologies
RealFlow Team
Next Limit Technologies
Re: Colour-Vector in C++
Again, thanks a lot for your help and the float-int tip. I'm sure that your code will do the trick.
Thomas Schlick | Next Limit Technologies