Beispiel #1
0
        public override void Run(RenderControl renderer)
        {
            var shape       = ShapeBuilder.MakeSphere(new GPnt(), 1);
            var bufferShape = new BufferShape(shape, null, null, 0.1);

            bufferShape.Build();

            float distance  = 3.0f;
            int   halfCount = 5;

            var scene = renderer.GetScene();

            for (int ii = -halfCount; ii < halfCount; ++ii)
            {
                for (int jj = -halfCount; jj < halfCount; ++jj)
                {
                    for (int kk = -halfCount; kk < halfCount; ++kk)
                    {
                        var node = new BrepSceneNode(bufferShape);
                        node.SetTransform(Matrix4.makeTranslation(ii * distance, jj * distance, kk * distance));
                        scene.AddNode(node);
                    }
                }
            }
            renderer.ZoomAll();

            Matrix4 m1 = new Matrix4(1);
            Matrix4 m2 = new Matrix4(1);
            Matrix4 x  = m1 * m2;
        }
        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();
        }