Jump to content
adam_perin

Primitive Hook shop_materialpath override

Recommended Posts

Posted (edited)

Looking at the sample GUI_PolygonNormalShade, I'm trying to replace the material in the viewport when a visualizer is set. I have been trying to do this by copying the approach used in GUI_PolygonNormalShade but instead of writing new "Cd" attributes I want to write a new "shop_materialpath" attribute to the detail attributes. Its look like everything is correct (no crashes or errors) but I'm still not getting the new material to show in the viewport. Any ideas would be super helpful. Here is the code from the filterPrimitive function.

processed = GR_PROCESSED;

	char arr[] = "/mat/test";


	OP_Node* matNode = OPgetDirector()->findNode(arr);
	if (!matNode)
	{
		OP_Network *parent = (OP_Network *)OPgetDirector()->findNode("/mat");
		parent->createNode("tooncolorshader", "test");
		matNode = OPgetDirector()->findNode(arr);

	}

	string path(arr);

	auto indexedString = new GT_DAIndexedString(1);
	indexedString->setString(0, 0, path.c_str());
	GT_AttributeListHandle dah = gt_prm->getDetailAttributes()->addAttribute("shop_materialpath", indexedString, true);
	
	auto mesh = UTverify_cast<const GT_PrimPolygonMesh *>(gt_prm.get());
	ph = new GT_PrimPolygonMesh(*mesh,
		mesh->getPointAttributes(),
		mesh->getVertexAttributes(),
		mesh->getUniformAttributes(),
		dah);


	// return a new polygon mesh with modified shop_materialpath attribute.
	return ph;

 

Edited by adam_perin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×