[Closed] SDK soft selection data for editable poly?
I know I can use this for editable mesh objects:
TriObject *triOb = reinterpret_cast<TriObject *>(os->obj);
Mesh& mesh = triOb->GetMesh();
float *weights = mesh.getVSelectionWeights();
But this won’t work on an editable poly, and I’ve been unable to find an equivalent.
This works when the object the modifier is applied to is an editable mesh, but not when it is an editable poly:
void TestModifier::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node) {
TriObject *triOb = reinterpret_cast<TriObject *>(os->obj);
Mesh& mesh = triOb->GetMesh();
float *weights = mesh.getVSelectionWeights();
for (int i = 0; i < mesh.getNumVerts(); i++) { mprintf(_T("%f, "), weights[i]); }
mprintf("
");
}
What do I need to change to make it work for an editable poly?
this is the generic method for handling meshes of all types (there are a few “specialised” cases
Object *obj = os->obj;
if(!obj) return;
if (obj->IsSubClassOf(triObjectClassID)) // Handle any triobject types
{
TriObject* triobj = (TriObject*)obj;
......
}
else if (obj->IsSubClassOf(polyObjectClassID)) // Handle any PolyObject types
{
PolyObject* polyObj = (PolyObject*)obj;
........
}
else if (obj->CanConvertToType(triObjectClassID)) // all others box/geosphere/etc should try to convert to a triobject,
{
TriObject *triOb = (TriObject *)obj->ConvertToType(t, triObjectClassID);
// Now stuff this into the pipeline!
os->obj = triOb;
.........
}
i usual then just have 2 Overloaded functions that handle tri & poly objects respectively
Hm. When I try to use
obj->IsSubClassOf(polyObjectClassID)
it gives me the following error:
1>TestModifier.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class Class_ID polyObjectClassID" (__imp_?polyObjectClassID@@3VClass_ID@@A)
1>C:\Program Files\Autodesk\3ds Max 2012\plugins\TestModifier.dlm : fatal error LNK1120: 1 unresolved externals
It is included…
EDIT:
Also, polyObjectClassID on its own is not a problem, it is only when used with IsSubClassOf that I am having a problem.
EDIT (AGAIN):
For my current purposes, I have it working by replacing the condition with
if (obj->ClassID() == EPOLYOBJ_CLASS_ID) {
...
}
but obviously I would still like to get it working the other way.
it gives me the following error:
thats a linker error you need to add the additional dependencies is the linker part of the project props
poly.lib
mnmath.lib
Also, I am still not sure what I’m supposed to do in order to use the getVSelectionWeights method with a PolyObject, since, for example,
Mesh& mesh = polyOb->GetMesh();
will not compile.
Edit:
(Thanks for the linker info. I have no idea how someone would know to do that.)
Okay, got it working. I was wondering what MNMesh was all about, and still have some research to do, but at least I’m off to a start now (if a bumpy one).