Skip to main content
History: Mogre Basic Tutorial 2 Source
View published page
Source of version: 2
(current)
{CODE(wrap="1", colors="c#")} using System; using System.Collections.Generic; using System.Windows.Forms; using MogreFramework; using Mogre; namespace Tutorial02 { static class Program { [STAThread] static void Main() { try { MyOgreWindow win = new MyOgreWindow(); new SceneCreator(win); win.Go(); } catch (System.Runtime.InteropServices.SEHException) { if (OgreException.IsThrown) MessageBox.Show(OgreException.LastException.FullDescription, "An Ogre exception has occurred!"); else throw; } } } class MyOgreWindow : OgreWindow { protected override void CreateCamera() { Camera = this.SceneManager.CreateCamera("PlayerCam"); Camera.Position = new Vector3(0, 10, 500); Camera.LookAt(Vector3.ZERO); Camera.NearClipDistance = 5; } protected override void CreateViewport() { Viewport = this.RenderWindow.AddViewport(Camera); Viewport.BackgroundColour = ColourValue.Black; Camera.AspectRatio = (float)Viewport.ActualWidth / Viewport.ActualHeight; } } class SceneCreator { public SceneCreator(OgreWindow win) { win.SceneCreating += new OgreWindow.SceneEventHandler(SceneCreating); } void SceneCreating(OgreWindow win) { // Set the ambient light and shadow technique SceneManager mgr = win.SceneManager; mgr.SetShadowUseInfiniteFarPlane(false); mgr.AmbientLight = ColourValue.Black; mgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE; // Create a ninja Entity ent = mgr.CreateEntity("ninja", "ninja.mesh"); ent.CastShadows = true; mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); // Define a ground plane Plane plane = new Plane(Vector3.UNIT_Y, 0); MeshManager.Singleton.CreatePlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 20, 20, true, 1, 5, 5, Vector3.UNIT_Z); // Create a ground plane ent = mgr.CreateEntity("GroundEntity", "ground"); mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); ent.SetMaterialName("Examples/Rockwall"); ent.CastShadows = false; // Create the first light Light light; light = mgr.CreateLight("Light1"); light.Type = Light.LightTypes.LT_POINT; light.Position = new Vector3(0, 150, 250); light.DiffuseColour = ColourValue.Red; light.SpecularColour = ColourValue.Red; // Create the second light light = mgr.CreateLight("Light2"); light.Type = Light.LightTypes.LT_DIRECTIONAL; light.DiffuseColour = new ColourValue(.25f, .25f, 0); light.SpecularColour = new ColourValue(.25f, .25f, 0); light.Direction = new Vector3(0, -1, -1); // Create the third light light = mgr.CreateLight("Light3"); light.Type = Light.LightTypes.LT_SPOTLIGHT; light.DiffuseColour = ColourValue.Blue; light.SpecularColour = ColourValue.Blue; light.Direction = new Vector3(-1, -1, 0); light.Position = new Vector3(300, 300, 0); light.SetSpotlightRange(new Degree(35), new Degree(50)); } } } {CODE}
Search by Tags
Search Wiki by Freetags
Latest Changes
Projects using OGRE
Building Your Projects With CMake
Compiled API Reference
Overlay Editor
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
One Function Ogre
...more
Search
Find
Online Users
256 online users
OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username
Password
CapsLock is on.
Remember me (for 1 year)
Log in