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 bool FrameRenderingQueued(FrameEventArgs evt) { if (this.mode != Mode.Normal) { // fire ray Ray ray; ray = TrayManager.GetCursorRay(Camera); var rayResult = this.terrainGroup.RayIntersects(ray); if (rayResult.Hit) { this.editMarker.IsVisible = true; this.editNode.Position = rayResult.Position; // figure out which terrains this affects List <Axiom.Components.Terrain.Terrain> terrainList; var brushSizeWorldSpace = TerrainWorldSize * this.brushSizeTerrainSpace; var sphere = new Sphere(rayResult.Position, brushSizeWorldSpace); this.terrainGroup.SphereIntersects(sphere, out terrainList); foreach (var ti in terrainList) { DoTerrainModify(ti, rayResult.Position, evt.TimeSinceLastFrame); } } else { this.editMarker.IsVisible = false; } } if (!this.fly) { // clamp to terrain var camPos = Camera.Position; var ray = new Ray(new Vector3(camPos.x, this.terrainPos.y + 10000, camPos.z), Vector3.NegativeUnitY); TerrainGroup.RayResult rayResult = this.terrainGroup.RayIntersects(ray); Real distanceAboveTerrain = 50; Real fallSpeed = 300; Real newy = camPos.y; if (rayResult.Hit) { if (camPos.y > rayResult.Position.y + distanceAboveTerrain) { this.fallVelocity += evt.TimeSinceLastFrame * 20; this.fallVelocity = Utility.Min(this.fallVelocity, fallSpeed); newy = camPos.y - this.fallVelocity * evt.TimeSinceLastFrame; } newy = Utility.Max(rayResult.Position.y + distanceAboveTerrain, newy); Camera.Position = new Vector3(camPos.x, newy, camPos.z); } } if (this.heightUpdateCountDown > 0) { this.heightUpdateCountDown -= evt.TimeSinceLastFrame; if (this.heightUpdateCountDown <= 0) { this.terrainGroup.Update(); this.heightUpdateCountDown = 0; } } if (this.terrainGroup.IsDerivedDataUpdateInProgress) { TrayManager.MoveWidgetToTray(this.infoLabel, TrayLocation.Top, 0); this.infoLabel.Show(); if (this.terrainsImported) { this.infoLabel.Caption = "Building terrain, please wait..."; } else { this.infoLabel.Caption = "Updating textures, patience..."; } } else { TrayManager.RemoveWidgetFromTray(this.infoLabel); this.infoLabel.Hide(); if (this.terrainsImported) { SaveTerrains(true); this.terrainsImported = false; } } return(base.FrameRenderingQueued(evt)); }