Jump to content

Primitive Hook shop_materialpath override


Recommended Posts

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...