问题标签 [maya-api]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2599 浏览

python - maya python迭代大量顶点

我正在用 python 编写一个脚本,让 Maya 将顶点位置从一侧交换到另一侧。因为我希望翻转是基于拓扑的,所以我使用拓扑对称选择工具来查找顶点对应关系。我设法使用 filterExpand 和 xform 做到了这一点。问题是它在大型多边形网格上非常慢,我想知道如何使用 openMaya 来代替。

将 maya.cmds 导入为 cmds

谢谢毛里齐奥

0 投票
1 回答
148 浏览

function - 2 个 Maya 插件之间的通信

我正在用 C++ 开发 2 个 Maya 插件,并且想从插件 #2 调用插件 #1 中的一个函数,并与函数一起发送参数。

调用者插件是 MPxNode,被调用插件应该是“通用”函数,其作用是创建一些渲染 VRayPlugins。

我应该如何继续声明和调用适当的函数?

0 投票
2 回答
915 浏览

c++ - 优化 MPxLocatorNode 绘制

MPxLocatorNode在 C++ 中使用 Maya api 创建了一个。该节点没有compute方法,它只是在方法中使用open gl绘制的不同样式的形状draw

它绘制的一种样式是十字架,与定位器完全相同。因此,我进行了一些基准测试以将其与本机定位器进行比较,并注意到我的节点的性能要慢得多。Maya 的定位器大约快 4 倍!

1000 个节点

我的节点:74 fps

Maya 的定位器:300 fps

我做错了什么会降低节点的性能?我唯一能想到的是,我在方法中获取了节点的MObjectsvia ,这与MPlugdraw方法中从数据块中获取它们不同compute

我的 cpp 文件如下。大多数减速应该在draw方法中。

编辑

我正在评论部分代码以找出减速的​​地方,看起来一旦我取消注释 gl draw 方法,性能就会从 300 fps 下降到 80 fps。那怎么办??

0 投票
1 回答
772 浏览

qt - 获取Maya中某类节点对应的图标

我想在 Maya 内的 Qt 工具中使用大纲工具为 Maya 中的节点显示的相同图标?有什么方法可以根据类型找到我拥有的节点的 Qt 中的图标或图标的路径?

有没有什么方法可以使用代码来获取这些图标?

0 投票
1 回答
1036 浏览

c++ - Maya API 复制/删除复合数组属性

我正在编写一个变形器节点,它将世界矩阵和圆柱体的可见性作为输入。圆柱体被组织成组,这种结构反映在我的变形器上。我有一个二维数组,由带有儿童圆柱体的组组织,每个数组都是一个复合属性,因此我可以控制整个组的可见性和单个孔。

这是属性设置:

我已经编写了 python 脚本来为此添加一个圆柱体,它将确定它应该属于哪个组,添加一个新条目并将可见性和 worldMatrix 连接起来。

我对这个设置有几个问题。首先,删除圆柱体的行为符合我的预期,因为我已经定义了 disconnectBehaviour 来删除数组中的实例。但是,删除组会在层次结构的顶层留下一个断开连接的属性,我必须手动清理它。

其次,虽然删除效果很好,但如果也可以使用复制,那将非常方便。因此,如果有人复制了一个圆柱体,则会创建一个数组条目并连接必要的属性。这可能吗?到目前为止,使用变形器的人自然会尝试这样做,我不得不让他们使用脚本。

0 投票
1 回答
344 浏览

c++11 - Importing animation keytracks into Maya

I have a human bipedal animation file format that I would like to programmatically read into Maya using the C++ API.

The animation file format is similar to that of the Open Asset Importer's per-node animation structure.

For every joint, there is a series of up to 60 3D vector keys (to describe the translation of the joint) and 60 quaternion keys (to describe the rotation of the joint). Every joint is guaranteed to have the same number of keys (or no keys at all).

The length (time in seconds) of the animation can be specified or changed (so that you can set the 60 keys to happen over 2 seconds for a 30 FPS animation, for example).

The translations and rotations of the joints propagates down the skeleton tree every frame, producing the animation.

Here's a sample. Additional remarks about the data structure are added by the logging facility. I have truncated the keys for brevity.

In C++, the data structure I currently have corresponds to this:

std::unordered_map<string, std::vector<Vector3>> TranslationKeyTrack is used to map a set of translation vectors to the corresponding bone.

std::unordered_map<string, std::vector<Quaternion>> RotationKeyTrack is used to map a set of rotation quaternions to the corresponding bone.

Additional notes: There are some bones that do not move relative to its parent bone; these bones have no keys at all (but has an entry with 0 keys). There are also some bones that have only rotation, or only position keys. The skeleton data is stored in a separate file that I can already read into Maya using MFnIkJoint.

The bones specified in the animation file is 1:1 to the bones in that skeleton data.

Now I would like to import this animation data into Maya. However, I do not understand Maya's way of accepting animation data through its C++ API.

In particular, the MFnAnimCurve function set addKeyFrame or addKey accepts only a single floating point value tied to a time key, while I have a list of vectors and quaternions. MFnAnimCurve also accepts 'tangents'; after reading the documentation, I am still unsure of how to convert the data I have into these tangents.

My question is: How do I convert the data I have into something Maya understands?

I understand better with examples, so some sample code will be helpful.

0 投票
0 回答
549 浏览

c++ - 如何使用 Maya API 撤消删除网格?

我正在尝试使用 C++ API 编写一个 Maya 插件,该插件将识别选择中的网格,(计算一些东西),删除它们,然后在场景中插入一个新的网格。

我通过与objExporter插件示例相同的方式收集选定的网格。我正在使用 aMDagModifier删除网格节点并尝试撤消这些更改。但undoIt它不起作用......

这是我的简化代码:

(我想坚持使用 C++ API 并避免使用 MEL/Python 接口)。

如何deleteNode正确撤消操作?

0 投票
4 回答
2916 浏览

python - 通过python在maya中设置渲染图像路径

我想在 Maya 2015 的特定位置渲染图像。

为此,我想通过 python(pymel 或 cmds)设置图像输出路径。

使用上面的代码,我可以更改给我非常接近结果的项目目录。

但是项目窗口中的“图像”变量仍然设置为图像。

如何在项目窗口的图像中添加“D:\my_renderpath”。

0 投票
2 回答
160 浏览

maya - 连接本地网络上的两个 Maya

如何在局域网中连接两个maya。

例如。

2个用户在局域网的不同计算机上打开maya软件,并通过python commandPort连接到maya会话。

最终目标是两个用户可以同时编辑同一个模型。当用户 1 移动顶点或面..等时,这些更改应实时显示在其他用户的视口中,反之亦然。

0 投票
1 回答
290 浏览

c++ - 创建指向 MFnMesh 的指针

我正在尝试创建接收MFnMesh指针并在其上执行操作的函数。

问题是我无法将 my 转换MFnMesh为指针,我认为问题不仅在这个类上,而且在MFnBaseClass因为我收到这个错误。

这是函数测试,它somefile.h包含在调用函数的文件中。

这是我在调用test函数之前所做的。

我没有找到将 my 转换MFnMesh为指针的任何方法,因此我尝试将其直接称为对象,而不是像这样的指针。

我明白了:

那么您知道是否有办法创建一个以时尚方式作用于类的函数,MFnBase甚至是具有MFnBase属性的类?我不知道我们不能做这种真正流行的过程。

我是 C++ 新手,所以我可能犯了一个愚蠢的错误。