zhucde (虚拟闲人) 的博客

OGRE,FLY3D, 图形开发, 一起探讨吧.QQ超级群(500人):186898914 QQ群(200人):23806843
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

子节点(ChildNode)设置WorldPostion

Posted on 2011-02-26 00:20  zhucde  阅读(421)  评论(0编辑  收藏  举报
if(m_SceneManager->hasEntity("knot"))
	{

		Entity *pent=m_SceneManager->getEntity("knot");
		SceneNode *parentNode=pent->getParentSceneNode();
	//	SceneNode *parentNode=m_SceneManager->getRootSceneNode();
		SceneNode *pNode=parentNode->createChildSceneNode();

		static int newentflag=0;
		newentflag++;
		String name="newentflag_"+StringConverter::toString(newentflag);
		Entity *newEnt=m_SceneManager->createEntity(name,"sphere.mesh");
		pNode->attachObject(newEnt);
		pNode->setPosition(parentNode->_getDerivedOrientation().Inverse()*(pt-parentNode->getPosition())/parentNode->getScale());
		pNode->setScale(0.01,0.01,0.01);
	}

childNode->setPosition(ParentNode->_getDerivedOrientation().Inverse()*(需要设置的WorldPostion-parentNode->getPosition())/parentNode->getScale());