Proportional Editing of a Sphere (How to get the effect of the Proportional Edit Tool in Blender on

Hey,



what I’m trying to achieve is to manipulate the vertices of a sphere in order get a bulge with a proportional falloff. Like what the PET does in Blender: http://wiki.blender.org/index.php/Doc:2.4/Manual/3D_interaction/Transform_Control/Proportional_Edit .



I started by creating a sphere object and fetching the vertices through the VertexBuffer. How would I now know which indices of the vertex array are in a certain radius? Also how would I test for the distance between a vertex and the middle of the area that should be edited? (To get a smooth falloff)

Kinda hard for me, so I’m not able to solve this without the communities help :slight_smile: Thanks!

All method names etc are from memory so may need a bit of tweaking:





If you have point c



The points in the mesh (lets say a triangle) are p1, p2, p3.



All in Vector3f



Then the distance to each is simply p1.subtract©.length() (can use subtractLocal for speed if you don’t need to keep p1)



Length involves a square root calculation though and if you just want to know if you are inside a radius you can square your range once and then use lengthSquared on each point.



[java]rangeSquared = FastMath.square(range)



if (p1.subtract©.lengthSquared() < rangeSquared) {

// in range

}

[/java]



If you want to get a smooth falloff then use the range found above as a divisor on the amount you are moving something. Whether you can keep the squared or need to do the square root will depend on the type of falloff you are looking for.



Hope that helps…



Zarch

1 Like