public override bool FrameRenderingQueued( FrameEventArgs evt ) { // shoot a ray from the cursor to the plane var ray = TrayManager.GetCursorRay( Camera ); this.mCursorQuery.Ray = ray; var result = this.mCursorQuery.Execute(); if ( result.Count != 0 ) { // using the point of intersection, find the corresponding texel on our texture var pt = ray.GetPoint( result[ result.Count - 1 ].Distance ); this.mBrushPos = ( ( new Vector2( pt.x, -pt.y ) )*( 1.0f/this.mPlaneSize ) + ( new Vector2( 0.5, 0.5 ) ) )* TEXTURE_SIZE; } byte freezeAmount = 0; this.mTimeSinceLastFreeze += evt.TimeSinceLastFrame; // find out how much to freeze the plane based on time passed while ( this.mTimeSinceLastFreeze >= 0.1 ) { this.mTimeSinceLastFreeze -= 0.1; freezeAmount += 0x04; } _updateTexture( freezeAmount ); // rebuild texture contents this.mPenguinAnimState.AddTime( evt.TimeSinceLastFrame ); // increment penguin idle animation time this.mPenguinNode.Yaw( (Real)( new Radian( (Real)evt.TimeSinceLastFrame ) ) ); // spin the penguin around return base.FrameRenderingQueued( evt ); // don't forget the parent class updates! }
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 ); } } }
/// <summary> /// /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> public void SetCorners(Math.Vector2 topLeft, Math.Vector2 bottomRight) { SetCorners(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); }
void btn_CursorPressed( object sender, Vector2 cursorPosition ) { Button btn = sender as Button; if ( btn != null && btn.Name == "PageButtonControl" ) ChangePage( -1 ); }