[Closed] SDK Question
Hello,
I am making my first attemp at making a maxscript extension, the sdk help has been great at getting me setup with visual studio by reading the “How to write a basic maxscript Plugin”. Unfortunatly Im new to C++ so progress is slow. The SDK docs look great but I
m feeling alittle overwhelmed.
I found the thread started by Andreas “3dsmax SDK adventure” which has loads of cool info, I decided on this seperate thread as I dont want to pollute that useful resource with my noobie questions.
Anyway I decided to dive in a write a function, Its going to be something simple as a learning exercise. Basically my function will assign a float_script controller to a spline vertex. So I am thinking my function will expect 2 arguments, the spline object and a vertex index so it knows which vertex to work with.
This is what I have so far for the function code.
[color=lime]//**************************************************************************
// AssignSplineKnotSC() -
//
// Usage: assigns a float_script to a spline vertex
//**************************************************************************
[/color]Value* AssignSplineKnotSC_cf(Value** arg_list, int count)
{
check_arg_count(AssignSplineKnotSC, 2, count);
return &ok;
}
pretty much nothing! ok so I was wondering if anybody can point me to some relevant areas of the docs or maybe post some simple examples I can look at. To get me started
Thanks for reading
Dan
Ok some progress, .
The function now expects 3 arguments. The first two must be nodes and the 3rd a string.
The function looks at the supplied nodes and creates a spline between them and the string is used to name the new spline.
so in script I would call the function like this:
AssignSplineKnotSC $Point01 $Point02 “New_Spline_Name”
This is what the C++ stuff looks like.
//**************************************************************************
// AssignSplineKnotSC() - create a spline between 2 object positions and assign SC`s
// to knot points
//
//
//**************************************************************************
Value* AssignSplineKnotSC_cf(Value** arg_list, int count)
{
check_arg_count(AssignSplineKnotSC, 3, count);
Interface* ip = GetCOREInterface();
//get the node from the 1st Argument
Value* theNode1 = arg_list[0];
INode* startDummy = theNode1->to_node();
//get the node from the 2nd Argument
Value* theNode2 = arg_list[1];
INode* endDummy = theNode2->to_node();
// Creare new matrix and get positions of the dummy points
Matrix3 mat;
mat = startDummy->GetNodeTM(0.0f);
Point3 pos1 = mat.GetTrans();
mat = endDummy->GetNodeTM(0.0f);
Point3 pos2 = mat.GetTrans();
// Creation of new splineshape
SplineShape* obj = (SplineShape *)ip->CreateInstance(SHAPE_CLASS_ID, splineShapeClassID);
Spline3D* spline = NULL;
// add new spline to shape
Point3 pt(0.0f, 0.0f ,0.0f);
spline = obj->shape.NewSpline();
spline->AddKnot(SplineKnot( KTYPE_CORNER, LTYPE_LINE, pos1, pt, pt ));
spline->AddKnot(SplineKnot( KTYPE_CORNER, LTYPE_LINE, pos2, pt, pt ));
spline->ComputeBezPoints();
// update spline object
obj->shape.UpdateSels();
obj->shape.InvalidateGeomCache();
// Get name of spline from the 3rd argument
Value* name = arg_list[2];
TSTR nodeName = name->to_string();
// add spline object to scene
Matrix3 nodeTM(1);
INode* realINode = ip->CreateObjectNode(obj);
realINode->SetName(nodeName);
realINode->SetNodeTM(0, nodeTM);
return (Float::intern(pos1.x));
}
[size=2][/size]
The next phase is assign position script controllers to the knot points, I couldnt see much in the sdk docs about this. Does anybody know how to go about this?
Thanks for reading
Dan