当前位置: 首页>>代码示例>>C#>>正文


C# SceneManager.CreateLight方法代码示例

本文整理汇总了C#中SceneManager.CreateLight方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateLight方法的具体用法?C# SceneManager.CreateLight怎么用?C# SceneManager.CreateLight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SceneManager的用法示例。


在下文中一共展示了SceneManager.CreateLight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateScene

        protected static void CreateScene()
        {
            sceneMgr = _root.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE);

            //Image combined = new Image();

            //combined.LoadTwoImagesAsRGBA("terra_DIFFUSE.png", "terra_SPECULAR.png", "General", PixelFormat.PF_BYTE_RGBA);
            //combined.Save("terra_diffusespecular.png");

            //combined.LoadTwoImagesAsRGBA("terra_NORMAL.png", "terra_DISP.png", "General", PixelFormat.PF_BYTE_RGBA);
            //combined.Save("terra_normalheight.png");

            _cam = sceneMgr.CreateCamera("Camera");
            _cam.Pitch(-0.78f);
            _cam.NearClipDistance = 5f;
            _cam.FarClipDistance = 99999 * 6;
            _cam.Move(new Vector3(1084, 346, 1317));

            viewport = _window.AddViewport(_cam);
            _cam.AspectRatio = (float)viewport.ActualWidth / (float)viewport.ActualHeight;

            sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE;
            sceneMgr.ShadowTextureCount = 8;
            sceneMgr.SetShadowTextureSize(8192);

            CreateNewDude("1");
            CreateNewDude("2");

            Vector3 lightDir = new Vector3(0.55f, -0.3f, 0.75f);
            lightDir.Normalise();

            Light light = sceneMgr.CreateLight("tstLight");
            light.Type = Light.LightTypes.LT_DIRECTIONAL;
            light.Direction = lightDir;
            light.DiffuseColour = ColourValue.White;
            light.SpecularColour = ColourValue.White;
            light.CastShadows = false;
            light.Visible = true;

            sceneMgr.AmbientLight = ColourValue.White;

            tgo = new TerrainGlobalOptions();
            tg = new TerrainGroup(sceneMgr, Terrain.Alignment.ALIGN_X_Z, 513, 12000.0f);
            tg.SetFilenameConvention("Asd", "dat");
            tg.Origin = new Vector3(0, -250, 0);

            ConfigureTerrainDefaults(light);

            for (int x = 0; x <= 0; ++x)
            {
                for (int y = 0; y <= 0; ++y)
                {
                    DefineTerrain(x, y);
                }
            }

            tg.LoadAllTerrains(true);

            if (mTerrainImported)
            {
                foreach (TerrainGroup.TerrainSlot t in tg.GetTerrainIterator())
                {

                    InitBlendMaps(t.instance);
                }
            }

            tg.FreeTemporaryResources();
            //  tg.SaveAllTerrains(true);

            hydrax = new MHydrax.MHydrax(sceneMgr, _cam, viewport);

            hydrax.Components = MHydraxComponent.HYDRAX_COMPONENTS_ALL;

            Plane p = new Plane(new Vector3(0, 1, 0), new Vector3(0, 0, 0));

            MHydrax.MProjectedGrid m = new MProjectedGrid(hydrax,
                            new MPerlin(new MPerlin.MOptions(8, 0.085f, 0.49f, 1.4f, 1.27f, 2, new Vector3(0.5f, 50, 150000))),
                            p,
                            MMaterialManager.MNormalMode.NM_VERTEX,
                            new MHydrax.MProjectedGrid.MOptions(56, 35, 50, false, false, false, 3.75f));

            hydrax.SetModule(m);
            hydrax.CfgFileManager.Load("TestiPeli.hdx");

            hydrax.Create();

            //  sceneMgr.SetSkyDome(true, "Examples/CloudySky", 5, 8);

            mRect = new SelectionRectangle("Selection SelectionRectangle");

            sceneMgr.RootSceneNode.CreateChildSceneNode("debug_object").AttachObject(mRect);
            mRect._camera = _cam;

            ct = new CollisionTools(sceneMgr);
            SetupCaelum(viewport, _window);
        }
开发者ID:aRkker,项目名称:Survival,代码行数:97,代码来源:Program.cs

