[Solved] Trouble with moving vertices according to math function.
Hello everyone spending time for beginner's question :)
I want to create a script that converts an object to an editable poly, and then it changes third coordinate (z) of every vertex, according to specified math function.
Let's say I want to use sin(x). Then, I want to:
1. Convert object to an editable poly.
2. In loop, get z coordinate of each subsequent vertex.
3. Move it up or down so the z value changes to sin(z).
Now, imagine triangle as half of square, placed vertically.
I want to run this script so the triangle gets a "y=sin(x)"-shaped edge, instead of "y=x"-shaped one
Here is the code:
h = $.height obj = convertToPoly($) subobjectlevel = 1 for i in 1 to obj.numVerts do ( pos=polyop.getVert obj i z=pos.z z/=h z*=pi z=sin(z)+1 z/=2 z*=h z-=pos.z u=[0,0,z] polyop.MoveVert obj i u ) subobjectlevel = 0
Well, as soon as i have found Sword of Apollo's Function Sculptor (click here to see it), everything I wanted to achieve became really easy.
This script is the best solution I could imagine. Of course, it would be good if some minor tweaks were applied just to improve usage experience, but it works perfectly for me.
Everything I have to do now is to play with some math parameters for sin(x), for example:
sin(30*x-pi/2), so it suits perfectly for what I am actually doing.
Again, thanks to everybody who looked into this topic and wanted to help.