本文整理汇总了C#中Axiom.Core.Camera类的典型用法代码示例。如果您正苦于以下问题:C# Camera类的具体用法?C# Camera怎么用?C# Camera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Camera类属于Axiom.Core命名空间,在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CameraComponent
public CameraComponent()
{
camera = null;
acceleration = Vector3.Zero;
velocity = Vector3.Zero;
rotation = Vector3.Zero;
}
示例2: OnLoad
public void OnLoad()
{
var dir = Directory.GetCurrentDirectory();
ResourceGroupManager.Instance.AddResourceLocation(dir, "Folder");
//MaterialManager.Instance.Initialize();
_scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
_scene.ClearScene();
Bindings.Axiom.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.Near = 0.001f;
_camera.Far = 20.0f;
_camera.AutoAspectRatio = true;
var vp = _window.AddViewport(_camera);
vp.BackgroundColor = ColorEx.CornflowerBlue;
}
示例3: NotifyCurrentCamera
/// <summary>
///
/// </summary>
/// <param name="camera"></param>
public override void NotifyCurrentCamera( Camera camera )
{
base.NotifyCurrentCamera( camera );
///Fake orientation toward camera
Vector3 zVec = ParentNode.DerivedPosition - camera.DerivedPosition;
zVec.Normalize();
Vector3 fixedAxis = camera.DerivedOrientation*Vector3.UnitY;
Vector3 xVec = fixedAxis.Cross( zVec );
xVec.Normalize();
Vector3 yVec = zVec.Cross( xVec );
yVec.Normalize();
Quaternion oriQuat = Quaternion.FromAxes( xVec, yVec, zVec );
this.fakeOrientation = oriQuat.ToRotationMatrix();
Quaternion q = ParentNode.DerivedOrientation.UnitInverse*oriQuat;
Matrix3 tempMat = q.ToRotationMatrix();
Matrix4 rotMat = Matrix4.Identity;
rotMat = tempMat;
rotMat.Translation = new Vector3( 0.5f, 0.5f, 0.5f );
this.unit.TextureMatrix = rotMat;
}
示例4: CreateCamera
protected override void CreateCamera()
{
base.CreateCamera();
camera2 = scene.CreateCamera("Camera2");
camera2.Far = 300;
camera2.Near = 1;
}
示例5: GetSquaredViewDepth
///
/// </summary>
/// <param name="camera"></param>
/// <returns></returns>
public override float GetSquaredViewDepth(Camera camera)
{
// get the parent entitie's parent node
Node node = this.ParentNode;
Debug.Assert(node != null);
return node.GetSquaredViewDepth(camera);
}
示例6: Merge
public void Merge( AxisAlignedBox boxBounds, Sphere sphereBounds, Camera cam, bool receiver )
{
aabb.Merge( boxBounds );
if ( receiver )
receiverAabb.Merge( boxBounds );
Real camDistToCenter = ( cam.DerivedPosition - sphereBounds.Center ).Length;
minDistance = System.Math.Min( minDistance, System.Math.Max( (Real)0, camDistToCenter - sphereBounds.Radius ) );
maxDistance = System.Math.Max( maxDistance, camDistToCenter + sphereBounds.Radius );
}
示例7: NotifyCamera
/// <summary>
///
/// </summary>
/// <param name="cam"></param>
/// <param name="section"></param>
public override void NotifyCamera(Camera cam, PagedWorldSection section)
{
Grid2DPageStrategyData stratData = (Grid2DPageStrategyData)section.StrategyData;
Vector3 pos = cam.DerivedPosition;
Vector2 gridpos = Vector2.Zero;
stratData.ConvetWorldToGridSpace(pos, ref gridpos);
int row = 0, col = 0;
stratData.DetermineGridLocation(gridpos, ref row, ref col);
float loadRadius = stratData.LoadRadiusInCells;
float holdRadius = stratData.HoldRadiusInCells;
//scan the whole hold range
float frowmin = (float)row - holdRadius;
float frowmax = (float)row + holdRadius;
float fcolmin = (float)col - holdRadius;
float fcolmax = (float)col + holdRadius;
int clampRowAt = stratData.CellCountVert - 1;
int clampColAt = stratData.CellCountHorz - 1;
//round UP max, round DOWN min
int rowmin = frowmin < 0 ? 0 : (int)System.Math.Floor(frowmin);
int rowmax = frowmax > clampRowAt ? clampRowAt : (int)System.Math.Ceiling(frowmax);
int colmin = fcolmin < 0 ? 0 : (int)System.Math.Floor(fcolmin);
int colmax = fcolmax > clampColAt ? clampColAt : (int)System.Math.Ceiling(fcolmax);
// the inner, active load range
frowmin = (float)row - loadRadius;
frowmax = (float)row + loadRadius;
fcolmin = (float)col - loadRadius;
fcolmax = (float)col + loadRadius;
//round UP max, round DOWN min
int loadrowmin = frowmin < 0 ? 0 : (int)System.Math.Floor(frowmin);
int loadrowmax = frowmax > clampRowAt ? clampRowAt : (int)System.Math.Ceiling(frowmax);
int loadcolmin = fcolmin < 0 ? 0 : (int)System.Math.Floor(fcolmin);
int loadcolmax = fcolmax > clampColAt ? clampColAt : (int)System.Math.Ceiling(fcolmax);
for (int r = rowmin; r <= rowmax; ++r)
{
for (int c = colmin; c <= colmax; ++c)
{
PageID pageID = stratData.CalculatePageID(r, c);
if (r >= loadrowmin && r <= loadrowmax && c >= loadcolmin && c <= loadcolmax)
{
// int the 'load' range, request it
section.LoadPage(pageID);
}
else
{
// int the outer 'hold' range, keep it but don't actively load.
section.HoldPage(pageID);
}
// other paged will by inference be marked for unloading
}
}
}
示例8: GetSquaredViewDepth
/// <summary>
/// Returns the camera-relative squared depth of this renderable.
/// </summary>
/// <param name="camera"></param>
/// <returns></returns>
public override Real GetSquaredViewDepth( Camera camera )
{
Vector3 min, max, mid, dist;
min = box.Minimum;
max = box.Maximum;
mid = ( ( min - max )*0.5 ) + min;
dist = camera.DerivedPosition - mid;
return dist.LengthSquared;
}
示例9: CreateCamera
public virtual void CreateCamera()
{
// create a camera and initialize its position
camera = scene.CreateCamera("MainCamera");
camera.Position = new Vector3(0, 0, 500);
camera.LookAt(new Vector3(0, 0, -300));
// set the near clipping plane to be very close
camera.Near = 5;
camera.AutoAspectRatio = true;
}
示例10: 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);
}
}
示例11: CheckShadowCasters
private void CheckShadowCasters( IList casters,
PlaneBoundedVolume nearClipVol,
Light light,
bool extrudeInSoftware,
bool finiteExtrude,
bool zfailAlgo,
Camera camera,
float extrudeDistance,
bool stencil2sided,
LightList tmpLightList )
{
int flags;
for ( int i = 0; i < casters.Count; i++ )
{
ShadowCaster caster = (ShadowCaster)casters[ i ];
if ( nearClipVol.Intersects( caster.GetWorldBoundingBox() ) )
{
// We have a zfail case, we must use zfail for all objects
zfailAlgo = true;
break;
}
}
for ( int ci = 0; ci < casters.Count; ci++ )
{
ShadowCaster caster = (ShadowCaster)casters[ ci ];
flags = 0;
if ( light.Type != LightType.Directional )
{
extrudeDistance = caster.GetPointExtrusionDistance( light );
}
if ( !extrudeInSoftware && !finiteExtrude )
{
// hardware extrusion, to infinity (and beyond!)
flags |= (int)ShadowRenderableFlags.ExtrudeToInfinity;
}
if ( zfailAlgo )
{
// We need to include the light and / or dark cap
// But only if they will be visible
if ( camera.IsObjectVisible( caster.GetLightCapBounds() ) )
{
flags |= (int)ShadowRenderableFlags.IncludeLightCap;
}
}
// Dark cap (no dark cap for directional lights using
// hardware extrusion to infinity)
if ( !( ( flags & (int)ShadowRenderableFlags.ExtrudeToInfinity ) != 0 &&
light.Type == LightType.Directional ) &&
camera.IsObjectVisible( caster.GetDarkCapBounds( light, extrudeDistance ) ) )
{
flags |= (int)ShadowRenderableFlags.IncludeDarkCap;
}
// get shadow renderables
IEnumerator renderables = caster.GetShadowVolumeRenderableEnumerator(
this.shadowTechnique, light, this.shadowIndexBuffer, extrudeInSoftware, extrudeDistance, flags );
// If using one-sided stencil, render the first pass of all shadow
// renderables before all the second passes
for ( int i = 0; i < ( stencil2sided ? 1 : 2 ); i++ )
{
if ( i == 1 )
{
renderables = caster.GetLastShadowVolumeRenderableEnumerator();
}
while ( renderables.MoveNext() )
{
ShadowRenderable sr = (ShadowRenderable)renderables.Current;
// omit hidden renderables
if ( sr.IsVisible )
{
// render volume, including dark and (maybe) light caps
this.RenderSingleShadowVolumeToStencil( sr,
zfailAlgo,
stencil2sided,
tmpLightList,
( i > 0 ) );
// optionally render separate light cap
if ( sr.IsLightCapSeperate
&& ( ( flags & (int)ShadowRenderableFlags.IncludeLightCap ) ) > 0 )
{
// must always fail depth check
this.targetRenderSystem.DepthBufferFunction = CompareFunction.AlwaysFail;
Debug.Assert( sr.LightCapRenderable != null,
"Shadow renderable is missing a separate light cap renderable!" );
this.RenderSingleShadowVolumeToStencil( sr.LightCapRenderable,
zfailAlgo,
stencil2sided,
//.........这里部分代码省略.........
示例12: RenderShadowVolumesToStencil
/// <summary>
/// Internal method for rendering all the objects for a given light into the stencil buffer.
/// </summary>
/// <param name="light">The light source.</param>
/// <param name="camera">The camera being viewed from.</param>
protected virtual void RenderShadowVolumesToStencil( Light light, Camera camera )
{
// get the shadow caster list
IList casters = this.FindShadowCastersForLight( light, camera );
if ( casters.Count == 0 )
{
// No casters, just do nothing
return;
}
// Set up scissor test (point & spot lights only)
bool scissored = false;
if ( light.Type != LightType.Directional &&
this.targetRenderSystem.Capabilities.HasCapability( Capabilities.ScissorTest ) )
{
// Project the sphere onto the camera
float left, right, top, bottom;
Sphere sphere = new Sphere( light.DerivedPosition, light.AttenuationRange );
if ( camera.ProjectSphere( sphere, out left, out top, out right, out bottom ) )
{
scissored = true;
// Turn normalised device coordinates into pixels
int iLeft, iTop, iWidth, iHeight;
this.currentViewport.GetActualDimensions( out iLeft, out iTop, out iWidth, out iHeight );
int szLeft, szRight, szTop, szBottom;
szLeft = (int)( iLeft + ( ( left + 1 ) * 0.5f * iWidth ) );
szRight = (int)( iLeft + ( ( right + 1 ) * 0.5f * iWidth ) );
szTop = (int)( iTop + ( ( -top + 1 ) * 0.5f * iHeight ) );
szBottom = (int)( iTop + ( ( -bottom + 1 ) * 0.5f * iHeight ) );
this.targetRenderSystem.SetScissorTest( true, szLeft, szTop, szRight, szBottom );
}
}
this.targetRenderSystem.UnbindGpuProgram( GpuProgramType.Fragment );
// Can we do a 2-sided stencil?
bool stencil2sided = false;
if ( this.targetRenderSystem.Capabilities.HasCapability( Capabilities.TwoSidedStencil ) &&
this.targetRenderSystem.Capabilities.HasCapability( Capabilities.StencilWrap ) )
{
// enable
stencil2sided = true;
}
// Do we have access to vertex programs?
bool extrudeInSoftware = true;
bool finiteExtrude = !this.shadowUseInfiniteFarPlane ||
!this.targetRenderSystem.Capabilities.HasCapability(
Capabilities.InfiniteFarPlane );
if ( this.targetRenderSystem.Capabilities.HasCapability( Capabilities.VertexPrograms ) )
{
extrudeInSoftware = false;
this.EnableHardwareShadowExtrusion( light, finiteExtrude );
}
else
{
this.targetRenderSystem.UnbindGpuProgram( GpuProgramType.Vertex );
}
// Add light to internal list for use in render call
tmpLightList.Clear();
tmpLightList.Add( light );
// Turn off color writing and depth writing
this.targetRenderSystem.SetColorBufferWriteEnabled( false, false, false, false );
this.targetRenderSystem.DepthBufferWriteEnabled = false;
this.targetRenderSystem.StencilCheckEnabled = true;
this.targetRenderSystem.DepthBufferFunction = CompareFunction.Less;
// Calculate extrusion distance
float extrudeDistance = 0;
if ( light.Type == LightType.Directional )
{
extrudeDistance = this.shadowDirLightExtrudeDist;
}
// get the near clip volume
PlaneBoundedVolume nearClipVol = light.GetNearClipVolume( camera );
// Determine whether zfail is required
// We need to use zfail for ALL objects if we find a single object which
// requires it
bool zfailAlgo = false;
this.CheckShadowCasters( casters,
nearClipVol,
light,
extrudeInSoftware,
finiteExtrude,
zfailAlgo,
//.........这里部分代码省略.........
示例13: NotifyCurrentCamera
public override void NotifyCurrentCamera( Camera camera )
{
if ( parentNode != null )
{
// Get mesh lod strategy
var meshStrategy = this.mesh.LodStrategy;
// Get the appropriate lod value
Real lodValue = meshStrategy.GetValue( this, camera );
// Bias the lod value
var biasedMeshLodValue = lodValue*this.meshLodFactorTransformed;
// Get the index at this biased depth
var newMeshLodIndex = this.mesh.GetLodIndex( biasedMeshLodValue );
// Apply maximum detail restriction (remember lower = higher detail)
this.meshLodIndex = (int)Utility.Max( this.maxMeshLodIndex, this.meshLodIndex );
// Apply minimum detail restriction (remember higher = lower detail)
this.meshLodIndex = (int)Utility.Min( this.minMeshLodIndex, this.meshLodIndex );
// Construct event object
EntityMeshLodChangedEvent evt;
evt.Entity = this;
evt.Camera = camera;
evt.LodValue = biasedMeshLodValue;
evt.PreviousLodIndex = this.meshLodIndex;
evt.NewLodIndex = newMeshLodIndex;
// Notify lod event listeners
//camera.SceneManager.NotifyEntityMeshLodChanged( evt );
// Change lod index
this.meshLodIndex = evt.NewLodIndex;
// Now do material LOD
lodValue *= this.materialLodFactorTransformed;
// apply the material LOD to all sub entities
foreach ( var subEntity in this.subEntityList )
{
// Get sub-entity material
var material = subEntity.Material;
// Get material lod strategy
var materialStrategy = material.LodStrategy;
// Recalculate lod value if strategies do not match
Real biasedMaterialLodValue;
if ( meshStrategy == materialStrategy )
{
biasedMaterialLodValue = lodValue;
}
else
{
biasedMaterialLodValue = materialStrategy.GetValue( this, camera )*
materialStrategy.TransformBias( this.materialLodFactor );
}
// Get the index at this biased depth
var idx = material.GetLodIndex( biasedMaterialLodValue );
// Apply maximum detail restriction (remember lower = higher detail)
idx = (int)Utility.Max( this.maxMaterialLodIndex, idx );
// Apply minimum detail restriction (remember higher = lower detail)
idx = (int)Utility.Min( this.minMaterialLodIndex, idx );
// Construct event object
EntityMaterialLodChangedEvent materialLodEvent;
materialLodEvent.SubEntity = subEntity;
materialLodEvent.Camera = camera;
materialLodEvent.LodValue = biasedMaterialLodValue;
materialLodEvent.PreviousLodIndex = subEntity.MaterialLodIndex;
materialLodEvent.NewLodIndex = idx;
// Notify lod event listeners
//camera.SceneManager.NotifyEntityMaterialLodChanged( materialLodEvent );
// Change lod index
subEntity.MaterialLodIndex = materialLodEvent.NewLodIndex;
// Also invalidate any camera distance cache
//subEntity.InvalidateCameraCache();
}
}
// Notify child objects (tag points)
foreach ( var child in this.childObjectList.Values )
{
child.NotifyCurrentCamera( camera );
}
}
示例14: CreateCamera
/// <summary>
/// Creates a camera to be managed by this scene manager.
/// </summary>
/// <remarks>
/// This camera can be added to the scene at a later time using
/// the AttachObject method of the SceneNode class.
/// </remarks>
/// <param name="name"></param>
/// <returns></returns>
public virtual Camera CreateCamera( string name )
{
if ( this.cameraList.ContainsKey( name ) )
{
throw new AxiomException( string.Format( "A camera with the name '{0}' already exists in the scene.",
name ) );
}
// create the camera and add it to our local list
Camera camera = new Camera( name, this );
this.cameraList.Add( camera );
return camera;
}
示例15: QueueSkiesForRendering
/// <summary>
/// Internal method for queueing the sky objects with the params as
/// previously set through SetSkyBox, SetSkyPlane and SetSkyDome.
/// </summary>
/// <param name="camera"></param>
internal virtual void QueueSkiesForRendering( Camera camera )
{
// translate the skybox by cam position
if ( this.skyPlaneNode != null )
{
this.skyPlaneNode.Position = camera.DerivedPosition;
}
if ( this.skyBoxNode != null )
{
this.skyBoxNode.Position = camera.DerivedPosition;
}
if ( this.skyDomeNode != null )
{
this.skyDomeNode.Position = camera.DerivedPosition;
}
RenderQueueGroupID qid;
// if the skyplane is enabled, queue up the single plane
if ( this.isSkyPlaneEnabled )
{
qid = this.isSkyPlaneDrawnFirst ? RenderQueueGroupID.SkiesEarly : RenderQueueGroupID.SkiesLate;
this.GetRenderQueue().AddRenderable( this.skyPlaneEntity.GetSubEntity( 0 ), 1, qid );
}
// if the skybox is enabled, queue up all the planes
if ( this.isSkyBoxEnabled )
{
qid = this.isSkyBoxDrawnFirst ? RenderQueueGroupID.SkiesEarly : RenderQueueGroupID.SkiesLate;
for ( int plane = 0; plane < 6; plane++ )
{
this.GetRenderQueue().AddRenderable( this.skyBoxEntities[ plane ].GetSubEntity( 0 ), 1, qid );
}
}
// if the skydome is enabled, queue up all the planes
if ( this.isSkyDomeEnabled )
{
qid = this.isSkyDomeDrawnFirst ? RenderQueueGroupID.SkiesEarly : RenderQueueGroupID.SkiesLate;
for ( int plane = 0; plane < 5; ++plane )
{
this.GetRenderQueue().AddRenderable( this.skyDomeEntities[ plane ].GetSubEntity( 0 ), 1, qid );
}
}
}