There is not Spline3D Type in "enum ParamType"


#1

I want to create my own function using .gup plugin,But I ran into some trouble.
There is not Spline3D Type in paramtype.h file.so I tried to replace it with TYPE CLASS, but it still failed.
as follow:

{
AppendFunction(
			FUNC_ID(CurveLength), FUNC_STR(CurveLength), 0, TYPE_FLOAT, 0,5
			, _M("spline"), 0, TYPE_CLASS
			, _M("knot"), 0, TYPE_INT
			, _M("v1"), 0, TYPE_FLOAT
			, _M("v2"), 0, TYPE_FLOAT
			, _M("size"), 0, TYPE_FLOAT
			, p_end);
};
BEGIN_FUNCTION_MAP
VFN_5(FUNC_ID(CurveLength), TYPE_FLOAT, CurveLength, TYPE_CLASS, TYPE_INT, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT)
END_FUNCTION_MAP

static float CurveLength(Spline3D *spline, int knot, float v1, float v2, float size = 0.0f);

I hope I can get help!


#2

probably because there’s no Spline3D type in MXS. Work out what you would expect to pass to this function in maxscript and go from there.


#3

TYPE_CLASS requires a ClassDesc not an Object of some type


#4

Although there is TYPE_BEZIERSHAPE in paramtype.h file,but it still failed.

VFN_5(FUNC_ID(OutlineSpline), OutlineSpline, TYPE_BEZIERSHAPE , TYPE_INT, TYPE_FLOAT, TYPE_INT, TYPE_BOOL)


static void OutlineSpline(BezierShape *shape, int poly, float size, int centered, BOOL newType);


#5

again what would you expect to pass to the function in MaxScript ?


#6

Actually, I want to rewrite ‘OutlineSpline’ ,Because you can’t use it directly, you have to write a function with nodes as arguments.


#7

What I was trying to lead you down is, there are no types for dealing with Spline Shapes in Maxscript other than the Node It’s self… So the type you want is INode. You have to then test for and derive the Shape from that.

something like…

Object* obj = node->GetObjectRef();
	if (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
		obj = ((IDerivedObject*)obj)->FindBaseObject();
	if (obj->ClassID() != splineShapeClassID && obj->ClassID() != Class_ID(SPLINE3D_CLASS_ID,0))
		throw RuntimeError (GetString(IDS_SHAPE_OPERATION_ON_NONSPLINESHAPE), obj->GetObjectName());
	SplineShape* s = (SplineShape*)obj;

from mxsagni project


#8

Here’s my simple test,but it doesn’t work:

Object* obj = node->GetObjectRef();
SplineShape* s = (SplineShape*)obj;
BezierShape bs = s->shape;
OutlineSpline(&bs, poly, size, centered, newType);

the following is code in Maxscript:

MXSExposure.OutlineSpline $ 0 20 0 true


#9

is the node valid in the debugger ? … this works for me

    void SetNode(INode* node)
	{
		if (node)
		{
			TCHAR* n = node->GetName();
			Object* obj = node->GetObjectRef();		
		}
	}

the node is valid and so is the object.


#10

I didn’t get any errors, but spline didn’t seem to change.Do i need to upate the Splineshape?
but there is the following in my codes:

spline->ComputeBezPoints();
shape->InvalidateGeomCache();

So I was very confused


#11

The “outlinespline” code is too long,so I’m going to test it with a different function:

static int DeleteSelSegs(BezierShape *shape, int poly) {
Spline3D *spline = shape->splines[poly];
int segs = spline->Segments();
int verts = spline->Verts();
for (int s = segs - 1; s >= 0; --s) {
BitArray& vsel = shape->vertSel[poly];
BitArray& ssel = shape->segSel[poly];
if (spline->Closed() && ssel[s]) {
if (s == (spline->KnotCount() - 1)) {
spline->SetOpen();
ssel.SetSize(spline->Segments(), 1);
}
}
}
spline->ComputeBezPoints();
shape->InvalidateGeomCache();
return false;
}

this is my exported function:

void IMXSExposure::OutlineSpline(INode node, int poly)
{
if (node)
{
Object obj = node->GetObjectRef();
SplineShape
s = (SplineShape
)obj;
BezierShape olShape = s->shape;
DeleteSelSegs(&olShape, poly);
}

MXSExposure.OutlineSpline $ 0

The purpose of my test was to make it react in the scene, to show that I had succeeded


#12

There’s still no error. The Splineshap hasn’t changed. I don’t know what functions are missing


#13

what happens if you add

updateShape $

to your script ?


#14

add updateShape $
Splineshap remains unchanged.
:sweat:


#15

I seriously doubt that this is correct:

&olShape