Notifications
Clear all

[Closed] SDK node->

So still trying to get my head around the sdk a bit. I’m getting some basic stuff to happen like renaming selected objects…


void MyClass::FN_RenameNode(){
	ip = GetCOREInterface();

	int Node_Count;
	Node_Count = ip->GetSelNodeCount();

	for (int i = 0; i < Node_Count; i++){
		INode *node = ip->GetSelNode(i);
		TSTR name(_T("Got_You_"));
		ip->MakeNameUnique(name);
		node->SetName(name);
	}

	ip->RedrawViews(ip->GetTime());
}

So after my little rename object. Should I have put the objects into an array?

So next would be convert all selected to editpoly and attach them… Here is where I’m a bit lost.

I did find a “obj->CanConvertToType(Class_ID(???, 0)))”

I’m guessing I need to filter though my array to see if I can convert and append a new array with good objects.


void MyClass::FN_PolyAttachNode(){
	ip = GetCOREInterface();

	int Node_Count;
	Node_Count = ip->GetSelNodeCount();
	
	/// TODO - get nodes into array
	/// TODO - check if edit poly obj
	/// TODO - convert to edit poly
	
	for (int i = 0; i < Node_Count; i++){ 
		INode *node = ip->GetSelNode(i);
	   /// TOTD - attach node[1] to node[i]  
	}

	ip->RedrawViews(ip->GetTime());
}

I’m I going in the right direction or doing something really backwards?

12 Replies

getting a bit closer. I’m going though the objects and seeing what can be converted.


  void Poly_Attach::FN_PolyAttachNode(){
  	ip = GetCOREInterface();
  
  	int Node_Count;
  	Node_Count = ip->GetSelNodeCount();
  	
  	for (int i = 0; i < Node_Count; i++){ 
  		INode *node = ip->GetSelNode(i);
  		Object *obj = node->EvalWorldState(0).obj;
  		switch (obj->SuperClassID()){
  			case GEOMOBJECT_CLASS_ID:
  				if (obj->CanConvertToType(defObjectClassID)){
  					MessageBox(NULL, _T("I can be coverted!"), _T("Total Nodes"), MB_OK);
  				}else{
  					MessageBox(NULL, _T("I can't be"), _T("Total Nodes"), MB_OK);
  				}
  				break;
  			default:
  				MessageBox(NULL, _T("I'm Default"), _T("Total Nodes"), MB_OK);
  		}
  	}
  	ip->RedrawViews(ip->GetTime());
  }
  

not sure how to convert to poly object yet?

Now really looking at this code. I can see i,m going to be stuck on my array of objects problem again.

I need to add get all the “INode *node = ip->GetSelNode(i);” and add them to an array. After that filter though the array and append a new array with good items.

Any thought on how to do this?

a snippet from editpolyops.cpp localattachData::AppendNode function

// Get the attach object
	bool del = false;
	PolyObject *obj = NULL;
	ObjectState os = attachNode->GetObjectRef()->Eval(t);
	if (os.obj->IsSubClassOf(polyObjectClassID)) obj = (PolyObject *) os.obj;
	else {
		if (!os.obj->CanConvertToType(polyObjectClassID)) return;
		obj = (PolyObject*)os.obj->ConvertToType(t,polyObjectClassID);
		if (obj!=os.obj) del = true;
	}
	// Get the mesh:
	MNMesh *attachMesh = new MNMesh(obj->GetMesh());
	if (del) delete obj;

I might be asking the wrong questions.

Not too worked about the attach as much as turning a box to and edit poly so I can use Polyop in the SDK.

PolyObject* GetPolyObjectFromNode(INode *pNode, TimeValue t, int &deleteIt)
{
	deleteIt = FALSE;
	Object *pObj = pNode->EvalWorldState(t).obj;
	if (pObj->CanConvertToType(Class_ID(POLYOBJ_CLASS_ID, 0))) { 
		PolyObject *pTri = (PolyObject *)pObj->ConvertToType(t, Class_ID(POLYOBJ_CLASS_ID,0));
		if (pObj != pTri) deleteIt = TRUE;
		return pTri;
	} else {
		return NULL;
	}
}

