简体   繁体   English

如何从已加载的.ive模型树中旋转/转换现有的OpenSceneGraph(OSG)节点?

[英]How do I rotate/translate existing OpenSceneGraph (OSG) nodes from a loaded .ive model tree?

I have a given model in .ive and the problem is that I'm trying to rotate a single node out of the whole tree model (existing in the .ive file). 我在.ive中有一个给定的模型,问题是我试图从整个树模型(存在于.ive文件中)中旋转一个节点。 Is that possible? 那可能吗? How can I do that? 我怎样才能做到这一点?

Sure, it can be done. 当然可以。

You first have to find the nodes that you want to manipulate. 您首先必须找到要操作的节点。 You should be able to do this by creating a subclass of osg::NodeVisitor, and using it to traverse the graph until you find the node you want to manipulate. 通过创建osg :: NodeVisitor的子类,并使用它遍历图,直到找到要操作的节点,您应该能够做到这一点。 If you've given the node a name, it can be simple to find the one you are looking for. 如果为节点指定了名称,则可以很容易找到所需的名称。 If not, you'll have to figure out some other unique characteristics of the node, or just pull all nodes of a certain type and try them one at a time. 如果不是这样,则必须弄清楚该节点的其他一些独特特性,或者只是拉出某种类型的所有节点,然后一次尝试一个。

Then, once you have that, you can just save a pointer and manipulate it directly. 然后,一旦有了它,就可以保存一个指针并直接对其进行操作。

See tutorials: 参见教程:

https://www.movesinstitute.org/Sullivan/OSGTutorials/osgDOF.html https://www.movesinstitute.org/Sullivan/OSGTutorials/osgDOF.html

and

https://www.movesinstitute.org/Sullivan/OSGTutorials/osgUpdate.htm https://www.movesinstitute.org/Sullivan/OSGTutorials/osgUpdate.htm

You will have to find the node that corresponds with that subsection of the model. 您将必须找到与模型的该子部分相对应的节点。 To do this you will need to identify something that is unique about that node (hopefully it has a name or something). 为此,您将需要标识该节点唯一的内容(希望它具有名称或其他内容)。

Once you have that node, you may need to break it off of the main tree, add a Transform of some kind (a PositionAttitudeTransform, probably) and then re-add your node as a child of the PAT. 拥有该节点后,您可能需要将其从主树上断开,添加某种Transform(可能是PositionAttitudeTransform),然后将您的节点重新添加为PAT的子代。

Then you can modify the rotations in the PAT. 然后,您可以修改PAT中的旋转角度。

You might use a visitor like the find named node(s) visitor to locate the node you want. 您可以使用诸如“查找命名节点”访问者之类的访问者来找到所需的节点。

Consider converting the .ive file to .osgt or .osg in order to see the structure (and hopefully node names) in the file. 考虑将.ive文件转换为.osgt或.osg,以便查看文件中的结构(并希望有节点名)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM