Fix skybox orientation in forward third person camera (Thanks goodlyay).

This commit is contained in:
UnknownShadow200 2016-07-14 16:15:36 +10:00
parent 7be81bea37
commit 309ba45a5d
5 changed files with 73 additions and 63 deletions

View file

@ -251,6 +251,7 @@
<Compile Include="Math\IntersectionUtils.cs" />
<Compile Include="Math\PickedPos.cs" />
<Compile Include="Math\Picking.cs" />
<Compile Include="Platform\DesktopWindow.cs" />
<Compile Include="Platform\Font.cs" />
<Compile Include="Platform\IPlatformWindow.cs" />
<Compile Include="Platform\Platform.cs" />

View file

@ -137,7 +137,7 @@ namespace ClassicalSharp {
foreach( IGameComponent comp in Components )
comp.Ready( this );
LoadIcon();
window.LoadIcon();
string connectString = "Connecting to " + IPAddress + ":" + Port + "..";
if( Graphics.WarnIfNecessary( Chat ) ) {
MapBordersRenderer.UseLegacyMode( true );
@ -211,17 +211,6 @@ namespace ClassicalSharp {
}
}
void LoadIcon() {
string launcherPath = PathIO.Combine( Program.AppDirectory, "Launcher2.exe" );
if( File.Exists( launcherPath ) ) {
window.Icon = Icon.ExtractAssociatedIcon( launcherPath ); return;
}
launcherPath = PathIO.Combine( Program.AppDirectory, "Launcher.exe" );
if( File.Exists( launcherPath ) ) {
window.Icon = Icon.ExtractAssociatedIcon( launcherPath );
}
}
void OnNewMapCore( object sender, EventArgs e ) {
foreach( IGameComponent comp in Components )
comp.OnNewMap( this );

View file

@ -0,0 +1,68 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using System.Drawing;
using System.IO;
using OpenTK;
using OpenTK.Graphics;
using Clipboard = System.Windows.Forms.Clipboard;
namespace ClassicalSharp {
/// <summary> Implementation of a native window and native input handling mechanism on Windows, OSX, and Linux. </summary>
public sealed class DesktopWindow : GameWindow, IPlatformWindow {
Game game;
public DesktopWindow( Game game, string username, bool nullContext, int width, int height ) :
base( width, height, GraphicsMode.Default, Program.AppName + " (" + username + ")", nullContext, 0, DisplayDevice.Default ) {
this.game = game;
}
protected override void OnLoad( EventArgs e ) {
game.OnLoad();
base.OnLoad( e );
}
public override void Dispose() {
game.Dispose();
base.Dispose();
}
protected override void OnRenderFrame( FrameEventArgs e ) {
game.RenderFrame( e.Time );
base.OnRenderFrame( e );
}
protected override void OnResize( object sender, EventArgs e ) {
game.OnResize();
base.OnResize( sender, e );
}
public void LoadIcon() {
string launcherPath = Path.Combine( Program.AppDirectory, "Launcher2.exe" );
if( File.Exists( launcherPath ) ) {
Icon = Icon.ExtractAssociatedIcon( launcherPath ); return;
}
launcherPath = Path.Combine( Program.AppDirectory, "Launcher.exe" );
if( File.Exists( launcherPath ) ) {
Icon = Icon.ExtractAssociatedIcon( launcherPath );
}
}
// TODO: retry when clipboard returns null.
public string ClipboardText {
get {
if ( OpenTK.Configuration.RunningOnMacOS )
return GetClipboardText();
else
return Clipboard.GetText();
}
set {
if ( OpenTK.Configuration.RunningOnMacOS )
SetClipboardText( value );
else
Clipboard.SetText( value );
}
}
}
}

View file

@ -2,10 +2,8 @@
using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using OpenTK.Platform;
using Clipboard = System.Windows.Forms.Clipboard;
namespace ClassicalSharp {
@ -30,8 +28,6 @@ namespace ClassicalSharp {
KeyboardDevice Keyboard { get; }
Icon Icon { get; set; }
Point PointToScreen( Point coords );
WindowState WindowState { get; set; }
@ -40,6 +36,8 @@ namespace ClassicalSharp {
string ClipboardText { get; set; }
void LoadIcon();
void Run();
void SwapBuffers();
@ -48,50 +46,4 @@ namespace ClassicalSharp {
event EventHandler<KeyPressEventArgs> KeyPress;
}
/// <summary> Implementation of a native window and native input handling mechanism on Windows, OSX, and Linux. </summary>
public sealed class DesktopWindow : GameWindow, IPlatformWindow {
Game game;
public DesktopWindow( Game game, string username, bool nullContext, int width, int height ) :
base( width, height, GraphicsMode.Default, Program.AppName + " (" + username + ")", nullContext, 0, DisplayDevice.Default ) {
this.game = game;
}
protected override void OnLoad( EventArgs e ) {
game.OnLoad();
base.OnLoad( e );
}
public override void Dispose() {
game.Dispose();
base.Dispose();
}
protected override void OnRenderFrame( FrameEventArgs e ) {
game.RenderFrame( e.Time );
base.OnRenderFrame( e );
}
protected override void OnResize( object sender, EventArgs e ) {
game.OnResize();
base.OnResize( sender, e );
}
// TODO: retry when clipboard returns null.
public string ClipboardText {
get {
if ( OpenTK.Configuration.RunningOnMacOS )
return GetClipboardText();
else
return Clipboard.GetText();
}
set {
if ( OpenTK.Configuration.RunningOnMacOS )
SetClipboardText( value );
else
Clipboard.SetText( value );
}
}
}
}

View file

@ -170,7 +170,7 @@ namespace ClassicalSharp {
}
public override Vector2 GetCameraOrientation() {
return new Vector2( player.HeadYawRadians, -player.PitchRadians );
return new Vector2( -player.HeadYawRadians, -player.PitchRadians );
}
float dist = 3;