如何在Maya中创建带有边界框的MPxTransform节点
How to create an MPxTransform node in Maya with a bounding box?
在cpp中,我正在寻找在Maya中创建带有边界框的MPxTransform节点的代码。但是,我的代码既没有在大纲中添加转换节点,也没有创建边界框。我错过了什么?
. cpp文件:
myClass::myClass() // Entry point: This one is executed
{
myMPxTransformClass prox;
MPxTransformationMatrix *transformMtrx;
transformMtrx=prox.createTransformationMatrix();
// What is missing here to get the node registered in Maya and bounding box displayed ?
}
myMPxTransformClass::myMPxTransformClass() // This one is executed
{
MGlobal::displayInfo("MPx Initialized");
}
bool myMPxTransformClass::isBounded() // This one is not called
{
MGlobal::displayInfo("isBounded returned");
return true;
}
MBoundingBox myMPxTransformClass::boundingBox() // This one is not called
{
MPoint p1,p2;
p1=MPoint(-1,-1,-1);
p2=MPoint(1,1,1);
MGlobal::displayInfo("Bounding box returned");
return MBoundingBox(p1,p2);
}
和相应的。h文件
class myMPxTransformClass : public MPxTransform
{
public:
myMPxTransformClass();
virtual ~myMPxTransformClass() {};
protected:
virtual MBoundingBox boundingBox();
bool isBounded();
};
如果要编写插件,则需要实现3个常用功能:
-
initializePlugin,在加载插件时调用
-
uninitializePlugin,当插件被卸载时调用Maya调用来创建对象的新实例,例如create节点
-
creator, Maya调用创建对象的新实例,如
createNode
这是一个示例代码:
#include "include/HelloWorldCmd.h"
#include <maya/MFnPlugin.h>
void* HelloWorld::creator() { return new HelloWorld; }
MStatus HelloWorld::doIt(const MArgList& argList) {
MGlobal::displayInfo("Hello World!");
return MS::kSuccess;
}
MStatus initializePlugin(MObject obj) {
MFnPlugin plugin(obj, "Chad Vernon", "1.0", "Any");
MStatus status = plugin.registerCommand("helloWorld", HelloWorld::creator);
CHECK_MSTATUS_AND_RETURN_IT(status);
return status;
}
MStatus uninitializePlugin(MObject obj) {
MFnPlugin plugin(obj);
MStatus status = plugin.deregisterCommand("helloWorld");
CHECK_MSTATUS_AND_RETURN_IT(status);
return status;
}
在这里你可以找到更多关于它的信息:
http://www.chadvernon.com/blog/resources/maya-api-programming/your-first-plug-in/相关文章:
- std::当在256字节边界上写入整数时,流的奇怪行为
- 使用不变量来确定二分搜索中的边界条件
- 跨 DLL 边界访问虚拟方法是否安全/可能?
- 在 64 位边界上对齐C++结构数组?
- std::数组边界检查如何工作?
- CGAL:如何创建填充边界曲线的曲面网格?
- 在 c++ 中是否允许创建具有运行时边界的数组?
- 是否可以跨 dll 边界返回常量引用/指向 std::vectors?
- C++11:16 字节原子<>变量是否在 16 字节边界上自动对齐,从而允许CMPXCHG16B指令?
- 转换引用对象的边界框?
- 将迭代器作为 3 个元素的滑动窗口,可以超调边界(可能使用 Boost)
- 算法设计:用边界数字表示 2D 网格的最佳方式,以C++?
- 查找矩形的边界集
- 在sfml中获取可转换的边界框
- SystemC sc_signal数组内存边界
- 如何处理libstdc++跨执行边界抛出的异常
- BoostSpirit.Qi-针对原始数据类型进行边界检查
- 在运行时为随机分布类成员设置最小和最大边界?
- Java 中的边界椭圆实现
- 如何在Maya中创建带有边界框的MPxTransform节点