SOLVED Spline Points with ModifyObject

Hello,

I am trying to create a deformer plugin that will work on splines by modifying the positions of the points.

Using the code below I am getting the points from a spline and offsetting its position along the Z axis as a simple test.


Bool DeformPlugin::ModifyObject(BaseObject* mod, BaseDocument* doc, BaseObject* op, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread)
{
	// Check the input parameters validity.
	if (!mod || !op || !doc)
		return false;

	// Retrieve BaseContainer instance pointer and check for validity
	BaseContainer* bc = mod->GetDataInstance();
	if (!bc)
		return false;

	// Verify the modifier inherits from PointObject and cast the pointer to the corresponding PointObject.
	if (!mod->IsInstanceOf(Opoint))
		return false;

	// Verify the modified object inherits from PointObject and cast the pointer to the corresponding PointObject.
	if (!op->IsInstanceOf(Opoint))
		return true;

	SplineObject *opSplineObj = static_cast<SplineObject*>(op);

	iferr(MovePoints(opSplineObj, modPointObj))
	{
		return false;
	}

	return true;
}

maxon::Result<void> DeformPlugin::MovePoints(SplineObject* opSplineObj, PointObject* modPointObj)
{
	if (!opSplineObj)
		return maxon::OK;

	const Vector* opPointsR = opSplineObj->GetPointR();
	const Int32 opPointsCnt = opSplineObj->GetPointCount();
	Vector* opPointsW = opSplineObj->GetPointW();

	if (!opPointsCnt)
		return maxon::OK;

	for (Int32 opPointIdx = 0; opPointIdx < opPointsCnt; opPointIdx++)
	{
		opPointsW[opPointIdx] = opPointsR[opPointIdx];
		opPointsW[opPointIdx].z = opPointsR[opPointIdx].z + 20;
	}

	return maxon::OK;
}

The code is working to properly move the points, the problem is that I am getting the line points of the spline that I am deforming when I am trying to get the spline points.

This is the selection of points I am getting.
Deform Post Line.png

This is the selection of points I want to get.
Deform Post Spline.png

I tried using the base SDK examples and they are also using the line points instead of the spline points.

Is there a way to get and use the spline points or do deformers only utilize the line points?

Any help would be greatly appreciated.

John Thomas

Hi @JohnThomas, thanks for reaching out us.

With regard to your question, I confirm that what you see is correct since the deformer provided data is the tessellated representation of the original spline.

Best, Riccardo

@r_gigante Thanks for the response, that's what I thought the case would be.

John Thomas