Continuing from last thread, here's animated text for the pie chart value / percentage.
Watch the clip below.
The basic idea is to fetch the value from revolve node, and pass it to the text node. Similar with the bar chart, excpt the adjustment for the max value in pie chart.
Create curve profile for the pie chart.
Revolve that curve... with history option turn on. And also set the output to polygon, change the polygon type: quad, format: general. In general option, U & V type: per span # of isoparms, and U & V number: 3.
Now with all those history node hook in with the object, try to change the end sweep from revolve node. The pie is short of reducing it size accordingly. Now this is the one the we'll be animating, and connect this value to the text node... well sort of like that...
Select the pie object, and add attribute called "percentage", or so, as long as it make sense to you. This new attribute will be driving the end sweep value, but after this value went thru the setRange node. So, let's create setRange node.
Open hypershade, put all those items in it, the pie object, revolve node and setRange node.
Connect the "percentage" attribute into the setRange1.valueX. In my case, my pie object name is polyPie and my setRange node name is setRange1. So the connection is:
polyPie.percentage --> setRange1.valueX. You can either connect this using connection editor or by using simple mel script.
Here's using mel script:
connectAttr -f polyPie.percentage setRange1.valueX;
Connect setRange.outValue.outValueX to the revolve1.endSweep. Here's using mel:
connectAttr -f setRange.outValue.outValueX revolve1.endSweep;Btw, those nodes' names are the names in my scnene, change them accordingly if you have different object names.
If we now change the percentage value, let's say to 50, the pie still not showing the correct shape of 50%, which should be half pie. That is if our pie min-max value is 0-100. But in endSweep node, the max value is 360. So that's why when we set the percentage value to 50, we don't get half pie.
This is where setRange node comes in. There are three columns in setRange node, the first column is X, second is Y, third is Z, or in other utility nodes like condition or blend node, they may called as XYZ or RGB (as R the first column, G second & B third).
Set the setRange1.oldMaxX to 100. Set setRange1.maxX to 360. Now the pie shape should looks right. This is basically "convert" the max number from 0-100 ratio into 0-360 ratio.
If we have data that have maximum number other than 100, just adjust thath oldMax value, but leave the max to 360.
For the text, create text with option to bevel. And we'll assign value from the percentage attribute into the textForBevel.text using similar expression from the bar chart.
In my case, open expression editor and type these lines:
float $n = `getAttr polyPie.percentage`;
string $val = `ceil ($n)`;
setAttr textForBevel1.text -type "string" $val;
Btw, there will be a gap when the pie chart is revolving from 0 to 360, it's easily fix by closing the gap, either using polyAppend or polyBridge tool. After closing the gap, as long as it looks right, don't worry about it too much. Maya will prompt error saying cannot perform polyPlanarPorjection thing. Just ignore it.
Watch the clip below.
Create curve profile for the pie chart.
Revolve that curve... with history option turn on. And also set the output to polygon, change the polygon type: quad, format: general. In general option, U & V type: per span # of isoparms, and U & V number: 3.
Now with all those history node hook in with the object, try to change the end sweep from revolve node. The pie is short of reducing it size accordingly. Now this is the one the we'll be animating, and connect this value to the text node... well sort of like that...
Select the pie object, and add attribute called "percentage", or so, as long as it make sense to you. This new attribute will be driving the end sweep value, but after this value went thru the setRange node. So, let's create setRange node.
Open hypershade, put all those items in it, the pie object, revolve node and setRange node.
Connect the "percentage" attribute into the setRange1.valueX. In my case, my pie object name is polyPie and my setRange node name is setRange1. So the connection is:
polyPie.percentage --> setRange1.valueX. You can either connect this using connection editor or by using simple mel script.
Here's using mel script:
connectAttr -f polyPie.percentage setRange1.valueX;
Connect setRange.outValue.outValueX to the revolve1.endSweep. Here's using mel:
connectAttr -f setRange.outValue.outValueX revolve1.endSweep;Btw, those nodes' names are the names in my scnene, change them accordingly if you have different object names.
If we now change the percentage value, let's say to 50, the pie still not showing the correct shape of 50%, which should be half pie. That is if our pie min-max value is 0-100. But in endSweep node, the max value is 360. So that's why when we set the percentage value to 50, we don't get half pie.
This is where setRange node comes in. There are three columns in setRange node, the first column is X, second is Y, third is Z, or in other utility nodes like condition or blend node, they may called as XYZ or RGB (as R the first column, G second & B third).
Set the setRange1.oldMaxX to 100. Set setRange1.maxX to 360. Now the pie shape should looks right. This is basically "convert" the max number from 0-100 ratio into 0-360 ratio.
If we have data that have maximum number other than 100, just adjust thath oldMax value, but leave the max to 360.
For the text, create text with option to bevel. And we'll assign value from the percentage attribute into the textForBevel.text using similar expression from the bar chart.
In my case, open expression editor and type these lines:
float $n = `getAttr polyPie.percentage`;
string $val = `ceil ($n)`;
setAttr textForBevel1.text -type "string" $val;
Btw, there will be a gap when the pie chart is revolving from 0 to 360, it's easily fix by closing the gap, either using polyAppend or polyBridge tool. After closing the gap, as long as it looks right, don't worry about it too much. Maya will prompt error saying cannot perform polyPlanarPorjection thing. Just ignore it.
Komentar
Posting Komentar
Monggo komennya