抱歉,如此具体的应用程序,但我注意到另一篇关于 Maya 开发的回答很好的帖子。
我刚刚为 Maya 编写了一个插件节点。它只是根据湍流函数杀死一堆粒子。湍流由许多可在属性编辑器中调整的属性驱动。
在属性编辑器中,还有一些其他属性,称为“缓存”和“节点状态”,它们放置在湍流属性之前。对于用户来说这看起来不太漂亮。
我想要做的就是在 GUI 中放置分隔线以将它们分开。如果您在属性编辑器中查看大多数其他 Maya 节点,它们正是这样做的。它们在面板上有水平可折叠栏,将不相关的属性彼此分开。
我的简单问题是,如何告诉 Maya 创建这些可折叠栏来分割属性?
谢谢你提供的所有帮助。
安迪
我有一个循环给我三个变量
matteGroup
matteName
object
Run Code Online (Sandbox Code Playgroud)
我想做一个嵌套的dicionary保存所有数据,如:
dictionary{matteGroup: {matteName: obj1, obj2, ob3} }
Run Code Online (Sandbox Code Playgroud)
我正在逐个检查对象,所以我想创建matteGroup它,如果它不存在,创建matteName它,如果它不exixst,然后创建或追加对象的名称.我尝试了许多解决方案,如普通字典,defaultdict和我在网上找到的一些自定义类,但我无法正常完成.我有一个很好的嵌套我无法追加,反之亦然.
这是循环
dizGroup = {}
dizName = {}
for obj in mc.ls(type='transform'):
if mc.objExists(obj + ('.matteGroup')):
matteGroup = mc.getAttr(obj + ('.matteGroup'))
matteName = mc.getAttr(obj + ('.matteName'))
if matteGroup not in dizGroup:
dizGroup[matteGroup] = list()
dizGroup[matteGroup].append(matteName)
if matteName not in dizName:
dizName[matteName] = list()
dizName[matteName].append(obj)
Run Code Online (Sandbox Code Playgroud)
有了这个,我分别得到了两本词典,但不是那么有用!任何提示?
谢谢
我正在开发一个glsl着色器程序,作为在"闭源"应用程序中运行的插件的一部分.应用程序(maya)是使用opengl 2.1编写的,但是我们的显卡支持opengl/glsl 4.1,我想在程序中使用镶嵌和几何着色器.应用程序设置opengl视口和传统的模型/视图矩阵堆栈,我无法控制代码的那一部分.
我的传递顶点着色器使用GLSL 1.2并且工作正常:
// GLSL VERTEX SHADER
#version 120
void main ()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Run Code Online (Sandbox Code Playgroud)
我的传递几何着色器使用glsl 4.1并且在应用程序中也可以正常工作:
// GLSL GEOMETRY SHADER
#version 410
layout (lines_adjacency) in;
layout (line_strip, max_vertices = 2) out;
void main ()
{
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
EmitVertex();
EndPrimitive();
}
Run Code Online (Sandbox Code Playgroud)
但这只是一个传递测试.在我的真实几何着色器中,我需要在世界空间中进行一些计算,但几何着色器点在视图空间中.我的问题是:我可以在4.1几何着色器中访问gl_ModelViewProjectionMatrix吗?我知道传统的矩阵堆栈已经在glsl 4.1中被弃用,而不是统一变量,但我无法改变应用程序.我不能在几何着色器中使用glsl 1.2,因为我需要lines_adjacency输入类型.我是否需要在我的插件的C++源代码中将矩阵复制到一个统一变量中?或者是否有一个"后门"直接从glsl 4.1获取它?或者其他我没想到的东西?
可能重复:
在Android上渲染Maya动画?
想在android中使用maya对象.有没有任何工具和脚本可以帮助我在android项目中使用maya对象,这样我就可以在maya中渲染该对象并尝试开发简单的游戏
我是Python的新手,我甚至完全迷失在哪里开始完成这项工作.
我已经编写了许多小模块(maya的工具集),需要在单个.pyc文件中编译.有没有一个模块可以做到这一点?或者你能告诉我从哪里开始吗?教程?我甚至都不知道要查找的条款.
我正在为Maya编写一个简单的工具菜单,我想将它粘贴到模型面板的边框(透视图).
from PySide import QtCore, QtGui
from maya import OpenMayaUI as omui
from shiboken import wrapInstance
class TestWidget(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent = self.getMayaWindow())
self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.FramelessWindowHint)
self.setFixedSize(100, 100)
panelPtr = omui.MQtUtil.findControl('modelPanel4')
panel = wrapInstance(long(panelPtr), QtGui.QWidget)
position = panel.mapToGlobal(panel.pos())
self.move(position.x(), position.y() + panel.geometry().height() / 2 - self.geometry().height() / 2)
mainLayout = QtGui.QVBoxLayout(self)
button = QtGui.QPushButton('CLOSE')
button.setFixedSize(80, 80)
button.clicked.connect(self.deleteLater)
mainLayout.addWidget(button)
def getMayaWindow(self):
omui.MQtUtil.mainWindow()
ptr = omui.MQtUtil.mainWindow()
return wrapInstance(long(ptr), QtGui.QWidget)
w = TestWidget()
w.show()
Run Code Online (Sandbox Code Playgroud)
主窗口小部件在创建时正好位于我想要的位置(水平位于模型面板的左侧,垂直位于模型面板的中间).
我需要在调整模型面板大小时重新定位它,但模型面板不会发出resized()信号.我很感激任何建议.
我需要获取所有选定的顶点并将它们存储在一个数组中,这样我就可以遍历并找出有关每个顶点的信息.
虽然我无法弄清楚这一点.
sel = cmds.ls(sl=1)
print sel
Run Code Online (Sandbox Code Playgroud)
返回:
//[u'pCube1.vtx[50:53]', u'pCube1.vtx[74:77]']
Run Code Online (Sandbox Code Playgroud)
或多或少我需要我的'sel'变量来打印出这个:
pCube1.vtx[50]
pCube1.vtx[51]
pCube1.vtx[52]
pCube1.vtx[53]
pCube1.vtx[74]
pCube1.vtx[75]
pCube1.vtx[76]
pCube1.vtx[77]
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何做到这一点,而不是字面上剥离字符串?我认为这是一个非常混乱的方式,并想知道是否有另一种可能性!也许使用OpenMaya的Maya API?
我正在使用 C++ 为 Autodesk Maya 编写一个插件,但出现链接器错误。
我的主类是 Maya_Search_Plugin.cpp
#include <Utilities.h>
DeclareSimpleCommand( search_face, PLUGIN_COMPANY, "4.5");
//doIt method is entry point for plugin
MStatus search_face::doIt( const MArgList& )
{
//calls to Maya types/functions and Utilities functions
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个实用程序类,其中包含一些静态方法,其标头如下所示
#ifndef __Maya_CPP_Plugin__Utilities__
#define __Maya_CPP_Plugin__Utilities__
//#pragma once
//standard libs
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <math.h>
//maya libs
#include <maya/MDagPath.h>
#include <maya/MFn.h>
#include <maya/MFileIO.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MTypes.h>
#include <maya/MPointArray.h>
#include <maya/MObjectArray.h> …Run Code Online (Sandbox Code Playgroud) 这是一个命名脚本,用于命名Autodesk Maya中的节点.然而,这个特定的脚本并没有使用特定的任何东西.
我刚才问过我会怎么做这样的事情,可以使用变量约定,然后出现模板.
所以如果我有这样的约定:
'${prefix}_${name}_${side}_${type}'
Run Code Online (Sandbox Code Playgroud)
我可以传递这些论点:
bind_thigh_left_joint
Run Code Online (Sandbox Code Playgroud)
然后通过缩写词典(以及用户缩写词典)运行它们,使用场景文件中的相关节点进行检查以确保没有重复项,最后得到: bn_thigh_L_jnt
但是我想要它,以便如果其中一个键具有第一个大写字母,它将使替换大写.
例如,如果{$prefix}是代替{$Prefix}大腿会成为大腿,或者如果{$prefix}是{$PREFIX}大腿会成为大腿上.但是,如果它是{$PREfix}大腿仍然只是大腿.
我可以很容易地做到这一点,除了我无法检测钥匙的个别情况.例如,如果字符串是'${Prefix}_${name}_${SIDE}_${type}'我如何找到什么案例前缀,如果我知道,我将如何使用此模板?
请注意,这段代码不是我所拥有的确切代码,我已经省略了许多其他更具特色的东西,这只是处理替换本身.
from string import Template
import collections
def convert(prefix, name, side, obj_type):
user_conv = '${Prefix}_${name}_${SIDE}_${type}'
# Assigns keys to strings to be used by the user dictionary.
subs = {'prefix': prefix, 'name': name, 'side': side, 'type': obj_type}
# Converts all of user convention to lowercase, and substitutes the names from subs.
new_name = Template(user_conv.lower())
new_name = …Run Code Online (Sandbox Code Playgroud) .ma我正在尝试在 Python 脚本末尾打开一个 Maya 场景,
路径看起来像这样:G:\ProjectPath\Scene.ma。
但我知道的唯一命令是 MEL 命令:
file -f -options "v=0; p=17; f=0" -ignoreVersion -typ "mayaAscii" -o
"G:/ProjectPath/Scene.ma";
addRecentFile("G:/ProjectPath/Scene.ma", "mayaAscii");
Run Code Online (Sandbox Code Playgroud)
有人知道如何用 Python 实现这一点吗?