PDA

View Full Version : Xpresso and Spline Text


cbowyer
11-23-2005, 09:41 PM
I built a bar chart the other day and placed a texture with the Spline effect on the top of each bar and then used Xpresso to update the Spline Text with the Y scale value. It all worked pretty well the text updated as the bar grew taller but I had a deadline at the end of the day and didn't have time to really explore xPresso to see what else was possible... Specifically I wanted to find out two things.

1) How to round the decimal value to 1 place. It seemed to have 3 places or none.

2) Concactinate a string onto the end of the value such as "km/h" or "bats" or whatever.

I revisited the file for a few minutes today but didn't get any answers. Does anyone know if either of these is possible? with xPresso?

warmest regards

Cameron Bowyer

base80
11-24-2005, 12:06 AM
1. if you put the thing on integer it will give whole values instead of a value with a comma.
one decimal is another story altogether.

2. you can use maths add to add the km/h. But you must set the math node to string mode in order to work. you can add as many things as you like

cbowyer
11-24-2005, 01:14 AM
Thanks base80!

1. if you put the thing on integer it will give whole values instead of a value with a comma. one decimal is another story altogether.

Maybe I can turn it into a string and hack off the last two digits somehow. It doesn't really have to round, it just needs to be smaller than 3 decimal places.

2. you can use maths add to add the km/h. But you must set the math node to string mode in order to work. you can add as many things as you like

I'll play around with the add function tomorrow. Thanks again!

warmest regards
Cameron Bowyer

Darter
11-24-2005, 11:22 AM
Here’s an expression for rounding decimal values.

The expression works for values between -32,768 and 32,767, which is the range for the C++ short int variable type.

User Data are on the XPresso tag, where the number of decimal places can be set. The Output value is for demonstration purposes and can be removed, along with the node connected to the XGroup output.

The expression seems to work reliably but if there are any problems, feedback would be appreciated.

base80
11-24-2005, 12:26 PM
very cool darter, but could you make the rounding as an input port so i can save the node in the x-pool?

and the limitation of -32k to +32k is not very useful for many things, but ill work around it.

Darter
11-24-2005, 12:46 PM
Sure, here's a modified version of the file.

cbowyer
11-24-2005, 05:26 PM
Thanks Darter!

Darter
11-25-2005, 01:08 PM
I've reworked the expression so that it works for numbers outside of the -32,768 to 32,767 range.

http://forums.cgsociety.org/showthread.php?t=296922

CGTalk Moderation
11-25-2005, 01:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.