On 12/05/2015 at 10:00, xxxxxxxx wrote:
Hello,
in an Xpresso node, you don't handle parameters but ports. These ports must be handled in special ways:
static Int32 input_ids[] = { GV_TEST_A, GV_TEST_B, 0 };
...
GvValuesInfo ports; // data structure for all ports
// init the input ports
virtual Bool InitCalculation(GvNode *bn, GvCalc *calc, GvRun *run)
{
return GvBuildValuesTable(bn, ports, calc, run, input_ids);;
}
virtual Bool Calculate(GvNode *bn, GvPort *port, GvRun *r, GvCalc *calc)
{
// calculate all ports
if (!GvCalculateInValuesTable(bn, r, calc, ports)) return false;
// get the "Gradient" port
GvPort* portGradient = ports.in_values[0]->GetPort();
// get the "Gradient" data
Gradient* gradient = nullptr;
portGradient->GetDataInstance((const void*&)gradient, CUSTOMDATATYPE_GRADIENT, r);
// sample the gradient
if(gradient != nullptr)
{
InitRenderStruct irs(bn->GetDocument());
gradient->InitRender(irs);
for(Int32 i = 0; i < 10; i++)
{
Vector color = gradient->CalcGradientPixel(Float(i) / 10.0);
GePrint(String::VectorToString(color));
}
gradient->FreeRender();
}
return true;
}
// free data
virtual void FreeCalculation(GvNode *bn, GvCalc *calc)
{
GvFreeValuesTable(bn, ports);
}
best wishes,
Sebastian