public override void Animation(RenderControl render, float time) { if (mLength > 50) { return; } mTheta += 0.02f; var rotation = Matrix4.makeRotationAxis(new Vector3(1, 0, 0), mTheta); mLength += 0.1f; var trf = Matrix4.makeTranslation(-mLength, 0, 0) * rotation; mWorkpiece.SetTransform(trf); mWorkpiece.RequstUpdate(); Vector3 tailPostion = new Vector3(0, 0, 5); tailPostion.applyMatrix4(trf); mMotionTrail.SetPosition(mCount++, tailPostion); mMotionTrail.RequstUpdate(); render.RequestDraw(EnumUpdateFlags.Scene); }
public override void Animation(RenderControl render, float time) { if (nCurrentHeight > 50) { //CylinderNode.SetMaterial(GrayMaterial); //TubeNode.SetMaterial(RedMaterial); nDirection = -1; } else if (nCurrentHeight < 0) { nDirection = 1; //CylinderNode.SetMaterial(RedMaterial); //TubeNode.SetMaterial(GrayMaterial); } { var matrixR = Matrix4.makeRotationAxis(new Vector3(0, 0, 1), time); var matrixT = Matrix4.makeTranslation(-50, 0, 0); ConeNode1.SetTransform(matrixR * matrixT); ConeNode1.RequstUpdate(); nScale *= 1.01f; if (nScale > 5) { nScale = 1; } ConeNode2.SetTransform(matrixT * matrixR * Matrix4.makeScale(1, nScale, nScale)); ConeNode2.RequstUpdate(); } nCurrentHeight += nStep * nDirection; CylinderNode.SetTransform(Matrix4.makeTranslation(0, 0, nCurrentHeight)); CylinderNode.RequstUpdate(); render.GetContext().UpdateWorld(); render.RequestDraw(); }