本文整理汇总了C#中Camera.LookAt方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.LookAt方法的具体用法?C# Camera.LookAt怎么用?C# Camera.LookAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.LookAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: CreateCamera
protected void CreateCamera()
{
mCamera = mSceneMgr.CreateCamera("PlayerCam");
mCamera.Position = new Vector3(50, 200, 1000);
mCamera.LookAt(Vector3.ZERO);
//mCamera.Yaw(new Degree(45));
//mCamera.NearClipDistance = 100;
//mCamera.FarClipDistance = 500;
//mCameraMan = new CameraMan(mCamera);
}
示例4: CreateCamera
public virtual void CreateCamera()
{
// Create the camera
camera = sceneMgr.CreateCamera("PlayerCam");
// Position it at 500 in Z direction
camera.Position = new Vector3(0, 0, 500);
// Look back along -Z
camera.LookAt(new Vector3(0, 0, -300));
camera.NearClipDistance = 5;
}
示例5: CreateCamera
protected virtual void CreateCamera()
{
mCamera = mSceneMgr.CreateCamera("PlayerCam");
mCamera.Position = new Vector3(0, 100, 250);
mCamera.LookAt(new Vector3(0, 50, 0));
mCamera.NearClipDistance = 5;
mCameraMan = new CameraMan(mCamera);
}
示例6: 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."
);
}
示例7: 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();
//.........这里部分代码省略.........
示例8: 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);
}
示例9: Open
public void Open(string fileName)
{
FrameDescription frame;
using (var frameFile = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
using (var reader = new StreamReader(frameFile))
frame = (FrameDescription)SerializationService.Deserialize(reader.ReadToEnd(), typeof(FrameDescription));
}
frame.FrameName = Path.GetFileNameWithoutExtension(fileName);
Directory.SetCurrentDirectory(frame.WorkingDir);
scn = new SceneDescription();
try
{
scn.LightOrientation = (int)frame["LightOrientation"];
}
catch
{
scn.LightOrientation = -1.0f;
}
scn.WorkingDirectory = frame.WorkingDir;
scn.SceneName = frame.FrameName;
var lights = new List<Lightsource>();
var cameras = new List<Camera>();
foreach (var frameElement in frame.Elements)
{
switch (frameElement.GetType().Name.ToString())
{
case "FrameAreaLightTemplate":
var templ = (FrameAreaLightTemplate)frameElement;
scn.LightNameTemplate = templ.NameTemplate;
scn.LightGain = new Vector3(templ.Gain.c1, templ.Gain.c2, templ.Gain.c3);
break;
case "FrameLightsource":
var lt = (FrameLightsource)frameElement;
var light = new Lightsource();
if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Area)
{
var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty));
light.Type = LightSourceTypes.Area;
light.Name = lt.Parameters[FrameLightsource.AreaLightGeometryName].ToString();
light.Emission = new Vector3(emission.x, emission.y, emission.z);
}
else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.EnvironmentMap)
{
light.Type = LightSourceTypes.EnvironmentMap;
light["ImagePath"] = scn.EnvMapPath = lt.Parameters[FrameLightsource.InfiniteLightMapPath].ToString();
}
else if (lt.LightType == RayDen.Library.Entity.Frames.LightSourceTypes.Point)
{
var pos = Vector.FromString(lt.Parameters[FrameLightsource.PointLightPosition].ToString().Replace(" ", string.Empty));
var emission = Vector.FromString(lt.Parameters[FrameLightsource.LightsourcePower].ToString().Replace(" ", string.Empty));
light.Emission = new Vector3(emission.x, emission.y, emission.z);
light.Type = LightSourceTypes.Point;
light.p0 = new Vector3(pos.x, pos.y, pos.z);
}
Trace.WriteLine(string.Format("Lightsource {0} {1}", light.Type, light.Name));
lights.Add(light);
break;
case "FrameCamera":
var cam = (FrameCamera)frameElement;
//cameras.Add(new Camera()
//{
// Fov = cam.Fov > 0f ? cam.Fov : 30f,
// Position = new Vector3(cam.Position.x, cam.Position.y, cam.Position.z),
// Target = new Vector3(cam.Target.x, cam.Target.y, cam.Target.z),
// Up = new Vector3(cam.Up.x, cam.Up.y, cam.Up.z)
//});
var camera = new Camera() { Fov = cam.Fov > 0f ? cam.Fov : 30f };
camera.LookAt(new Vector3(cam.Position.x, cam.Position.y, cam.Position.z),
new Vector3(cam.Target.x, cam.Target.y, cam.Target.z),
new Vector3(cam.Up.x, cam.Up.y, cam.Up.z));
cameras.Add(camera);
break;
case "FrameObjFileReference":
var objFile = (FrameObjFileReference)frameElement;
scn.SceneGeo = new GeoGroup()
{
MatFilePath = frame.WorkingDir + objFile.MtlFilePath,
ObjFilePath = frame.WorkingDir + objFile.ObjFilePath
};
break;
}
}
scn.Cameras = cameras.ToArray();
Trace.WriteLine(string.Format("{0} cameras", scn.Cameras.Length));
scn.Lights = lights.ToArray();
}
示例10: CreateCamera
private void CreateCamera() {
this.mCam = this.mSceneMgr.CreateCamera("MainCamera");
this.mCam.NearClipDistance = 0.1f;
this.mCam.FarClipDistance = 1000f;
//
// Position it at 500 in Z direction
mCam.SetPosition(0, 0, 80);
// Look back along -Z
mCam.LookAt(new Vector3(0f, 0f, -300f));
mCam.NearClipDistance = (0.5f);
mSceneMgr.ShadowFarDistance = (100.0f);
//#if OGRE_VERSION < ((2 << 16) | (0 << 8) | 0)
mSceneMgr.ShadowTechnique = (ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE);
mSceneMgr.SetShadowTextureSize(1024);
//#endif
mSceneMgr.AmbientLight = new ColourValue(0.1f, 0.1f, 0.1f); //(ColourValue.Black);
// Setup camera and light
setCameraPosDefault();
}
示例11: CreateCamera
private void CreateCamera()
{
m_Camera = m_SceneManager.CreateCamera("myCamera1");
m_Camera.ProjectionType = ProjectionType.PT_ORTHOGRAPHIC;
m_Camera.SetPosition(-1, 2000, 0);
m_Camera.NearClipDistance = 5;
m_Camera.FarClipDistance = 2501;
m_Camera.LookAt(Vector3.ZERO);
m_Camera.AutoAspectRatio = true;
}
示例12: CreateScene
protected virtual void CreateScene()
{
camera = sceneMgr.CreateCamera("Camera");
camera.Position = new Vector3(0, 0, 150);
camera.LookAt(Vector3.ZERO);
mViewport = mRenderWindow.AddViewport(camera);
Entity ogreHead = sceneMgr.CreateEntity("Head", "ogrehead.mesh");
SceneNode headNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
headNode.AttachObject(ogreHead);
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
Light l = sceneMgr.CreateLight("MainLight");
l.Position = new Vector3(20, 80, 50);
}
示例13: _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;
}
}
示例14: 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();
}
示例15: CreateCamera
/// <summary>
/// Creates the camera for this class.
/// If you override this function, you must set the Camera property of this class
/// to be the result. Example:
/// this.Camera = this.SceneManager.CreateCamera(...);
/// </summary>
protected virtual void CreateCamera()
{
mCamera = mSceneMgr.CreateCamera("MainCamera");
mCamera.NearClipDistance = 1;
mCamera.Position = new Vector3(0, 0, 300);
mCamera.LookAt(Vector3.ZERO);
}