[Closed] Moving vertices using SDK
Hi everyone,
I need some help with SDK. The goal is to change objects’ thickness by moving “bottom” vertices. To get their numbers, I open max script listener, select that vertices and define their numbers in my plugin.
Then, I load the model, get its mesh and move the vertices like this:
pluginInstance->ip->MergeFromFile("D:\ est.max", true, false, true, false, NULL, 0, 0);
INode * pNode = SceneNodeByNameCache::GetInst().GetSceneNodeByName("Box001", true, false);
Object * obj = pNode->GetObjectRef();
if (obj->ClassID() == EPOLYOBJ_CLASS_ID)
{
PolyObject * po = (PolyObject *)obj;
MNMesh &mesh = po->GetMesh();
for (int i = 0; i < V_COUNT; i++)
mesh.V(V_NUM[i])->p.z -= 10;
}
V_COUNT is the number of vertices to move, V_NUM is array of their numbers.
Here strange things start. V_COUNT vertices are moved, but not that I wanted to. It’s like they are stored mixed in the mesh.
What’s the mistake, or is there a way to move vertices easier?
Have you tried adding a DebugPrint before moving the vertex to check whether the vertices you’re moving are actually the right ones? Or at least have the same index as you intended.
Also, is V_NUM an int[] or a BitArray?
Thanks for replying fast,
No, I haven’t. I’ve just copied the indexes from max script listener – they SHOULD be right. But the thing is – they’re not!
V_NUM is an int array, but I’ve also tried to create a BitArray – it was successfully created, but how to move the selection after calling VertexSelect() method? I haven’t found any appropriate method in MNMesh and related classes…
There was an idea to set color of vertices and select them by color, but here’s the same problem – how to work with selection, not a single vertex? I’m dealing with 3ds max sdk for the first time and got lost a little bit.