shadmar Posted July 18, 2014 Posted July 18, 2014 --Scale of box has to be less or equal to 1, you can scale up after function Script:sphereit(x,y,z) sx = x * math.sqrt(1.0 - (y*y*0.5) - (z*z*0.5) + (y*y*z*z/3.0)); sy = y * math.sqrt(1.0 - (z*z*0.5) - (x*x*0.5) + (z*z*x*x/3.0)); sz = z * math.sqrt(1.0 - (x*x*0.5) - (y*y*0.5) + (x*x*y*y/3.0)); return sx,sy,sz end Example usage on a 1x1x1 box mesh (has to be abit tesselated to have enough vertices to transform) function Script:Start() surface=self.entity:GetSurface(0) for v=0,surface:CountVertices()-1 do surface:SetVertexColor(v,v/1000,1000-v,v/1000,1) vpos = surface:GetVertexPosition(v) x,y,z = self:sphereit(vpos.x,vpos.y,vpos.z) surface:SetVertexPosition(v,Vec3(x,y,z)) end surface:UpdateNormals(true,0.01,180) end Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.