示例2: Init

        public void Init(String handle)
        {
            try
            {
                // Create root object
                mRoot = new Root();

                // Define Resources
                ConfigFile cf = new ConfigFile();
                cf.Load("./resources.cfg", "\t:=", true);
                ConfigFile.SectionIterator seci = cf.GetSectionIterator();
                String secName, typeName, archName;

                while (seci.MoveNext())
                {
                    secName = seci.CurrentKey;
                    ConfigFile.SettingsMultiMap settings = seci.Current;
                    foreach (KeyValuePair<string, string> pair in settings)
                    {
                        typeName = pair.Key;
                        archName = pair.Value;
                        ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                    }
                }

                //Load the resources from resources.cfg and selected tab (_ConfigurationPaths)
                //LoadResourceLocations(_ConfigurationPaths);

                //example of manual add: _FileSystemPaths.Add("../../Media/models");
                foreach (string foo in _ConfigurationPaths)
                {
                    AddResourceLocation(foo);
                }

                // Setup RenderSystem
                mRSys = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
                //mRSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem");

                // or use "OpenGL Rendering Subsystem"
                mRoot.RenderSystem = mRSys;

                mRSys.SetConfigOption("Full Screen", "No");
                mRSys.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

                // Create Render Window
                mRoot.Initialise(false, "Main Ogre Window");
                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = handle;
                misc["FSAA"] = "4";
                // misc["VSync"] = "True"; //not sure how to enable vsync to remove those warnings in Ogre.log
                mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

                // Init resources
                MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC);
                TextureManager.Singleton.DefaultNumMipmaps = 5;
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // Create a Simple Scene
                //SceneNode node = null;
                // mMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "SceneManager");
                mMgr = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE, "SceneManager");

                mMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f);

                mCamera = mMgr.CreateCamera("Camera");
                mWindow.AddViewport(mCamera);

                mCamera.AutoAspectRatio = true;
                mCamera.Viewport.SetClearEveryFrame(false);

                //Entity ent = mMgr.CreateEntity(displayMesh, displayMesh);

                //ent.SetMaterialName(displayMaterial);
                //node = mMgr.RootSceneNode.CreateChildSceneNode(displayMesh + "node");
                //node.AttachObject(ent);

                mCamera.Position = new Vector3(0, 0, 0);
                //mCamera.Position = new Vector3(0, 0, -400);
                mCamera.LookAt(0, 0, 1);

                //Create a single point light source
                Light light2 = mMgr.CreateLight("MainLight");
                light2.Position = new Vector3(0, 10, -25);
                light2.Type = Light.LightTypes.LT_POINT;
                light2.SetDiffuseColour(1.0f, 1.0f, 1.0f);
                light2.SetSpecularColour(0.1f, 0.1f, 0.1f);

                mWindow.WindowMovedOrResized();

                IsInitialized = true;

                // Create the camera's top node (which will only handle position).
                cameraNode = mMgr.RootSceneNode.CreateChildSceneNode();
                cameraNode.Position = new Vector3(0, 0, 0);

                //cameraNode = mMgr->getRootSceneNode()->createChildSceneNode();
                //cameraNode->setPosition(0, 0, 500);

                // Create the camera's yaw node as a child of camera's top node.
                cameraYawNode = cameraNode.CreateChildSceneNode();
//.........这里部分代码省略.........
开发者ID:zinick,项目名称:Ogre3D-Level-Editor,代码行数:101,代码来源:OgreForm.cs

示例3: init

            public bool init()
            {
                // Start with a new root to get this party started
                root = new Root();

                // Configuration buisness
                ConfigFile config = new ConfigFile();
                config.Load("resources.cfg", "\t:=", true);

                // Go through all our configuration settings
                ConfigFile.SectionIterator itor = config.GetSectionIterator();
                string secName, typeName, archName;

                // Move through all of the sections
                while (itor.MoveNext())
                {
                  secName = itor.CurrentKey;
                  ConfigFile.SettingsMultiMap settings = itor.Current;
                  foreach (KeyValuePair<string, string> pair in settings)
                  {
                typeName = pair.Key;
                archName = pair.Value;
                ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                  }
                }

                // Configure our window and set up the RenderSystem
                bool found = false;
                foreach (RenderSystem rs in root.GetAvailableRenderers())
                {
                  root.RenderSystem = rs;
                  string rname = root.RenderSystem.Name;
                  if (rname == "Direct3D9 Rendering Subsystem")
                  {
                found = true;
                break;
                  }
                }

                // If we can't find the DirectX rendering system somethign is seriously wrong
                if (!found)
                  return false;

                root.RenderSystem.SetConfigOption("Full Screen", "No");
                root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");

                root.Initialise(false);
                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = hWnd.ToString();
                window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // Create our SceneManager
                sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
                sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
                sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;

                // Create the camera
                camMgr = new CamManager();
                camMgr.Initialize(ref sceneMgr);

                viewport = window.AddViewport(camMgr.mainCam);
                viewport.BackgroundColour = new ColourValue(0, 0, 0, 1);

                // Load our stick here
                LoadModel("TEStick.mesh");

                // Set up ground
                Plane plane = new Plane(Mogre.Vector3.UNIT_Y, 0);
                MeshManager.Singleton.CreatePlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
                  1500, 1500, 20, 20, true, 1, 5, 5, Mogre.Vector3.UNIT_Z);
                Entity ground = sceneMgr.CreateEntity("GroundEnt", "ground");
                sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ground);

                ground.SetMaterialName("Examples/Rockwall");
                ground.CastShadows = false;

                // Set up some lights
                Light pointLight = sceneMgr.CreateLight("pointLight");
                pointLight.Type = Light.LightTypes.LT_POINT;
                pointLight.Position = new Mogre.Vector3(0, 150, 250);
                pointLight.DiffuseColour = ColourValue.White;
                pointLight.SpecularColour = ColourValue.White;

                Light directionalLight = sceneMgr.CreateLight("directionalLight");
                directionalLight.Type = Light.LightTypes.LT_DIRECTIONAL;
                directionalLight.DiffuseColour = new ColourValue(.25f, .25f, 0);
                directionalLight.SpecularColour = new ColourValue(.25f, .25f, 0);
                directionalLight.Direction = new Mogre.Vector3(0, -1, 1);

                Light spotLight = sceneMgr.CreateLight("spotLight");
                spotLight.Type = Light.LightTypes.LT_SPOTLIGHT;
                spotLight.DiffuseColour = ColourValue.White;
                spotLight.SpecularColour = ColourValue.White;
                spotLight.Direction = new Mogre.Vector3(-1, -1, 0);
                spotLight.Position = new Mogre.Vector3(300, 300, 0);
                spotLight.SetSpotlightRange(new Degree(35), new Degree(50));

                // Set up our Input
                root.FrameRenderingQueued += new FrameListener.FrameRenderingQueuedHandler(Input);
//.........这里部分代码省略.........
开发者ID:aczarno,项目名称:StickMagik,代码行数:101,代码来源:OgreForm.cs


注:本文中的SceneManager.CreateLight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。