TriObject* GetTriObjectFromNode(INode *Node, TimeValue t, int &deleteIt) 
{
	deleteIt = FALSE;
	Object *pObj = Node->EvalWorldState(t).obj;
	if (pObj && pObj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID,0))) { 
		TriObject *pTri = (TriObject *)pObj->ConvertToType(t, Class_ID(TRIOBJ_CLASS_ID,0));
		if (pObj != pTri) deleteIt = TRUE;
		return pTri;
	} else {
		return NULL;
	}

}

usage for meshes (editable mesh if you like)

BOOL deleteIt =  FALSE;


TriObject *triObject = GetTriObjectFromNode(ip->GetSelNode(0), t, deleteIt); 

 // Use the TriObject if  available

 if (!triObject) return;

  Mesh& mesh = triObject->GetMesh();

// perform processing

   // Delete it when done if we own  it

 if (deleteIt)  triObject->DeleteMe();


or for polyObject (editable_poly) like so

BOOL deleteIt =  FALSE;


PolyObject*polyObject = GetPolyObjectFromNode(ip->GetSelNode(0),t, deleteIt); 

 // Use the polyObject if  available

 if (!polyObject ) return;

  MNMesh& mesh = polyObject ->GetMesh();

// perform processing

   // Delete it when done if we own  it

 if (deleteIt) polyObject ->DeleteMe();


Nice One!! Thats great thanks.

I think I’m getting my head around this.
<node> looks to be my wrapper or pointer to the object
<Object> looks be have info about the class or supper class
<TriObject> well not to sure but gets me to mesh (can be triObjectClassID or polyObjectClassID )
<mesh> is where I can work on the mesh

It will take some time to get it sorted. But your help is always great.

Thanks again

maybe this will help…

Nodes

Every scene object in a 3ds Max scene is represented in memory (that is, in the data structure of the scene) as a node. The node acts as a container for a rendered object’s geometry, transform controllers, assigned materials, assigned modifiers, etc. Nodes also provide the building blocks for hierarchies, in which parent/child relationships are created by linking objects node to node. Two tools that display nodes are Track View and Schematic View.

Multiple nodes may share the geometry of a single scene object. Each node in the scene is unique and can be identified as such by the commands and tools 3ds Max or plug-ins implement.

A node is represented by the class INode. The methods of INode provide the functions such as evaluating the geometry pipeline for the node, getting and setting the node name, working with parent/child hierarchies, accessing display attributes of the node, providing access to controllers, etc.

Objects

In C++ terminology an object is an instance of a class or struct type. In 3ds Max an object refers to a scene entity. Scene objects are represented in 3ds Max by instances of classes that derived from Object: CameraObject, GeomOjbect, HelperObject, IDerivedObject, IXRefObject, LightObject, and WSMObject. Scene objects are associated with an INode object that acts as a container for an object’s geometry, its transform controllers, assigned materials and modifiers, and more. For more information see the section on Nodes.

Virtually all 3ds Max objects are parametric objects: they are defined by user controlled parameters.

Meshes

A mesh is a collection of primitive shapes (e.g. edges and vertexes) that represent the geometry of a scene object. There are two principal kinds of meshes: triangular meshes (Mesh) and polygon meshes (MNMesh). The triangular mesh is represented in the pipeline by a TriObject object and a polygon mesh is represented in the pipeline by a PolyObject.

The triangle mesh is a vertex based representation, and the polygon mesh is a winged edge topological model.

Patch meshes (PatchMesh) are covered in the section on Patches and Faces.

also look through david laniers book

Thanks for you help. Great description and book link.

After playing around with the code and putting break points to see if I’m making it through all the functions. It really does nothing but gain the mesh level of the node.

Box does not covert to edit mesh or poly. Looks like it would need a channel deep copy.

It is really strange that you can’t do simple tasks with the SDK.

like…
macros.run “Modifier Stack” “Convert_to_Poly”

or
ConvertToPoly $

I have also looked into…


INode *node = ip->GetSelNode(i);
Object *obj = node->EvalWorldState(t).obj;
Object *New_obj = obj->CollapseObject();

no luck there.

Page 1 / 2