Custom node functionality for Fabric Engine2.0

Source: Internet
Author: User

Fabric engine is a versatile engine that is handy for writing node-write functions for software such as Maya. In particular, the canvas node editing panel, provides a large number of existing functions for users to call, of course, these nodes can be edited and modified by the user, in addition to provide a custom node function, very powerful and flexible.

The initial fabric is easily confused by the various data types of the editor. So I took the write Canvas nodes in Maya-fabric engine this video to clarify the idea.

operating system : WINDOS7

software platform : Maya

using the tool : Fabric Engine2.0

Case Content : Set up three locator points and place the third locator in the middle of the top two locator points. The location of a single locator can be stored with VEC3, two locator have to be stored with vec3[], and the final output to the third locator location data should be VEC3, so vec3[] to VEC3, there is a calculation process in the middle. The case is a new node to handle this intermediate computational process.

1. Go to Maya, open the node editor, press TAB to create three locator nodes, select the Locatorshape node, click the Remove selected nodes from Graph button above the node editor, Remove it from the node editor and leave three locator nodes.

2. In the node editor, bring up the Dfgmayanode node and click the Open Canvas button in the Properties panel of the node. You can open the Canvas node edit panel.

3. Right-click the creat port function on the right side of the canvas and create a new output point named result, type VEC3, expose. Right-click creat port on the left side of the canvas and create a new input point named targets, type vec3[] expose.

4. How to use the existing node in the canvas is not discussed here. The main point is how to create a new node and use that node to convert the vec3[] data type to the VEC3 data type. In the KL language of Fabic, the VEC3 type refers to a three-dimensional data type, such as VEC3 (0,0,0), which can be used to store RGB information, or XYZ information, as needed. Vec3[] refers to a list of VEC3 data, which is made up of one or more VEC3 data types. The same is true for other data types in fabric, such as: XFO[],XFO, which is used to represent spatial locations, such as: Xfo (ori, TR, SC).

5. Based on the above analysis, the conversion from vec3[] to VEC3 is easy. We all know that the simplest way to manipulate a list is the FOR Loop statement, which we'll implement here.

6. In the Canvas node Editor panel, right click on new empty function, create a new empty node, name Interpolatepositionarray, then select the node and right click on edit to enter editing mode. Build an in port, named targets, with data type vec3[], and build an out port named result with a data type of VEC3.

In this edit mode, modify the code block to:

dfgentry {  result = VEC3 (0,0,0);  for (Size i = 0,i < Targets.size (), i++)    result + = Target[i]/Float32 (Targets.size ());}

The above code block evaluates the average of the vec3[] data type in targets with the for statement and exports it to the VEC3 data type. The Targets.size () method is used to calculate the number of elements in the list.

7. Click Save to save the code block, click Go to go back to the Canvas node editor interface, Connect the targets and result interfaces in the left and right sides of the expose bar to the Interpolatepositionarray node targets[] with the result interface. This completes the editing work of the Dfgmayanode node. Close the canvas back to the Maya Node Editor panel. Connect the two locator to the in point of the Dfgmayanode node, and the other locator to the out point of the Dfgmayanode, and the work is done.

8. No matter how the first two locator move, the third locator will be at the midpoint of the two locator.

Custom node functionality for Fabric Engine2.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.