本文整理汇总了C#中SceneManager.CreateRayQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateRayQuery方法的具体用法?C# SceneManager.CreateRayQuery怎么用?C# SceneManager.CreateRayQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SceneManager
的用法示例。
在下文中一共展示了SceneManager.CreateRayQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pick
// intersects objects in scene with ray from screen coords: x, y
public static RaySceneQueryResult Pick(SceneManager mgr, int x, int y, Viewport vp, Camera cam)
{
//normalise mouse coordinates to [0,1]
//we could have used the panel's width/height in pixels instead of viewport's width/height
float scrx = (float)x / vp.ActualWidth;
float scry = (float)y / vp.ActualHeight;
Ray ray = cam.GetCameraToViewportRay(scrx, scry);
RaySceneQuery query = mgr.CreateRayQuery(ray);
RaySceneQueryResult results = query.Execute();
return results;
}
示例2: Init
//.........这里部分代码省略.........
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();
// Create the camera's pitch node as a child of camera's yaw node.
cameraPitchNode = cameraYawNode.CreateChildSceneNode();
// Create the camera's roll node as a child of camera's pitch node
// and attach the camera to it.
cameraRollNode = cameraPitchNode.CreateChildSceneNode();
cameraRollNode.AttachObject(mCamera);
mRaySceneQuery = mMgr.CreateRayQuery(new Ray());
}
catch (Exception ex)
{
Console.WriteLine("[Error,OgreForm.cs]: " + ex.Message + "," + ex.StackTrace);
}
}
示例3: init
//.........这里部分代码省略.........
// 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);
// Set up for picking
raySceneQuery = sceneMgr.CreateRayQuery(new Ray(), SceneManager.WORLD_GEOMETRY_TYPE_MASK);
if (null == raySceneQuery)
return false;
raySceneQuery.SetSortByDistance(true);
return true;
}