本文整理汇总了C#中SceneManager.CreateCamera方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateCamera方法的具体用法?C# SceneManager.CreateCamera怎么用?C# SceneManager.CreateCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SceneManager
的用法示例。
在下文中一共展示了SceneManager.CreateCamera方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CameraControlSystem
private float _timeSinceLastFrameLastUpdate; // Time value passed to the last call of the method "Update"
#endregion Fields
#region Constructors
public CameraControlSystem(SceneManager sceneManager, string name, Camera camera = null, bool reCalcOnTargetMoving = true)
{
_sceneMgr = sceneManager;
_name = name;
_targetNode = null;
_targetNodeListener = null;
_recalcOnTargetMoving = reCalcOnTargetMoving;
_currentCameraMode = null;
_cameraNode = _sceneMgr.RootSceneNode.CreateChildSceneNode(_name + "SceneNode");
if (camera == null) {
_camera = _sceneMgr.CreateCamera(_name);
_isOwnCamera = true;
} else {
_camera = camera;
_isOwnCamera = false;
}
//Reset to default parameters
_camera.Position = Vector3.ZERO;
_camera.Orientation = Quaternion.IDENTITY;
// ... and attach the Ogre camera to the camera node
_cameraNode.AttachObject(_camera);
_cameraModes = new Dictionary<string, CameraMode>();
}
示例2: OnLoad
public void OnLoad()
{
var dir = Directory.GetCurrentDirectory();
ResourceGroupManager.Singleton.AddResourceLocation(dir, "FileSystem");
MaterialManager.Singleton.Initialise();
_scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
_scene.ClearScene();
Bindings.MOGRE.SLSharp.Init();
Shader.DebugMode = true;
//Shader.DebugMode = true;
_clipmap = new Clipmap(_scene);
RecalcHeight();
_camera = _scene.CreateCamera("MainCamera");
_camera.Position = new Vector3(0, 0, 5);
_camera.LookAt(Vector3.ZERO);
_camera.NearClipDistance = 0.001f;
_camera.FarClipDistance = 20.0f;
_camera.AutoAspectRatio = true;
var vp = _window.AddViewport(_camera);
vp.BackgroundColour = ColourValue.Blue;
}
示例3: ChooseSceneManager
protected virtual void ChooseSceneManager()
{
sceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
camera = sceneMgr.CreateCamera("Camera");
camera.Position = new Vector3(0, 0, 150);
camera.LookAt(Vector3.ZERO);
mViewport = mRenderWindow.AddViewport(camera);
}
示例4: Program
/// <summary>
/// set up ogre
/// </summary>
public Program()
{
root = new Root("plugins.cfg", "", "Ogre.log");
renderSystem = root.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
renderSystem.SetConfigOption("Full Screen", "No");
renderSystem.SetConfigOption("Video Mode", "1920 x 1200 @ 32-bit colour");
root.RenderSystem = renderSystem;
SetupResources();
window = root.Initialise(true, "shadow test");
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "sceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f);
camera = sceneMgr.CreateCamera("cam");
camera.Position = new Vector3(0.8f, 0.8f, 0.8f);
camera.LookAt(new Vector3(-1, 1, -1));
camera.SetAutoTracking(true, sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(0, 0.4f, 0)));
camera.NearClipDistance = 0.1f;
camera.FarClipDistance = 2000;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = ColourValue.Black;
camera.AspectRatio = (float) viewport.ActualWidth / (float) viewport.ActualHeight;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
TextureManager.Singleton.DefaultNumMipmaps = 1;
CreateThings();
//SetupParticles();
//SetupShadows();
SetupInput();
root.FrameStarted += FrameStarted;
Console.WriteLine(
@"
Press 1, 2, 3, 4 to enable/disable lights, or Esc to quit.
The red and blue textures have PSSM and self-shadowing enabled.
The yellow one does not.
You can also use WASDQE to move the camera around."
);
}
示例5: InitMogre
public void InitMogre()
{
root = new Root();
#if DEBUG
root.LoadPlugin("RenderSystem_Direct3D9_d");
#else
root.LoadPlugin("RenderSystem_Direct3D9");
#endif
bool foundit = false;
foreach (RenderSystem rs in root.GetAvailableRenderers())
{
root.RenderSystem = rs;
String rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem")
{
foundit = true;
break;
}
}
if (!foundit)
return; //we didn't find it... Raise exception?
//we found it, we might as well use it!
root.RenderSystem.SetConfigOption("Full Screen", "No");
root.RenderSystem.SetConfigOption("Video Mode",
String.Format("{0} x {1} @ 32-bit colour", windowSize.Width, windowSize.Height));
root.Initialise(false);
// other plugins
#if DEBUG
root.LoadPlugin("Plugin_CgProgramManager_d");
root.LoadPlugin("Plugin_OctreeSceneManager_d");
#else
root.LoadPlugin("Plugin_CgProgramManager");
root.LoadPlugin("Plugin_OctreeSceneManager");
#endif
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = hWnd.ToString();
window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
camera = sceneMgr.CreateCamera("SimpleCamera");
camera.NearClipDistance = 0.1f;
camera.AutoAspectRatio = true;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = new ColourValue(0.25f, 0.25f, 0.25f, 1.0f);
root.FrameStarted += new FrameListener.FrameStartedHandler(MogreFrameStarted);
}
示例6: OnOgreInitComplete
private void OnOgreInitComplete(object sender, RoutedEventArgs args)
{
if (AutoUpdateViewportSize) {
MogreImage.SizeChanged += new SizeChangedEventHandler(MogreImage_SizeChanged);
}
mogreImageSource.IsDebugOverlayVisible = true;
//-----------------------------------------------------------------------------
TextureManager.Singleton.DefaultNumMipmaps = 6;
root = MogreRootManager.GetSharedRoot();
sceneMgr = mogreImageSource.SceneManager = root.CreateSceneManager(SceneType.ST_GENERIC, "sceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f);
camera = sceneMgr.CreateCamera("cam");
camera.Position = new Vector3(0.8f, 0.8f, 0.8f);
camera.LookAt(new Vector3(-1, 1, -1));
camera.SetAutoTracking(true, sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(0, 0.4f, 0)));
camera.NearClipDistance = 0.1f;
camera.FarClipDistance = 2000;
mogreImageSource.ViewportDefinitions = new ViewportDefinition[] { new ViewportDefinition(camera) };
CreateThings();
//SetupInput();
mogreImageSource.Root.FrameStarted += FrameStarted;
}
示例7: Initialise
public void Initialise()
{
Root = new Root();
ConfigFile cf = new ConfigFile();
cf.Load("Resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
while (seci.MoveNext())
{
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
}
if (!Root.RestoreConfig())
if (!Root.ShowConfigDialog())
return;
Root.RenderSystem.SetConfigOption("VSync", "Yes");
RenderWindow = Root.Initialise(true, "WorldCreator"); // @@@@@@@@@@@@@@@ Nazwa okna gry.
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC);
Camera = SceneManager.CreateCamera("MainCamera");
Viewport = RenderWindow.AddViewport(Camera);
Camera.NearClipDistance = 0.1f;
Camera.FarClipDistance = 1000.0f;
Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height);
MOIS.ParamList pl = new MOIS.ParamList();
IntPtr windowHnd;
RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
pl.Insert("WINDOW", windowHnd.ToString());
InputManager = MOIS.InputManager.CreateInputSystem(pl);
Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, false);
NewtonWorld = new World();
NewtonDebugger = new Debugger(NewtonWorld);
NewtonDebugger.Init(SceneManager);
ObjectManager = new ObjectManager();
MaterialManager = new MaterialManager();
MaterialManager.Initialise();
//CharacterProfileManager = new CharacterProfileManager();
Items = new Items();
//PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
//Quests = new Quests();
//NPCManager = new NPCManager();
Labeler = new TextLabeler(5);
User = new Player();
CharacterProfileManager = new CharacterProfileManager();
NPCManager = new NPCManager();
HumanController = new HumanController();
TypedInput = new TypedInput();
//SoundManager = new SoundManager();
}
示例8: Initialise
public void Initialise()
{
m_Root = new Root();
ConfigFile cf = new ConfigFile();
cf.Load("Resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
while (seci.MoveNext())
{
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
}
if (!m_Root.RestoreConfig())
if (!m_Root.ShowConfigDialog())
return;
m_RenderWindow = m_Root.Initialise(true);
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC);
m_Camera = m_SceneManager.CreateCamera("MainCamera");
m_Viewport = m_RenderWindow.AddViewport(m_Camera);
m_Camera.NearClipDistance = 0.1f;
m_Camera.FarClipDistance = 1000.0f;
MOIS.ParamList pl = new MOIS.ParamList();
IntPtr windowHnd;
m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
pl.Insert("WINDOW", windowHnd.ToString());
m_InputManager = MOIS.InputManager.CreateInputSystem(pl);
m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, false);
m_NewtonWorld = new World();
m_NewtonDebugger = new Debugger(m_NewtonWorld);
m_NewtonDebugger.Init(m_SceneManager);
m_GameCamera = new GameCamera();
m_ObjectManager = new ObjectManager();
}
示例9: _InitOgre
//.........这里部分代码省略.........
ConfigFile.SectionIterator seci = configFile.GetSectionIterator();
// Normally we would use the foreach syntax, which enumerates the values,
// but in this case we need CurrentKey too;
while (seci.MoveNext())
{
string secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (var pair in settings)
{
string typeName = pair.Key;
string archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
// Configures the application and creates the Window
// A window HAS to be created, even though we'll never use it.
//
bool foundit = false;
foreach (RenderSystem rs in _root.GetAvailableRenderers())
{
if (rs == null) continue;
_root.RenderSystem = rs;
String rname = _root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem")
{
foundit = true;
break;
}
}
if (!foundit)
return false;
_root.RenderSystem.SetConfigOption("Full Screen", "No");
_root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");
_root.Initialise(false);
var misc = new NameValuePairList();
misc["externalWindowHandle"] = hWnd.ToString();
_renderWindow = _root.CreateRenderWindow("OgreImageSource Windows", 0, 0, false, misc);
_renderWindow.IsAutoUpdated = false;
InitResourceLoad();
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
this.Dispatcher.Invoke(
(MethodInvoker)delegate
{
if (CreateDefaultScene)
{
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
_sceneManager = _root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
_sceneManager.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
_camera = _sceneManager.CreateCamera("DefaultCamera");
_camera.Position = new Vector3(0f, 0f, 500f);
// Look back along -Z
_camera.LookAt(lockat);
_camera.NearClipDistance = 5;
_camera.FarClipDistance = 3000f;
}
//初始化平面
PublicPlane.normal = Vector3.UNIT_Z;
PublicPlane.d = 0;
IsFrontBufferAvailableChanged += _isFrontBufferAvailableChanged;
if (Initialised != null)
Initialised(this, new RoutedEventArgs());
ReInitRenderTarget();
AttachRenderTarget(true);
OnFrameRateChanged(this.FrameRate);
_currentThread = null;
});
return true;
}
}
示例10: Initialise
public void Initialise()
{
Root = new Root();
ConfigFile cf = new ConfigFile();
cf.Load("Resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
while (seci.MoveNext())
{
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
}
if (!Root.RestoreConfig())
if (!Root.ShowConfigDialog())
return;
Root.RenderSystem.SetConfigOption("VSync", "Yes");
RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg"); // @@@@@@@@@@@@@@@ Nazwa okna gry.
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC);
Camera = SceneManager.CreateCamera("MainCamera");
Viewport = RenderWindow.AddViewport(Camera);
Camera.NearClipDistance = 0.1f;
Camera.FarClipDistance = 1000.0f;
Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height);
MOIS.ParamList pl = new MOIS.ParamList();
IntPtr windowHnd;
RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
pl.Insert("WINDOW", windowHnd.ToString());
InputManager = MOIS.InputManager.CreateInputSystem(pl);
Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true);
NewtonWorld = new World();
NewtonDebugger = new Debugger(NewtonWorld);
NewtonDebugger.Init(SceneManager);
GameCamera = new GameCamera();
ObjectManager = new ObjectManager();
MaterialManager = new MaterialManager();
MaterialManager.Initialise();
Items = new Items();
PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
CharacterProfileManager = new CharacterProfileManager();
Quests = new Quests();
NPCManager = new NPCManager();
Labeler = new TextLabeler(5);
Random = new Random();
HumanController = new HumanController();
TypedInput = new TypedInput();
SoundManager = new SoundManager();
Dialog = new Dialog();
Mysz = new MOIS.MouseState_NativePtr();
Conversations = new Conversations();
TriggerManager = new TriggerManager();
Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed);
Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased);
IngameConsole = new IngameConsole();
IngameConsole.Init();
IngameConsole.AddCommand("dupa", "soundOddawajPiec");
IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy");
IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii");
IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3");
IngameConsole.AddCommand("map", "ChangeMap");
IngameConsole.AddCommand("save", "SaveGame");
IngameConsole.AddCommand("load", "LoadGame");
IngameConsole.AddCommand("help", "ConsoleHelp");
IngameConsole.AddCommand("h", "CommandHelp");
}
示例11: CreateScene
//****************************************************************
// - 'CreateScene' is a method used as a place to initialise and setup the scene.
// - IT IS ONLY RUN ONCE at the start
//****************************************************************
public override void CreateScene()
{
// First we have to initialise some stuff
sceneManager = sceneMgr;
// Ask the sceneManager to set some common shadow settings
sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.55f, 0.6f);
sceneMgr.ShadowColour = new ColourValue(0.23f, 0.27f, 0.3f);
// sceneMgr.SetFog(FogMode.FOG_EXP2, new ColourValue(0.92f, 0.92f, 0.98f), 0.0015f);
//sceneMgr.SetFog(FogMode.FOG_LINEAR, new ColourValue(0.92f, 0.92f, 0.98f), 0.002f, 300, 910);
//give us a pretty skybox
//sceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox", 500f);
oCam = sceneManager.CreateCamera("ocam");
oCam.Position = new Vector3(0, 100, 0.1f);
oCam.LookAt(0, 0, 0);
//create sound manager
fslSM = FSLSoundManager.Instance;
fslSM.InitializeSound(oCam);
//Set the viewport to the player's chase camera.
vp = viewport;
vp.Camera = oCam;
vp.ShadowsEnabled = true;
//make a pointer to window
rWindow = window;
//Create GUI
overlayGui = new OverlayGUI();
//Create the Game manager
gameManager = new GameManager();
//create Input System
control = new Control(window);
//Create Timer
timer = new Timer();
}
示例12: 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);
}
示例13: CreateScene
void CreateScene()
{
//SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
mMgr = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_FAR);
mCam = mMgr.CreateCamera("Camera");
mCam.FOVy = new Degree(Constants.PlayerCamera.DefaultCamFOV);
mCam.NearClipDistance = Constants.Video.NearClip;
mCam.FarClipDistance = Constants.Video.FarClip;
//Camera cam = mgr.CreateCamera("Camera");
mRoot.AutoCreatedWindow.AddViewport(mCam);
mRoot.FrameEnded += new FrameListener.FrameEndedHandler(FrameEnded);
mRoot.FrameStarted += new FrameListener.FrameStartedHandler(FrameStarted);
Drawing2D.Initialize(this);
mMgr.SetSkyBox(true, "Examples/Sky", 500, false);
ColourValue fadeColour = new ColourValue(0.4f, 0.6f, 0.6f);
//mMgr.SetFog(FogMode.FOG_EXP, fadeColour, 0.005f);
//String p = Path.GetDirectoryName(Application.ExecutablePath) + @"Media\" + "terrain.cfg";
//mMgr.SetWorldGeometry(p);
//CreateTerrain();
}
示例14: InitMogre
public void InitMogre()
{
//-----------------------------------------------------
// 1 enter ogre
//-----------------------------------------------------
root = new Root();
//-----------------------------------------------------
// 2 configure resource paths
//-----------------------------------------------------
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
// Go through all sections & settings in the file
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
// Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
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);
}
}
//-----------------------------------------------------
// 3 Configures the application and creates the window
//-----------------------------------------------------
bool foundit = false;
foreach (RenderSystem rs in root.GetAvailableRenderers()) {
root.RenderSystem = rs;
String rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem") {
foundit = true;
break;
}
}
if (!foundit)
return; //we didn't find it... Raise exception?
//we found it, we might as well use it!
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();
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
camera = sceneMgr.CreateCamera("SimpleCamera");
camera.Position = new Vector3(0f, 0f, 100f);
// Look back along -Z
camera.LookAt(new Vector3(0f, 0f, -300f));
camera.NearClipDistance = 5;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);
Entity ent = sceneMgr.CreateEntity("ogre", "ogrehead.mesh");
SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("ogreNode");
node.AttachObject(ent);
}
示例15: InitMogre
public void InitMogre()
{
//-----------------------------------------------------
// 1 enter ogre
//-----------------------------------------------------
root = new Root();
//-----------------------------------------------------
// 2 configure resource paths
//-----------------------------------------------------
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);
// Go through all sections & settings in the file
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
// Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
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);
}
}
//-----------------------------------------------------
// 3 Configures the application and creates the window
//-----------------------------------------------------
bool foundit = false;
foreach (RenderSystem rs in root.GetAvailableRenderers())
{
root.RenderSystem = rs;
String rname = root.RenderSystem.Name;
if (rname == "Direct3D9 Rendering Subsystem")
{
foundit = true;
break;
}
}
if (!foundit)
return; //we didn't find it... Raise exception?
//we found it, we might as well use it!
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();
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
sceneMgr.AmbientLight = new ColourValue(1f, 1f, 1f);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
camera = sceneMgr.CreateCamera("SimpleCamera");
camera.Position = new Vector3(400f, 0f, 0f);
// Look back along -Z
camera.LookAt(new Vector3(-1f, 0f, 0f));
camera.NearClipDistance = 5;
viewport = window.AddViewport(camera);
viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);
material = MaterialManager.Singleton.Create("front", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow3.jpg");
material = MaterialManager.Singleton.Create("other", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow.jpg");
material = MaterialManager.Singleton.Create("back", "General");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("back2.jpg");
Vector3 moveVector3 = new Vector3(0f,-60f,110f);
for (int i = 0; i < cubeCount; i++)
{
Cube cube = new Cube();
cube.CubeName = "cube" + i.ToString();
cube.BuildCube("front", ref sceneMgr);
ManualObject manual = sceneMgr.GetManualObject(cube.CubeName);
manual.ConvertToMesh("cubeMesh"+i.ToString());
Entity ent = sceneMgr.CreateEntity("box"+i.ToString(), "cubeMesh"+i.ToString());
//.........这里部分代码省略.........