static void PI4D_SetFraction(GF_Node *node, GF_Route *route) { u32 i; Fixed frac; M_PositionInterpolator4D *_this = (M_PositionInterpolator4D *)node; if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; } else if (_this->set_fraction >= _this->key.vals[_this->key.count-1]) { _this->value_changed = _this->keyValue.vals[_this->keyValue.count-1]; } else { for (i=1; i<_this->key.count; i++) { // Find the key values the fraction lies between if (_this->set_fraction < _this->key.vals[i-1]) continue; if (_this->set_fraction >= _this->key.vals[i]) continue; frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction); _this->value_changed.x = Interpolate(_this->keyValue.vals[i-1].x, _this->keyValue.vals[i].x, frac); _this->value_changed.y = Interpolate(_this->keyValue.vals[i-1].y, _this->keyValue.vals[i].y, frac); _this->value_changed.z = Interpolate(_this->keyValue.vals[i-1].z, _this->keyValue.vals[i].z, frac); _this->value_changed.q = Interpolate(_this->keyValue.vals[i-1].q, _this->keyValue.vals[i].q, frac); break; } } gf_node_event_out(node, 3);//"value_changed" }
void OrientInt_SetFraction(SFNode *node) { u32 i; Float frac; M_OrientationInterpolator *_this = (M_OrientationInterpolator *)node; if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; } else if (_this->set_fraction >= _this->key.vals[_this->key.count-1]) { _this->value_changed = _this->keyValue.vals[_this->keyValue.count-1]; } else { for (i=1; i<_this->key.count; i++) { // Find the key values the fraction lies between if (_this->set_fraction < _this->key.vals[i-1]) continue; if (_this->set_fraction >= _this->key.vals[i]) continue; frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction); _this->value_changed = Rotation_Interpolate(_this->keyValue.vals[i-1], _this->keyValue.vals[i], frac); break; } } Node_OnEventOutSTR(node, "value_changed"); }
static void CI4D_SetFraction(GF_Node *n, GF_Route *route) { Fixed frac; u32 numElemPerKey, i, j; M_CoordinateInterpolator4D *_this = (M_CoordinateInterpolator4D *) n; if (! _this->key.count) return; if (_this->keyValue.count % _this->key.count) return; numElemPerKey = _this->keyValue.count / _this->key.count; //set size if (_this->value_changed.count != numElemPerKey) gf_sg_vrml_mf_alloc(&_this->value_changed, GF_SG_VRML_MFVEC4F, numElemPerKey); if (_this->set_fraction < _this->key.vals[0]) { for (i=0; i<numElemPerKey; i++) _this->value_changed.vals[i] = _this->keyValue.vals[i]; } else if (_this->set_fraction > _this->key.vals[_this->key.count - 1]) { for (i=0; i<numElemPerKey; i++) _this->value_changed.vals[i] = _this->keyValue.vals[(_this->keyValue.count) - numElemPerKey + i]; } else { for (j = 1; j < _this->key.count; j++) { // Find the key values the fraction lies between if ( _this->set_fraction < _this->key.vals[j-1]) continue; if (_this->set_fraction >= _this->key.vals[j]) continue; frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction); for (i=0; i<numElemPerKey; i++) { _this->value_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x, _this->keyValue.vals[(j)*numElemPerKey + i].x, frac); _this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y, _this->keyValue.vals[(j)*numElemPerKey + i].y, frac); _this->value_changed.vals[i].z = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].z, _this->keyValue.vals[(j)*numElemPerKey + i].z, frac); _this->value_changed.vals[i].q = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].q, _this->keyValue.vals[(j)*numElemPerKey + i].q, frac); } break; } } //invalidate gf_node_event_out(n, 3);//"value_changed" }
void CI4D_SetFraction(SFNode *n) { Float frac; u32 numElemPerKey, i, j; M_CoordinateInterpolator4D *_this = (M_CoordinateInterpolator4D *) n; if (! _this->key.count) return; if (_this->keyValue.count % _this->key.count) return; numElemPerKey = _this->keyValue.count / _this->key.count; //set size if (_this->value_changed.count != numElemPerKey) VRML_MF_Alloc(&_this->value_changed, FT_MFVec4f, numElemPerKey); if (_this->set_fraction < _this->key.vals[0]) { for (i=0; i<numElemPerKey; i++) _this->value_changed.vals[i] = _this->keyValue.vals[i]; } else if (_this->set_fraction > _this->key.vals[_this->key.count - 1]) { for (i=0; i<numElemPerKey; i++) _this->value_changed.vals[i] = _this->keyValue.vals[(_this->keyValue.count) - numElemPerKey + i]; } else { for (j = 1; j < _this->key.count; j++) { // Find the key values the fraction lies between if ( _this->set_fraction < _this->key.vals[j-1]) continue; if (_this->set_fraction >= _this->key.vals[j]) continue; frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction); for (i=0; i<numElemPerKey; i++) { _this->value_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x, _this->keyValue.vals[(j)*numElemPerKey + i].x, frac); _this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y, _this->keyValue.vals[(j)*numElemPerKey + i].y, frac); _this->value_changed.vals[i].z = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].z, _this->keyValue.vals[(j)*numElemPerKey + i].z, frac); _this->value_changed.vals[i].q = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].q, _this->keyValue.vals[(j)*numElemPerKey + i].q, frac); } break; } } //invalidate Node_OnEventOutSTR(n, "value_changed"); }
static Bool CI_SetFraction(Fixed fraction, MFVec3f *vals, MFFloat *key, MFVec3f *keyValue) { Fixed frac; u32 numElemPerKey, i, j; if (! key->count) return 0; if (keyValue->count % key->count) return 0; numElemPerKey = keyValue->count / key->count; if (vals->count != numElemPerKey) gf_sg_vrml_mf_alloc(vals, GF_SG_VRML_MFVEC3F, numElemPerKey); if (fraction < key->vals[0]) { for (i=0; i<numElemPerKey; i++) vals->vals[i] = keyValue->vals[i]; } else if (fraction > key->vals[key->count - 1]) { for (i=0; i<numElemPerKey; i++) vals->vals[i] = keyValue->vals[(keyValue->count) - numElemPerKey + i]; } else { for (j = 1; j < key->count; j++) { // Find the key values the fraction lies between if (fraction < key->vals[j-1]) continue; if (fraction >= key->vals[j]) continue; frac = GetInterpolateFraction(key->vals[j-1], key->vals[j], fraction); for (i=0; i<numElemPerKey; i++) { vals->vals[i].x = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].x, keyValue->vals[(j)*numElemPerKey + i].x, frac); vals->vals[i].y = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].y, keyValue->vals[(j)*numElemPerKey + i].y, frac); vals->vals[i].z = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].z, keyValue->vals[(j)*numElemPerKey + i].z, frac); } break; } } return 1; }
static void ColorInt_SetFraction(GF_Node *node, GF_Route *route) { u32 i; Fixed frac; M_ColorInterpolator *_this = (M_ColorInterpolator *)node; if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; } else if (_this->set_fraction >= _this->key.vals[_this->key.count-1]) { _this->value_changed = _this->keyValue.vals[_this->keyValue.count-1]; } else { for (i=1; i<_this->key.count; i++) { // Find the key values the fraction lies between if (_this->set_fraction < _this->key.vals[i-1]) continue; if (_this->set_fraction >= _this->key.vals[i]) continue; frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction); _this->value_changed.red = Interpolate(_this->keyValue.vals[i-1].red, _this->keyValue.vals[i].red, frac); _this->value_changed.green = Interpolate(_this->keyValue.vals[i-1].green, _this->keyValue.vals[i].green, frac); _this->value_changed.blue = Interpolate(_this->keyValue.vals[i-1].blue, _this->keyValue.vals[i].blue, frac); break; } } gf_node_event_out(node, 3);//"value_changed" }