|
今天学制作时钟,在setDataVariance()后,addChild一个表针,出错
// 创建动态表针
osg::Node* myclock::CreateMoveHandler(const osg::Vec3 ¢er, float radius)
{
//得到当前的时间
SYSTEMTIME st;
::GetLocalTime(&st);
osg::Node * second = CreateHandler(osg::Vec3 (-10.0, 0.0, 0.0), osg::Vec3 (35, 0.0, 0.0)) ; //创建表针,另一个函数
//利用当前系统时间初始化角度
float aml = 60.0;
float angle0 , angle1, angle2 ;
angle0 = st.wSecond * 6.0 ;
//create path
osg::AnimationPath *secondamp = createAnimationPath(center, radius, aml, -120.0 + angle0);
aml *= 60.0;
osg::Group *model = new osg::Group;
osg::ref_ptr<osg::MatrixTransform> positioned = new osg::MatrixTransform;
positioned->setDataVariance(osg::Object:YNAMIC);
positioned->addChild(second); // 在这里出现错误,请教如何修改
//设置更新回调
osg:ositionAttitudeTransform *xform = new osg::PositionAttitudeTransform;
xform->setUpdateCallback(new osg::AnimationPathCallback(secondamp, 0.0, 1.0));
xform ->addChild(positioned);
model->addChild(xform );
return model;
}
|
|