本文整理汇总了C#中Axiom.Core.SceneManager.CreateLight方法的典型用法代码示例。如果您正苦于以下问题:C# SceneManager.CreateLight方法的具体用法?C# SceneManager.CreateLight怎么用?C# SceneManager.CreateLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axiom.Core.SceneManager
的用法示例。
在下文中一共展示了SceneManager.CreateLight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiLights
public MultiLights(SceneManager pSceneManager, SceneNode pCamNode, MovingObject pPlayerShip, Int32 pNumberOfLights)
{
oldCamLightColor = CamLightColor = new ColorEx(0.13f, 0.1f, 0.05f);
PlayerLightColor = ColorEx.White;
camLights = new List<Light>(pNumberOfLights);
innerLights = (Int32)Math.Round(pNumberOfLights / 3.0f, MidpointRounding.AwayFromZero);
outerLights = pNumberOfLights - innerLights;
// create the playership's light.
playerLight = pSceneManager.CreateLight("playerSpotLight");
playerLight.Type = LightType.Spotlight;
playerLight.Diffuse = PlayerLightColor;
playerLight.Specular = ColorEx.White;
playerLight.SetSpotlightRange(0.0f, 120.0f);
playerLight.Direction = Vector3.NegativeUnitZ;
playerLightNode = pPlayerShip.Node.CreateChildSceneNode();
playerLightNode.AttachObject(playerLight);
playerLightNode.Position = new Vector3(0, 0, 0);
playerLightNode.SetDirection(new Vector3(1, 0, 0), TransformSpace.Local);
// create the camera spotlights around the camera's direction.
camInnerLightNode = pCamNode.CreateChildSceneNode();
camInnerLightNode.Position = new Vector3(0, 0, 0);
camOuterLightNode = pCamNode.CreateChildSceneNode();
camOuterLightNode.Position = new Vector3(0, 0, 0);
for (var i = 0; i < innerLights; i++)
{
var light = pSceneManager.CreateLight("camInnerLight " + (i + 1));
light.Type = LightType.Spotlight;
light.Diffuse = CamLightColor;
light.Specular = ColorEx.White;
light.SetSpotlightRange(0.0f, 25.0f);
light.Direction = Quaternion.FromAngleAxis(360.0 * i / innerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
Quaternion.FromAngleAxis(10.0 * Constants.DegreesToRadians, Vector3.UnitX) *
Vector3.NegativeUnitZ;
camLights.Add(light);
camInnerLightNode.AttachObject(light);
}
for (var i = 0; i < outerLights; i++)
{
var light = pSceneManager.CreateLight("camOuterLight " + (i + 1));
light.Type = LightType.Spotlight;
light.Diffuse = CamLightColor;
light.Specular = ColorEx.White;
light.SetSpotlightRange(0.0f, 25.0f);
light.Direction = Quaternion.FromAngleAxis(360.0 * i / outerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
Quaternion.FromAngleAxis(20.0 * Constants.DegreesToRadians, Vector3.UnitX) *
Vector3.NegativeUnitZ;
camLights.Add(light);
camOuterLightNode.AttachObject(light);
}
}
示例2: OnLoad
public void OnLoad()
{
//ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true);
_root.SceneManager = _sceneManager = _root.CreateSceneManager(SceneType.ExteriorClose);
_sceneManager.ClearScene();
_camera = _sceneManager.CreateCamera("MainCamera");
_camera.Position = new Vector3(0, 0, 500);
_camera.LookAt(new Vector3(0, 0, -300));
_camera.Near = 5;
_camera.AutoAspectRatio = true;
_camera.FieldOfView = 0.70f;
_viewport = _renderWindow.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100);
_viewport.BackgroundColor = ColorEx.Black; ;
_light = _sceneManager.CreateLight("light1");
_light.Type = LightType.Directional;
_light.Position = new Vector3(0, 150, 300);
_light.Diffuse = ColorEx.Blue;
_light.Specular = ColorEx.Blue;
//_light.Direction = new Vector3(0, 0, -300);
_sceneManager.AmbientLight = ColorEx.White;// new ColorEx(0.2f, 0.2f, 0.2f);
ResourceGroupManager.Instance.InitializeAllResourceGroups();
_inputReader = PlatformManager.Instance.CreateInputReader();
_inputReader.Initialize(_renderWindow, true, true, false, false);
_inputReader.UseKeyboardEvents = true;
_inputReader.UseMouseEvents = false;
//_renderItems.Add(new BasicCube());
_renderItems.Add(new CubeBrowser());
foreach (var i in _renderItems)
{
i.Initialise(_root);
}
}
示例3: RenderCompositeMap
/// <summary>
/// Helper method to render a composite map.
/// </summary>
/// <param name="size"> The requested composite map size</param>
/// <param name="rect"> The region of the composite map to update, in image space</param>
/// <param name="mat">The material to use to render the map</param>
/// <param name="destCompositeMap"></param>
public virtual void RenderCompositeMap(int size, Rectangle rect,
Material mat, Texture destCompositeMap)
{
//return;
if (mCompositeMapSM == null)
{
//dedicated SceneManager
mCompositeMapSM = Root.Instance.CreateSceneManager(SceneType.ExteriorClose, "TerrainMaterialGenerator_SceneManager");
float camDist = 100;
float halfCamDist = camDist * 0.5f;
mCompositeMapCam = mCompositeMapSM.CreateCamera("TerrainMaterialGenerator_Camera");
mCompositeMapCam.Position = new Vector3(0, 0, camDist);
//mCompositeMapCam.LookAt(Vector3.Zero);
mCompositeMapCam.ProjectionType = Projection.Orthographic;
mCompositeMapCam.Near = 10;
mCompositeMapCam.Far = 999999* 3;
//mCompositeMapCam.AspectRatio = camDist / camDist;
mCompositeMapCam.SetOrthoWindow(camDist, camDist);
// Just in case material relies on light auto params
mCompositeMapLight = mCompositeMapSM.CreateLight("TerrainMaterialGenerator_Light");
mCompositeMapLight.Type = LightType.Directional;
RenderSystem rSys = Root.Instance.RenderSystem;
float hOffset = rSys.HorizontalTexelOffset / (float)size;
float vOffset = rSys.VerticalTexelOffset / (float)size;
//setup scene
mCompositeMapPlane = mCompositeMapSM.CreateManualObject("TerrainMaterialGenerator_ManualObject");
mCompositeMapPlane.Begin(mat.Name, OperationType.TriangleList);
mCompositeMapPlane.Position(-halfCamDist, halfCamDist, 0);
mCompositeMapPlane.TextureCoord(0 - hOffset, 0 - vOffset);
mCompositeMapPlane.Position(-halfCamDist, -halfCamDist, 0);
mCompositeMapPlane.TextureCoord(0 - hOffset, 1 - vOffset);
mCompositeMapPlane.Position(halfCamDist, -halfCamDist, 0);
mCompositeMapPlane.TextureCoord(1 - hOffset, 1 - vOffset);
mCompositeMapPlane.Position(halfCamDist, halfCamDist, 0);
mCompositeMapPlane.TextureCoord(1 - hOffset, 0 - vOffset);
mCompositeMapPlane.Quad(0, 1, 2, 3);
mCompositeMapPlane.End();
mCompositeMapSM.RootSceneNode.AttachObject(mCompositeMapPlane);
}//end if
// update
mCompositeMapPlane.SetMaterialName(0, mat.Name);
mCompositeMapLight.Direction = TerrainGlobalOptions.LightMapDirection;
mCompositeMapLight.Diffuse = TerrainGlobalOptions.CompositeMapDiffuse;
mCompositeMapSM.AmbientLight =TerrainGlobalOptions.CompositeMapAmbient;
//check for size change (allow smaller to be reused)
if (mCompositeMapRTT != null && size != mCompositeMapRTT.Width)
{
TextureManager.Instance.Remove(mCompositeMapRTT);
mCompositeMapRTT = null;
}
if (mCompositeMapRTT == null)
{
mCompositeMapRTT = TextureManager.Instance.CreateManual(
mCompositeMapSM.Name + "/compRTT",
ResourceGroupManager.DefaultResourceGroupName,
TextureType.TwoD,
size,
size,
0,
PixelFormat.BYTE_RGBA,
TextureUsage.RenderTarget);
RenderTarget rtt = mCompositeMapRTT.GetBuffer().GetRenderTarget();
// don't render all the time, only on demand
rtt.IsAutoUpdated = false;
Viewport vp = rtt.AddViewport(mCompositeMapCam);
// don't render overlays
vp.ShowOverlays = false;
}
// calculate the area we need to update
float vpleft = (float)rect.Left / (float)size;
float vptop = (float)rect.Top / (float)size;
float vpright = (float)rect.Right / (float)size;
float vpbottom = (float)rect.Bottom / (float)size;
float vpwidth = (float)rect.Width / (float)size;
float vpheight = (float)rect.Height / (float)size;
RenderTarget rtt2 = mCompositeMapRTT.GetBuffer().GetRenderTarget();
Viewport vp2 = rtt2.GetViewport(0);
mCompositeMapCam.SetWindow(vpleft, vptop, vpright, vpbottom);
rtt2.Update();
vp2.Update();
// We have an RTT, we want to copy the results into a regular texture
// That's because in non-update scenarios we don't want to keep an RTT
// around. We use a single RTT to serve all terrain pages which is more
// efficient.
//.........这里部分代码省略.........