Axiom.Core.SceneNode.GetObject C# (CSharp) Method

GetObject() public method

Returns a movable object attached to this node by index. Node that this method is O(n), whereas the string overload of this method is O(1). Use the string version of this method if speed is important.
public GetObject ( int index ) : Axiom.Core.MovableObject
index int The index of the object to return.
return Axiom.Core.MovableObject
		public MovableObject GetObject( int index )
		{
			int i = 0;
			foreach ( MovableObject mo in this.objectList.Values )
			{
				if ( i == index )
					return mo;
				i++;
			}
			throw new IndexOutOfRangeException( "Invalid index specified." );
		}

Same methods

SceneNode::GetObject ( string name ) : Axiom.Core.MovableObject

Usage Example

コード例 #1
0
		public override void UpdateDebugDisplay( Page p, SceneNode sn )
		{
			byte dbglvl = mManager.DebugDisplayLevel;
			if ( dbglvl != 0 )
			{
				// we could try to avoid updating the geometry every time here, but this 
				// wouldn't easily deal with paging parameter changes. There shouldn't 
				// be that many pages anyway, and this is debug after all, so update every time
				int x, y;
				var stratData = (Grid2DPageStrategyData)p.ParentSection.StrategyData;
				stratData.CalculateCell( p.PageID, out x, out y );

				var data = (Grid2DPageStrategyData)p.ParentSection.StrategyData;

				// Determine our centre point, we'll anchor here
				// Note that world points are initialised to ZERO since only 2 dimensions
				// are updated by the grid data (we could display this grid anywhere)
				Vector2 gridMidPoint = Vector2.Zero;
				Vector3 worldMidPoint = Vector3.Zero;
				data.GetMidPointGridSpace( x, y, ref gridMidPoint );
				data.ConvertGridToWorldSpace( gridMidPoint, ref worldMidPoint );

				sn.Position = worldMidPoint;

				var gridCorners = new Vector2[4];
				var worldCorners = new Vector3[4];

				data.GetCornersGridSpace( x, y, ref gridCorners );
				for ( int i = 0; i < 4; ++i )
				{
					worldCorners[ i ] = Vector3.Zero;
					data.ConvertGridToWorldSpace( gridCorners[ i ], ref worldCorners[ i ] );
					// make relative to mid point
					worldCorners[ i ] -= worldMidPoint;
				}

				string matName = "Axiom/G2D/Debug";
				var mat = (Material)MaterialManager.Instance.GetByName( matName );
				if ( mat == null )
				{
					mat = (Material)MaterialManager.Instance.Create( matName, ResourceGroupManager.DefaultResourceGroupName );
					Pass pass = mat.GetTechnique( 0 ).GetPass( 0 );
					pass.LightingEnabled = false;
					pass.VertexColorTracking = TrackVertexColor.Ambient;
					pass.DepthWrite = false;
					mat.Load();
				}

				ManualObject mo = null;
				if ( sn.ChildCount == 0 )
				{
					mo = p.ParentSection.SceneManager.CreateManualObject();
					mo.Begin( matName, OperationType.LineStrip );
				}
				else
				{
					mo = (ManualObject)sn.GetObject( 0 );
					mo.BeginUpdate( 0 );
				}

				ColorEx vcol = ColorEx.Green;
				for ( int i = 0; i < 5; ++i )
				{
					mo.Position( worldCorners[ i%4 ] );
					mo.Color( vcol );
				}

				mo.End();

				if ( sn.ObjectCount == 0 )
				{
					sn.AttachObject( mo );
				}
			}
		}