本文整理汇总了C++中KeyFrame::setTime方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyFrame::setTime方法的具体用法?C++ KeyFrame::setTime怎么用?C++ KeyFrame::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyFrame
的用法示例。
在下文中一共展示了KeyFrame::setTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sender
void
KnobGui::onSetKeyActionTriggered()
{
QAction* action = qobject_cast<QAction*>( sender() );
assert(action);
int dim = action->data().toInt();
KnobPtr knob = getKnob();
assert( knob->getHolder()->getApp() );
//get the current time on the global timeline
SequenceTime time = knob->getHolder()->getApp()->getTimeLine()->currentFrame();
AddKeysCommand::KeysToAddList toAdd;
KnobGuiPtr thisShared = shared_from_this();
for (int i = 0; i < knob->getDimension(); ++i) {
if ( (dim == -1) || (i == dim) ) {
std::list<boost::shared_ptr<CurveGui> > curves = getGui()->getCurveEditor()->findCurve(thisShared, i);
for (std::list<boost::shared_ptr<CurveGui> >::iterator it = curves.begin(); it != curves.end(); ++it) {
AddKeysCommand::KeyToAdd keyToAdd;
KeyFrame kf;
kf.setTime(time);
Knob<int>* isInt = dynamic_cast<Knob<int>*>( knob.get() );
Knob<bool>* isBool = dynamic_cast<Knob<bool>*>( knob.get() );
AnimatingKnobStringHelper* isString = dynamic_cast<AnimatingKnobStringHelper*>( knob.get() );
Knob<double>* isDouble = dynamic_cast<Knob<double>*>( knob.get() );
if (isInt) {
kf.setValue( isInt->getValue(i) );
} else if (isBool) {
kf.setValue( isBool->getValue(i) );
} else if (isDouble) {
kf.setValue( isDouble->getValue(i) );
} else if (isString) {
std::string v = isString->getValue(i);
double dv;
isString->stringToKeyFrameValue(time, ViewIdx(0), v, &dv);
kf.setValue(dv);
}
keyToAdd.keyframes.push_back(kf);
keyToAdd.curveUI = *it;
keyToAdd.knobUI = thisShared;
keyToAdd.dimension = i;
toAdd.push_back(keyToAdd);
}
}
}
pushUndoCommand( new AddKeysCommand(getGui()->getCurveEditor()->getCurveWidget(), toAdd) );
}
示例2:
void
DSPasteKeysCommand::addOrRemoveKeyframe(bool add)
{
for (std::list<boost::weak_ptr<DSKnob> >::const_iterator it = _dstKnobs.begin(); it != _dstKnobs.end(); ++it) {
DSKnobPtr knobContext = it->lock();
if (!knobContext) {
continue;
}
for (std::size_t i = 0; i < _keys.size(); ++i) {
int dim = knobContext->getDimension();
KnobIPtr knob = knobContext->getInternalKnob();
knob->beginChanges();
double keyTime = _keys[i].key.getTime();
double setTime = _pasteRelativeToRefTime ? keyTime - _keys[_refKeyindex].key.getTime() + _refTime : keyTime;
if (add) {
for (int j = 0; j < knob->getDimension(); ++j) {
if ( (dim == -1) || (j == dim) ) {
KeyFrame k = _keys[i].key;
k.setTime(setTime);
knob->setKeyFrame(k, ViewSpec::all(), j, eValueChangedReasonNatronGuiEdited);
}
}
} else {
for (int j = 0; j < knob->getDimension(); ++j) {
if ( (dim == -1) || (j == dim) ) {
knob->deleteValueAtTime(eCurveChangeReasonDopeSheet, setTime, ViewSpec::all(), j, i == 0);
}
}
}
knob->endChanges();
}
}
_model->refreshSelectionBboxAndRedrawView();
} // DSPasteKeysCommand::addOrRemoveKeyframe
示例3: loadFromXML
bool AnimationTrack::loadFromXML(TiXmlElement *xmlNodeTrack)
{
xmlNodeTrack->QueryStringAttribute("name",&m_name);
stringc dataType;
xmlNodeTrack->QueryStringAttribute("dataType",&dataType);
m_dataType = stringToDataType(dataType);
TiXmlHandle hXmlNode(xmlNodeTrack);
//load keyframes data
TiXmlElement* xmlNodeTimes = hXmlNode.FirstChild( "times" ).Element();
if(xmlNodeTimes!=0)
{
int kfNum = 0;
//times
const char* timesStr = xmlNodeTimes->GetText();
if(timesStr!=0)
{
float *times=0;
kfNum = StringUtil::splitOutFloats(times, timesStr);
for(int i=0; i<kfNum; ++i)
{
KeyFrame* kf = createKeyFrame();
if(kf!=0)
{
kf->setTime(times[i]);
m_keyFrames.push_back(kf);
}
}
delete times;
}
//at least has 1 kf
if(kfNum>0)
{
//KF datas
float *kfDatas=0;
TiXmlElement* xmlNodeKFs = hXmlNode.FirstChild( "keyframes" ).Element();
if(xmlNodeKFs!=0)
{
int valueNum = StringUtil::splitOutFloats(kfDatas, xmlNodeKFs->GetText());
u32 dataElemNum = m_keyFrames[0]->getDataElementNum();
FLT_ASSERT(dataElemNum>0 && valueNum/dataElemNum==kfNum);
for(int i=0; i<kfNum; ++i)
{
m_keyFrames[i]->loadValue(kfDatas, i);
}
delete kfDatas;
}
//interp datas
TiXmlElement* xmlNodeInterps = hXmlNode.FirstChild( "interps" ).Element();
if(xmlNodeInterps!=0)
{
array_t<stringc> strs;
strs = StringUtil::split(xmlNodeInterps->GetText(), ",", kfNum);
FLT_ASSERT(strs.size()==kfNum);
for(int i=0; i<kfNum; ++i)
{
m_keyFrames[i]->setInterpTypeByString(strs[i]);
}
}
}
//create a computed frame, for interpolation
m_computedFrame = createKeyFrame();
}
return true;
}