Creating plane with 3dsMax SDK


#1

I want to create simple Plane (From standart primitives) object.
The problem is that I can’t find any info about Plane primitive object in documentation/sdk headers.
So, is there any way to create this type of object?


#2

this should do it, you can change it to return the object and not the node

INode* createPlane(float width, float length, int wsegs, int lsegs)
 {
 	SimpleObject2* planeObj = (SimpleObject2*)GetCOREInterface()->CreateInstance(GEOMOBJECT_CLASS_ID,PLANE_CLASS_ID);
 	if(planeObj)
 	{
 		INode* planeNode = GetCOREInterface()->CreateObjectNode(planeObj);
 		if(!planeNode)
 		{	
 			planeObj->DeleteThis();
 			return NULL;
 		}
 		IParamBlock2* pb = (IParamBlock2*)planeObj->GetReference(0);
 		if(pb)
 		{
 			pb->SetValue(1,0,width);
 			pb->SetValue(0,0,length);
 			pb->SetValue(2,0,wsegs);
 			pb->SetValue(3,0,lsegs);
 		}
 		return planeNode;
 	}
 	return NULL;
 }

Sdk attach mesh
#3

Thanks much! :rolleyes:
For me, as a beginner with Max SDK is a bit strange why some classes has its own interface and some hasn’t (like Box and Sphere have SetParams() method).


#4

the problem is the sdk shouldn’t have to provide an interface for every type of object it just happens that a few object that are used else where in the sdk so it probably made sense at the time to make access a bit “easier” so to speak. The example I showed didn’t have to use simpleobject2 as the class i could have just as easily used object. The problem then is knowing the structure of the parameter block.


#5

Well, could you please show an example for text object (TEXT_CLASS_ID) ?
I thought I could use same way for it, but this thing looks differently.


#6

edited because it’s rubbish :slight_smile:

this should do it


   INode* CreateText(char* text, char* font, float size)	
   {
   	SimpleSpline* splineObj = (SimpleSpline*)GetCOREInterface()->CreateInstance(SHAPE_CLASS_ID,Class_ID(TEXT_CLASS_ID,0));
   	if(splineObj)
   	{
   		INode* textNode = GetCOREInterface()->CreateObjectNode(splineObj);
   		if(!textNode)
   		{	
   			splineObj->DeleteThis();
   			return NULL;
   		}
   		
   		ITextObject* textObj= GetTextObjectInterface(splineObj );
   		if(textObj)
   		{
   			textObj->ChangeFont(font,0);
   			textObj->ChangeText(text);
			splineObj->GetParamBlock()->SetValue(TEXT_SIZE,0,size); // documentation is wrong this is the right way
   		}
   		splineObj->UpdateShape(0);
   		return textNode;
   	}
   	return NULL;
   }

see ITextObject Class Reference in the sdk documentation


#7

Anyone know if it’s possible to set the “Real-World Map Size” option when creating the plane ?


#8

use RealWorldMapUtils.h methods

(
	g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
	obj = g.animatable.getAnimByHandle (dotNetObject "System.UIntPtr" (getHandleByAnim (createInstance plane)))

	/* set RealWorldMapSize on */
	g.SetUsePhysicalScaleUVs obj (RealWorldMapSize = true)

	inode = g.coreinterface7.CreateObjectNode obj
	g.coreinterface7.SelectNode inode (clear_prev_selection = true)

	format "RealWorldMapSize: %\n" $.RealWorldMapSize
)

#9

Thanks Serejah, But i can’t seem to find a way to do it in c++


#10
#include "RealWorldMapUtils.h"

def_visible_primitive(MakeRWPlane, "MakeRWPlane");
Value* MakeRWPlane_cf(Value **arg_list, int count)
{		
	Object* planeObj = (Object*)GetCOREInterface()->CreateInstance(GEOMOBJECT_CLASS_ID,PLANE_CLASS_ID);
	
	if(planeObj)
	{
		INode* planeNode = GetCOREInterface()->CreateObjectNode(planeObj);
		if(!planeNode)
		{	
			planeObj->DeleteThis();
			return &undefined;
		}
		
		SetUsePhysicalScaleUVs( planeObj, true );

		return MAXNode::intern(planeNode);
	}

	return &undefined;

}

#11

Another thing about a plane that gets me is the widthseg + 1 + lensegs + 1 dead UV coords (so the first default uv coord index isn’t 1)! looking at the code theres some semi implemeted z depth thing going on. theres also a very slight accumulation error where verts get very slightly out of position the further right and up they are.


#12

Excellent Thanks.

SetUsePhysicalScaleUVs( planeObj, true );

It was easier then I thought :smiley: