I have created a grid with 40 x 40 vertex3D (small but useful)
I can pick a single vertex out of that grid by simply calling a function with the position array[X][Y], And therefore neighbors too. How can I raise up开发者_开发百科 neighbor vertex Z value so they kinda look like a bubble or sphere kind of thingy?
My first tough was to use:
Neighbor_vertex.Z = sin(PI/4 * 1 - ( 1/ distance_between_Neighbor_and_Pivot) ) * desired_Max_Height
But all I got is something like a wave.... and I would like to have a bubble or Sphere like shape.
THX dudes and dudettes
Your formula doesn't look quite right. Try this:
Neighbor_vertex.Z = cos (PI / 2 * distance_between_Neighbor_and_Pivot) * desired_Max_Height;
You might want to change the Z value only if the distance is less than 1.0 as well.
Are you using the Grapher app to test your formulae? I recommend it. It ships with the Mac.
Um, guys, if you want to make a spherical shape of a buble, you need reverse (arc) function...
So, the formula shall be like Neighbor_vertex.Z = sin( arccos( distance_between_Neighbor_and_Pivot / Buble_Radius ) ) * Buble_Radius.
The image below explains the formula.
Sketch http://img175.imageshack.us/img175/6052/34440153.png
精彩评论