- 积分
- 16
- 帖子
- 4
- 主题
- 2
- 精华
- 0
- 最后登录
- 2009-5-16
- 在线时间
- 14 小时
- 私信
|
发表时间 : 2009-5-6 11:03:11
|
浏览 : 1408 评论 : 1
vp2.2 中class vpApp取消成员变量:vpKernel* s_vpKernel;(特别注意:该变量在vp2.2中已经不能使用)
vp2.2中class vpApp增加以下成员变量: bool m_bDrawGraph;
typedef vuVector< vuField<vpGraphController*, vuFieldTraitMemBase> > vpGraphControllerVector;
vpGraphControllerVector m_graphDrawerVec;
bool m_bCaptureVideo;
int m_recordingIndex;
typedef vuVector< vuField<vsVideoCapture*, vuFieldTraitMemBase> > vsVideoCaptureVector;
vsVideoCaptureVector m_videoCaptureVec;
并且增加内部类:
class vpGraphController : public vuMemBase,
public vpKernel::Subscriber,
public vsGraphDrawerSubscriber{
public:
vpGraphController(vpChannel* channel) : m_channel(channel),
m_graphDrawer(new vsGraphDrawer),
m_graphNode(NULL)
{
if(m_channel.get() == NULL || m_channel->getRootNode() == NULL){
assert(0);
}
m_graphDrawer->setBoundsEnable(true);
m_graphDrawer->addSubscriber(vsGraphDrawer::EVENT_GRAPH_NODE_SELECTED, this);
}
void setGraphDrawerEnable(bool enable){
if(enable){
m_graphDrawer->setRootNode(const_cast<vsNode*>(m_channel->getRootNode()));
m_channel->addSubscriber(vsChannel::EVENT_POST_DRAW, m_graphDrawer.get());
}else{
m_channel->removeSubscriber(vsChannel::EVENT_POST_DRAW, m_graphDrawer.get(), true);
}
}
int panUp() { return m_graphDrawer->panUp();}
int panDown() { return m_graphDrawer->panDown();}
int panLeft() { return m_graphDrawer->panLeft();}
int panRight() { return m_graphDrawer->panRight();}
int scaleUp() { return m_graphDrawer->scaleUp();}
int scaleDown() { return m_graphDrawer->scaleDown();}
protected:
~vpGraphController(){}
/**
* Graph Drawer subscriber. Registers a vpKernel subscriber so that
* observer relocation during picking is performed during the context of
* the main application thread.
*/
void notify(vsGraphDrawer::Event ev, const vsGraphDrawer* gr, vsNode* node){
if(ev == vsGraphDrawer::EVENT_GRAPH_NODE_SELECTED && node != NULL){
static_cast<vpKernel*>(vpKernel::instance())->addSubscriber(
vpKernel::EVENT_POST_PROCESS_LATENCY_CRITICAL, this);
m_graphNode = node;
}
}
/**
* vpKernel subscriber used to updated observer position from graph
* picking during the context of the main application thread.
*/
void notify(vpKernel::Event ev, const vpKernel* kernel){
vpKernel::instance()->removeSubscriber(
vpKernel::EVENT_POST_PROCESS_LATENCY_CRITICAL, this, true);
vpObserver* observer = *vpObserver::begin();
if(m_graphNode == NULL && observer)
return;
m_traversalLocate.reset();
// If matrix results are requested, set the matrix stack;
m_traversalLocate.setMode(vsTraversalLocate::MODE_MATRIX_STACK |
vsTraversalLocate::MODE_NODE_STACK);
m_traversalLocate.visit(m_graphNode);
vuVec3d matTranslate;
m_traversalLocate.getTopMatrixStack().getTranslate(
&matTranslate[0], &matTranslate[1], &matTranslate[2]);
vuSphere<double> bsphere = m_graphNode->getBounds();
if(m_graphNode->isOfClassType(vsGeometryBase::getStaticClassType()))
bsphere.m_ctr+=matTranslate;
bsphere.m_ctr[1] += vuMax(-50000.0,-bsphere.m_radius*2);
vuVec3d rot;
observer->setPosition(bsphere.m_ctr[0],bsphere.m_ctr[1],
bsphere.m_ctr[2]);
observer->setOrientation(0.0, 0.0, 0.0);
m_graphNode = NULL;
}
private:
vuField<vpChannel*> m_channel;
vuField<vsGraphDrawer*, vuFieldTraitMemBase> m_graphDrawer;
vsTraversalLocate m_traversalLocate;
vsNode* m_graphNode;
};
其它的不同请自己查看vpApp源代码。 |
|