void SetInitialCursorPos() { // first try to set the cursor where the mouse is var loc = m_game.MousePositionService.MapLocation; // then try the voxel in the center of the screen if (loc.HasValue == false) { IntVector3 pos; Direction face; var view = m_game.Surfaces[0].Views[0]; var center = new IntVector2((int)view.ViewPort.Width / 2, (int)view.ViewPort.Height / 2); var pickMode = ((MapControl3D)m_control).Config.PickMode; bool hit = MousePositionService.PickVoxel(m_game, center, pickMode, out pos, out face); if (hit) { loc = pos; } else { loc = null; } } this.Location = loc; }
public static bool PickVoxel(MyGame game, IntVector2 screenPos, MapControlPickMode pickMode, out IntVector3 pos, out Direction face) { return(MousePositionService.PickVoxel(game.Environment, game.Surfaces[0].Views[0], screenPos, game.ViewGridProvider.ViewGrid, pickMode, out pos, out face)); }