I must be missing something REALLY obvious here...
This is in an expression Im setting up to control valves on a combustion engine.
The problem is that the bits work seperately, but when i put it together it doesn't work:
||
|| allValves.valveCycle=abs(trunc(fmod(pistonCamsAll.rotateZ,720)/180));
|| nurbsSphere1.translateY= allValves.valveCycle*5;
||
|| if ( allValves.valveCycle = 0 )
|| valveSet1.factorExValve1=(1-cos(pistonCamsAll.rotateZ/90*3.1415927))/2;
|| else
|| valveSet1.factorExValve1=0;
||
|| valveExMechB|valvePlunger.translateY=valveSet1.factorExValve1*allValves.valveDepth;
||
allValves.valveCycle=abs(trunc(fmod(pistonCamsAll.rotateZ,720)/180));
This is an extra attribute(float) on a locator, describing the rotation (720) of the drive shaft.
As pistonCamsAll.rotateZ goes from 0 to 720 (and beyond), allValves.valveCycle steps in integers 0, 1, 2, 3, 0, 1, 2... steppiung up every 180 degrees
nurbsSphere1.translateY= allValves.valveCycle*5;
I put this test sphere just to test the above statement, and it works, the sphere steps up, and up... then back to zero - so allValves.valveCycle is good...
valveSet1.factorExValve1=(1-cos(pistonCamsAll.rotateZ/90*3.1415927))/2;
This works ok too. It makes a sine motion from 0, to 1, to 0 within 180degree turn or the drive shaft (pistonCamsAll) ie one cycle in sync with each integer step that we defined above (allValves.valveCycle). I tested this outside of the IF statement, and it works fine, synced with my test sphere...
if ( allValves.valveCycle = 0 )
valveSet1.factorExValve1=(1-cos(pistonCamsAll.rotateZ/90*3.1415927))/2;
else
valveSet1.factorExValve1=0;
This is where it all goes pear shaped
I want to choose the right part of the cycle 0-1-2-3-0 to open the valve (in this case when valveCycle=0) to set the valve opening factor to it's synced sine close/open/close motion, and on other cycle values, it stays at zero.
The trouble is, it just stays at zero! Its like the IF is not being evaluated... and i just can't suss it out.
So I changed the line to "if ( allValves.valveCycle = 1 )", now it seems true for every cycle, with the valve constantly opening and closeing. In fact ALL non zero values yeild this result. Its as if I put "if (0)" then tried "if (1)"
valveExMechB|valvePlunger.translateY=valveSet1.factorExValve1*allValves.valveDepth;
The last line just translates the factor into actual Y movement (factor will also control spring scaling + fluid flows later). It works ok too.
I had originally made valveCycle an integer, but it was the same problem.
Well - thanks if you are still reading. I hope I could explain my problem ok. I cant think what else to do. Perhaps theres something i need to consider within an expression, perhaps a mystical flag someplace needs toggling, perhaps I should quit and become a farmer.
"It's so obvious, it's bound to be a trap" - Cato