Example #1
0
  void fCurve::keyModified(sInt i)
  {
    if (i==0)
      m_firstFrame=m_keys[i].frame;
    else if (i==getNKeys()-1)
      m_lastFrame=m_keys[i].frame;

    if (m_type==constant && i>=getNKeys()-2)
      m_keys[getNKeys()-1].value=m_keys[getNKeys()-2].value;
  }
void NormalInterpolatorNode::update() 
{
	int n;

	float fraction = getFraction();
	int index = -1;
	int nKey = getNKeys();
	for (n=0; n<(nKey-1); n++) {
		if (getKey(n) <= fraction && fraction <= getKey(n+1)) {
			index = n;
			break;
		}
	}
	if (index == -1)
		return;

	float scale = (fraction - getKey(index)) / (getKey(index+1) - getKey(index));

	float vector1[3];
	float vector2[3];
	float vectorOut[3];

	getKeyValue(index, vector1);
	getKeyValue(index+1, vector2);
	for (n=0; n<3; n++)
		vectorOut[n] = vector1[n] + (vector2[n] - vector1[n])*scale;

	setValue(vectorOut);
	sendEvent(getValueField());
}
Example #3
0
  void fCurve::convertToBezier(cubicBezierCurve2D& t) const
  {
    if (getNKeys()>1)
    {
      t.resize(getNKeys()-1);

      cubicBezierSegment2D *seg = t.segment;

      for (keyVectorCIt it = m_keys.begin(); (it + 1) != m_keys.end(); ++it)
      {
        const sF32 v0 = it->value, v1 = (m_type != constant) ? (it + 1)->value : it->value;
        const sInt f0 = it->frame, f1 = (it + 1) -> frame;

        sF32 dd0, ds1;
        calcTangents(it, dd0, ds1);

        seg->A=vector2(f0, v0);
        seg->B=vector2((2.0f * f0 + f1) / 3.0f, v0 + dd0 / 3.0f);
        seg->C=vector2((f0 + 2.0f * f1) / 3.0f, v1 - ds1 / 3.0f);
        seg->D=vector2(f1, v1);
        seg++;
      }
    }
  }
void NormalInterpolatorNode::outputContext(ostream &printStream, const char *indentString) 
{
	if (0 < getNKeys()) {
		MFFloat *key = getKeyField();
		printStream << indentString << "\tkey [" << endl;
		key->MField::outputContext(printStream, indentString, "\t\t");
		printStream << indentString << "\t]" << endl;
	}

	if (0 < getNKeyValues()) {
		MFVec3f *keyValue = getKeyValueField();
		printStream << indentString << "\tkeyValue [" << endl;
		keyValue->MField::outputContext(printStream, indentString, "\t\t");
		printStream << indentString << "\t]" << endl;
	}
}