如何将3D模型从MAYA等3D建模软件导入OpenGL,尤其是PC而不是Iphone开发?
我有来自Maya 2013 API的示例命令插件的问题.为了清楚起见,插件的代码已被拆分为.h和.cpp文件,但应该是正确的.
pluginCmd.h:
// Include the needed headers.
#include <stdio.h>
#include <maya/MString.h>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MPxCommand.h>
#include <maya/MIOStream.h>
// Class to represent our command.
class commandExample : public MPxCommand
{
public:
commandExample();
virtual ~commandExample();
MStatus doIt( const MArgList& );
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const;
static void* creator();
};
Run Code Online (Sandbox Code Playgroud)
pluginCmd.cpp:
// Include the header for the file.
#include "pluginCmd.h"
// Constructor for the command object.
commandExample::commandExample() {
cout << "In commandExample::commandExample()\n";
}
// Destructor for …Run Code Online (Sandbox Code Playgroud) 我正在按照本教程学习如何使用Three.js加载Maya模型.
一切都很好,但是教程只解释了如何使用一个纹理加载模型.
这是教程中的源代码:
function createScene(geometry, x, y, z, scale, tmap) {
zmesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture(tmap)}));
zmesh.position.set(x, y, z);
zmesh.scale.set(scale, scale, scale);
meshes.push(zmesh);
scene.add(zmesh);
}
Run Code Online (Sandbox Code Playgroud)
完整的JS Live Link
var SCREEN_WIDTH = window.innerWidth;
var SCREEN_HEIGHT = window.innerHeight;
var container;
var camera, scene;
var canvasRenderer, webglRenderer;
var mesh, zmesh, geometry, materials;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var meshes = [];
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = …Run Code Online (Sandbox Code Playgroud) 如何选择/获取字符串数组列表中的值?
当我执行代码来读取我的文件中的内容时,它如下:
for line in testFile:
test = line.split()
#Output:
['1', '21', '32', '43', '54', '65', '76', '87']
['2', '31', '42', '53', '64', '75', '86', '97']
['3', '41', '52', '63', '74', '85', '96', '107']
...
...
Run Code Online (Sandbox Code Playgroud)
但是,现在据说我想选择并获取第一个值 - 1,2,3仅在输出中,我得到['1', '21', '32', '43', '54', '65', '76', '87']或最后一行的值,我应该编码print test[0]还是for item in test..
这意味着,如果我决定抓住第3列的值,它会给我32,42,52,如果我抓住第6列,它会给我65,75,85等等.列数是相同的,我问这个因为我要么去设置旋转/平移属性中的值,而第一列是帧编号...
有可能这样做吗?
在阅读所有这些并迷失之前,我的主要问题是如何解压缩单个像素阵列并解释open gl如何读取这些数据.(我的背景不是c ++,而是python)
非常感谢您的帮助.
我正在使用具有一类MImage的maya(3d程序)来获取图像的像素数据.返回结果是一个单独的数组,每4个项目是RGBA这是我需要解压缩
pixels = [255, 255, 0, 255, 255, 255, 0, 255] //two yellow pixels and it keeps going with this pattern
Run Code Online (Sandbox Code Playgroud)
以下代码创建一个包含4个通道的256 x 256图像
unsigned int size = 256;
unsigned int depth = 4;
float color[3] = {1, 1, 0};
unsigned char *pixels = new unsigned char[size * size * depth];
for(unsigned int i = 0; i < size; i += depth){
MScriptUtil::setUcharArray(pixels, i+0, (int)floorf(color[0] * 255.0f + 0.5f));
MScriptUtil::setUcharArray(pixels, i+1, (int)floorf(color[1] * 255.0f + 0.5f)); …Run Code Online (Sandbox Code Playgroud) 如何通过 python 命令更改 Maya 中的当前渲染器。例如:“maya 软件”到“mental ray”,反之亦然任何 python 或 pymel 命令。?
import pymel.core as pm
import maya.cmds as cmds
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用maya 2015的pycharm(最新社区版).我需要的第一件事是能够引用maya命令模块,但我似乎无法找到如何.
import maya.cmds as cmds
Run Code Online (Sandbox Code Playgroud)
失败了
ImportError: No module named maya.cmds
Run Code Online (Sandbox Code Playgroud)
我需要做些什么才能让它发挥作用?
历史选项卡中打印的所有 Maya 脚本日志和错误。这是所有命令和 python 脚本的输出。
为了更好的调试脚本,我希望所有日志都发送到服务器上的某个地方。如何拦截并将输出发送到您的脚本。然后我会做所有必要的事情,输出要么是远程控制台,要么是服务器上文件中的某个地方。
拦截输出的任务。怎么做?
我需要用参考中的新文件替换旧文件。有一个referenceEdit命令,但没有用于替换文件的标志。
所以理想情况下我需要诸如:
cmds.referenceQuery( myReference, e=1, file=NEW )
Run Code Online (Sandbox Code Playgroud) 嘿,我正在编写一个工具来读取场景中的所有当前引用。我正在为每个引用创建一个文本字段和单选按钮。现在我想检查新版本的参考文件路径。如果有新版本,它应该将文本字段涂成黄色。
如何获取每个参考的路径?我想知道 Maya 中是否有任何内置内容可以提供当前在 Maya 中加载的引用的路径。我想在下面的循环中检查 referenceList 中的每个参考
#get references
referenceList = cmds.ls(rf = True)
for reference in referenceList:
print reference
cmds.textField(reference)
cmds.radioCollection()
cmds.radioButton(label = '')
cmds.radioButton(label = '')
cmds.textField(reference, edit = True, text = reference)
# newVersionFound = False
if newVersionFound == True:
cmds.textField(reference, edit = True, backgroundColor = [0.6,0.5,0])
Run Code Online (Sandbox Code Playgroud)
如果没有快速解决方案,我可能会根据参考名称构建路径字符串,因为我们的管道允许这样做。
问候,祝你有美好的一天!