/// <summary>
        ///
        /// </summary>
        public void Clear()
        {
            if (mRenderMethod == BillboardMethod.Accelerated)
            {
                //Delete the entity and mesh data
                if (mEntity != null)
                {
                    //Delete entity
                    mNode.DetachAllObjects();
                    mSceneMgr.RemoveEntity(mEntity);
                    mEntity = null;

                    //Delete mesh
                    Debug.Assert(mMesh != null);
                    string meshName = mMesh.Name;
                    mMesh = null;
                    if (MeshManager.Instance != null)
                    {
                        MeshManager.Instance.Remove(meshName);
                    }
                }

                //Remove any billboard data which might be left over if the user forgot to call build()
                mBillboardBuffer.Clear();
            }
            else
            {
                mFallbackSet.Clear();
            }
        }
示例#2
0
        }         // end CreateScene()

        private void SetLighting(string mode)
        {
            // Local Variable declarations
            string[] modeList = new string[] { "Ambient", "SunLight", "Colors" };           // add "Motion"
            Light    l;

            scene.AmbientLight = new ColorEx(0.05f, 0.05f, 0.05f);             // default is low ambient light

            // Clear Current Lights and start over
            // TODO: Add ClearLights
            //this.scene.ClearLights();
            lightNode.Lights.Clear();
            lightSet.Clear();

            // Set next Light Mode
            if (mode == "next")
            {
                lightModeIndex = (++lightModeIndex) % modeList.Length;
            }
            lightMode = modeList[lightModeIndex % modeList.Length];

            switch (lightMode)
            {
            case "SunLight":
                // Add Sun - Up and to the Left
                for (int i = 0; i < 3; i++)
                {
                    l           = AddLight("DirLight" + i.ToString(), new Vector3(-PLANE_SIZE / 2f, PLANE_SIZE / 2f, PLANE_SIZE / 2f), new ColorEx(1f, 1f, 1f, 1f), LightType.Directional);
                    l.Direction = new Vector3(1f, -0.5f, 0f);
                    l.SetAttenuation(10000f, 0, 0, 0);
                }
                scene.AmbientLight = new ColorEx(0.1f, 0.1f, 0.1f);                         // default is low ambient light
                break;

            case "Colors":
                float lightScale  = 1f;
                float lightDist   = PLANE_SIZE;                       // / lightScale;
                float lightHeight = 300f / lightScale;
                lightNode.Scale(new Vector3(lightScale, lightScale, lightScale));

                // Create a Light
                AddLight("Lt1", new Vector3(lightDist, lightHeight, lightDist), new ColorEx(1f, 1f, 0f, 0f), LightType.Point);
                AddLight("Lt2", new Vector3(lightDist, lightHeight, 0), ColorEx.Purple, LightType.Point);
                AddLight("Lt3", new Vector3(0, lightHeight, lightDist), ColorEx.Blue, LightType.Point);
                AddLight("Lt4", new Vector3(0, lightHeight, 0), ColorEx.DarkOrange, LightType.Point);

                // Center Spotlight showing down on center of WaterMesh
                l           = AddLight("LtMid", new Vector3(1500f, 1000f, 1500f), ColorEx.Red, LightType.Spotlight);
                l.Direction = -1 * Vector3.UnitY;
                l.SetSpotlightRange(60f, 70f, 90f);

                // Add Light to OgreHead coming out his forehead
                // TODO/BUG: Must alter Light name to avoid Axiom Exception.  Can't re-attach same light object to HeadNode
                string ltName = "LtHead" + RAND.NextDouble().ToString();
                l          = scene.CreateLight(ltName);
                l.Position = new Vector3(0, 20f, 0);
                l.Type     = LightType.Spotlight;
                l.SetSpotlightRange(40f, 20f, 20f);
                l.Diffuse = ColorEx.Yellow;
                l.SetAttenuation(1000000f, 0f, 0, 0.0000001f);                      // Make lights go a long way
                l.Direction = new Vector3(0, -0.1f, 1f);
                headNode.Lights.Add(l);
                headNode.AttachObject(l);
                break;

            case "Motion":

                //l.SetAttenuation(5000f, 0f, 0f, 0f);
                //SceneNode lightNode = scene.RootSceneNode.CreateChildSceneNode();
                //lightNode.Lights.Add(l);
                break;

            default:                                                   // "Ambient" mode
                scene.AmbientLight = new ColorEx(0.85f, 0.85f, 0.85f); // set Ambient Light
                break;
            }
        }