Notifications
Clear all

[Closed] Math for a bend

And here is one with Axis control:

plugin simpleMod MyBend
 name:"MyBend"
 classID:#(0x33635bb3, 0x5db238c1)
 version:1
 ( 
 parameters main rollout:params
 (
 amount type:#float ui:spn_amount default:0
 direction type:#float ui:spn_direction default:0	
 axis type:#integer ui:rad_axis default:3
 )
 
 rollout params "MyBend Parameters"
 (
 spinner spn_amount "Amount: " range:[-100000,100000,0] scale:1
 spinner spn_direction "Direction: " range:[-100000,100000,0] scale:1
 radiobuttons rad_axis "Axis:" labels:#("X","Y","Z")
 )
 
 on map i p do
 (
 if amount != 0 then
 (
 	case axis of
 	(
 		1: (
 				theDirMatrix = rotateXMatrix -direction
 				theRadius = 180/amount*extent.x/Pi
 				theRadiusOffset = [0,0,-theRadius] * theDirMatrix 				
 				TM = rotateYMatrix (amount*p.x/extent.x) * theDirMatrix
 				TM.row4 = theRadiusOffset
 				(([0,p.y,p.z]-theRadiusOffset)*inverse theDirMatrix) * TM 			
 			)
 		2: (
 				theDirMatrix = rotateYMatrix -direction
 				theRadius = 180/amount*extent.y/Pi
 				theRadiusOffset = [theRadius,0,0] * theDirMatrix 				
 				TM = rotateZMatrix (-amount*p.y/extent.y) * theDirMatrix
 				TM.row4 = theRadiusOffset
 				(([p.x,0,p.z]-theRadiusOffset)*inverse theDirMatrix) * TM 
 			)
 		default: (
 				theDirMatrix = rotateZMatrix -direction
 				theRadius = 180/amount*extent.z/Pi
 				theRadiusOffset = [theRadius,0,0] * theDirMatrix 				
 				TM = rotateYMatrix (amount*p.z/extent.z) * theDirMatrix
 				TM.row4 = theRadiusOffset
 				(([p.x,p.y,0]-theRadiusOffset)*inverse theDirMatrix) * TM 
 			)	
 	)	
 )
 else p
 )
 
 )

Same principle, just the axes and planes in which the calculations are performed are switched based on the radio buttons. This could be optimized to express in shorter form with less redundant code, but I might do that later.

 PEN

That is great Bobo, thanks a million and thanks to every one else as well. I need to sit down and play with this now so that I get a full handle on what it is doing. I think I get the idea of how you are calculating it but it hasn’t fully sunk in. Looks like you are having fun with it as well Bobo. I now have a sort of do it all modifier that does twist, taper, skew, wave, offsets, scaling and a other fun stuff. Looks like scripted modifiers that transform verts are now stable, they used to crash all the time. Speed is a huge problem how ever especialy when the modifier is active in the modifier stack. Once it is closed it isn’t to bad but not great. I really need to learn C++.

 PEN

It always works this way, I mention that it is stable and what happens next:S I start getting garbage collections errors. If I had p=[0,0,0] in the map handler it would throw them if I do p.x=0;p.y=0;p.z=0 it is fine. Very odd.

Page 2 / 2