void MFColor::setValue(CVRMLFieldData *data) { if (!data) return; if (data->getFieldType() != FLOAT_ARRAY_DATA) return; float r, g, b; r = 0.0f; g = 0.0f; b = 0.0f; m_values.clear(); CVRMLFloatArrayData *a = (CVRMLFloatArrayData *)data; for (int i=0; i<a->count(); i++) { int j=(i % 3); switch (j) { case 0: r = a->getValue(i); break; case 1: g = a->getValue(i); break; case 2: b = a->getValue(i); SFColor color; color.setValue(r, g, b); m_values.push_back(color); r = 0.0f; g = 0.0f; b = 0.0f; break; } } }
void MFColor::set1Value(int index, float r, float g, float b) { SFColor *color = (SFColor *)getObject(index); if (color) color->setValue(r, g, b); }
void MFColor::set1Value(int index, float value[]) { SFColor *color = (SFColor *)getObject(index); if (color) color->setValue(value); }
void MFColor::addValue(const char *value) { SFColor *field = new SFColor(); field->setValue(value); add(field); }