Ejemplo n.º 1
0
        /// <summary>
        /// Disposes
        /// </summary>
        public override void Dispose()
        {
            mLightNode  = null;
            mLight      = null;
            mpObjsNode  = null;
            mStaticGeom = null;
            mAnimState  = null;

            mSceneManager.ClearScene();

            mLightWibbler.Dispose();
            mLightWibbler = null;
            //ControllerManager contMgr = ControllerManager.GetSingleton();
            //contMgr.DestroyController( mLightCtlFlt );
            mLightCtlFlt = null;
            mWFCF        = null;
            mCFFPtr      = null;
            mCVFPtr      = null;

            mLog.Dispose();
            mLog = null;

            //GC.Collect();
            base.Dispose();
        }
Ejemplo n.º 2
0
        void setupLighting()
        {
            /****/
            // Set ambient light
            mSceneManager.SetAmbientLight(Converter.GetColor(0.2f, 0.2f, 0.2f));
            // Point light, movable, reddish
            mLight = mSceneManager.CreateLight("Light2");
            mLight.SetDiffuseColour(mMinLightColour);
            mLight.SetSpecularColour(1.0f, 1.0f, 1.0f);
            mLight.SetAttenuation(8000.0f, 1.0f, 0.0005f, 0.0f);

            // Create light node
            mLightNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode("MovingLightNode");
            mLightNode.AttachObject(mLight);
            // create billboard set
            BillboardSet bbs = mSceneManager.CreateBillboardSet("lightbbs", 1);

            bbs.SetMaterialName("Examples/Flare");
            Billboard bb = bbs.CreateBillboard(0, 0, 0, mMinLightColour);

            // attach
            mLightNode.AttachObject(bbs);



            // create controller, after this is will get updated on its own
            mWFCF   = new WaveformControllerFunction(WaveformType.Sine, 0.0f, 0.5f);
            mCFFPtr = new ControllerFunctionFloatPtr(mWFCF);

            mLightWibbler = new LightWibbler(mLight, bb, mMinLightColour, mMaxLightColour, mMinFlareSize, mMaxFlareSize);
            mCVFPtr       = new ControllerValueFloatPtr(mLightWibbler.mCVFH);

            ControllerManager contMgr = ControllerManager.GetSingleton();

            mLightCtlFlt = contMgr.CreateController(contMgr.GetFrameTimeSource(), mCVFPtr, mCFFPtr);

            mLightNode.SetPosition(new Vector3(300, 250, -300));


            // Create a track for the light
            Animation anim = mSceneManager.CreateAnimation("LightTrack", 20.0f);

            // Spline it for nice curves
            anim.SetInterpolationMode(Animation.InterpolationMode.Spline);
            // Create a track to animate the camera's node
            NodeAnimationTrack track = anim.CreateNodeTrack(0, mLightNode);
            // Setup keyframes
            TransformKeyFrame key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(0.0f)).Handle, false);              // A startposition

            key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f));

            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(2.0f)).Handle, false);             //B
            key.SetTranslate(new Vector3(150.0f, 600.0f, -250.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(4.0f)).Handle, false);             //C
            key.SetTranslate(new Vector3(-150.0f, 650.0f, -100.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(6.0f)).Handle, false);             //D
            key.SetTranslate(new Vector3(-400.0f, 500.0f, -200.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(8.0f)).Handle, false);             //E
            key.SetTranslate(new Vector3(-200.0f, 500.0f, -400.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(10.0f)).Handle, false);            //F
            key.SetTranslate(new Vector3(-100.0f, 450.0f, -200.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(12.0f)).Handle, false);            //G
            key.SetTranslate(new Vector3(-100.0f, 400.0f, 180.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(14.0f)).Handle, false);            //H
            key.SetTranslate(new Vector3(0.0f, 250.0f, 600.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(16.0f)).Handle, false);            //I
            key.SetTranslate(new Vector3(100.0f, 650.0f, 100.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(18.0f)).Handle, false);            //J
            key.SetTranslate(new Vector3(250.0f, 600.0f, 0.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(20.0f)).Handle, false);            //K == A
            key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f));
            // Create a new animation state to track this
            mAnimState = mSceneManager.CreateAnimationState("LightTrack");
            mAnimState.SetEnabled(true);
            /****/
        }