Materials in scripting

Materials in scripting

I would very much enjoy to have minimal access to the materials through scripting.
The main purpose would be to include the materials of the polygons in my mirror script and in a "point mirroring" script that I would like to write.

Thanks
 
I would like full access to the materials via scripting to create them, manipulate them, modify them, apply them, export them for importing in another file and so on.
 
That's already possible since Cheetah3D 6.2.1. Unluckily I forgot to update the documentation. I even forgot to mention the new API in the release notes.:redface:

Here is a list of the API changes. I've also attached a small example tool script.

Bye
Martin

Code:
Global class:
	    Functions:
		void	    clearConsole()
		
	Document class:
	    Functions:
		void	    setWindowFrame(Number originX,Number originY,Number width,Number height)
		
	Node class:
	    Functions:
		Vec4D	    Node::frame()
		void	    Node::setFrame(Vec4D frame)
		String	    Node::nodeType()
		Number	    Node::inputCount()
		Parameter   Node::inputAtIndex(Number index)
		Parameter   Node::inputWithName(String name)
		Number	    Node::outputCount()
		Parameter   Node::outputAtIndex(Number index)
		Parameter   Node::outputWithName(String name)
		void	    Node::update()

	Material class:
	    Functions:
		Number	    Material::nodeCount()
		Node	    Material::nodeAtIndex(Number index)
		Node	    Material::nodeWithID(Number id)
		Node	    Material::rootNode()
		Node	    Material::addNodeOfType(String type)
		Boolean	    Material::addConnection(Number fromID, String fromPara, Number toID, String toPara)
		Boolean	    Material::removeConnection(Number nodeID, String nodePara)
		Vec4D	    Material::reflection()
		Vec4D	    Material::transmission()
		
	Parameter class:
	    Functions:
		Boolean	    Parameter::connected()
		Number	    Parameter::connectedWithID()
		String	    Parameter::connectedWithParameter()
 

Attachments

  • Nodeaccess.js.zip
    1.3 KB · Views: 375
OK. I can make materials to my heart's content, and add nodes and connect nodes, but… how do i add the material to a polygonobject? I don't see the method for that.
 
Hi,
the following code snippet should do the job.

Code:
var tag = polyobj.addTagOfType(SHADERTAG);
tag.setParameter("material", mat);

Hereby "polyobj" is a polygon object and "mat" is the material.

Bye
Martin
 
Back
Top