mirror of
https://github.com/riperiperi/Simitone.git
synced 2025-01-22 09:11:52 -05:00
[3D] Support 3D.
This commit is contained in:
parent
e719817dd5
commit
1dad877003
8 changed files with 90 additions and 33 deletions
|
@ -99,7 +99,8 @@ namespace Simitone.Client
|
|||
{
|
||||
AdvancedLighting = settings.Lighting,
|
||||
SmoothZoom = settings.SmoothZoom,
|
||||
SurroundingLots = settings.SurroundingLotMode
|
||||
SurroundingLots = settings.SurroundingLotMode,
|
||||
AA = settings.AntiAlias
|
||||
};
|
||||
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
|
|
|
@ -31,6 +31,7 @@ using FSO.Client;
|
|||
using FSO.Content;
|
||||
using FSO.Client.Debug;
|
||||
using Simitone.Client.UI.Screens;
|
||||
using FSO.LotView.RC;
|
||||
|
||||
namespace Simitone.Client.UI.Panels
|
||||
{
|
||||
|
@ -593,24 +594,34 @@ namespace Simitone.Client.UI.Panels
|
|||
if (!vm.Ready || vm.Context.Architecture == null) return;
|
||||
|
||||
//handling smooth scaled zoom
|
||||
float BaseScale;
|
||||
WorldZoom targetZoom;
|
||||
if (TargetZoom < 0.5f)
|
||||
if (FSOEnvironment.Enable3D)
|
||||
{
|
||||
targetZoom = WorldZoom.Far;
|
||||
BaseScale = 0.25f;
|
||||
} else if (TargetZoom < 1f)
|
||||
{
|
||||
targetZoom = WorldZoom.Medium;
|
||||
BaseScale = 0.5f;
|
||||
} else
|
||||
{
|
||||
targetZoom = WorldZoom.Near;
|
||||
BaseScale = 1f;
|
||||
var s3d = ((WorldStateRC)World.State);
|
||||
s3d.Zoom3D += ((9.75f - (TargetZoom-0.25f)*10) - s3d.Zoom3D) / 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
float BaseScale;
|
||||
WorldZoom targetZoom;
|
||||
if (TargetZoom < 0.5f)
|
||||
{
|
||||
targetZoom = WorldZoom.Far;
|
||||
BaseScale = 0.25f;
|
||||
}
|
||||
else if (TargetZoom < 1f)
|
||||
{
|
||||
targetZoom = WorldZoom.Medium;
|
||||
BaseScale = 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetZoom = WorldZoom.Near;
|
||||
BaseScale = 1f;
|
||||
}
|
||||
World.BackbufferScale = TargetZoom / BaseScale;
|
||||
if (World.State.Zoom != targetZoom) World.State.Zoom = targetZoom;
|
||||
WorldConfig.Current.SmoothZoom = false;
|
||||
}
|
||||
World.BackbufferScale = TargetZoom/BaseScale;
|
||||
if (World.State.Zoom != targetZoom) World.State.Zoom = targetZoom;
|
||||
WorldConfig.Current.SmoothZoom = false;
|
||||
|
||||
//Cheats.Update(state);
|
||||
//AvatarDS.Update();
|
||||
|
@ -770,8 +781,8 @@ namespace Simitone.Client.UI.Panels
|
|||
if (RMBScroll || !MouseIsOn) return;
|
||||
finalRooms = new HashSet<uint>(CutRooms);
|
||||
var newCut = new Rectangle((int)(mouseTilePos.X - 2.5), (int)(mouseTilePos.Y - 2.5), 5, 5);
|
||||
newCut.X -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][0] * 2;
|
||||
newCut.Y -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][1] * 2;
|
||||
newCut.X -= VMArchitectureTools.CutCheckDir[(int)World.State.CutRotation][0] * 2;
|
||||
newCut.Y -= VMArchitectureTools.CutCheckDir[(int)World.State.CutRotation][1] * 2;
|
||||
if (newCut != MouseCutRect)
|
||||
{
|
||||
MouseCutRect = newCut;
|
||||
|
@ -779,12 +790,12 @@ namespace Simitone.Client.UI.Panels
|
|||
}
|
||||
}
|
||||
|
||||
if (LastFloor != World.State.Level || LastRotation != World.State.Rotation || !finalRooms.SetEquals(LastCutRooms))
|
||||
if (LastFloor != World.State.Level || LastRotation != World.State.CutRotation || !finalRooms.SetEquals(LastCutRooms))
|
||||
{
|
||||
LastCuts = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.Rotation, finalRooms);
|
||||
LastCuts = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.CutRotation, finalRooms);
|
||||
recut = 2;
|
||||
LastFloor = World.State.Level;
|
||||
LastRotation = World.State.Rotation;
|
||||
LastRotation = World.State.CutRotation;
|
||||
}
|
||||
LastCutRooms = finalRooms;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ using FSO.Common;
|
|||
using FSO.HIT;
|
||||
using FSO.Client.UI.Model;
|
||||
using Simitone.Client.UI.Screens;
|
||||
using FSO.LotView.RC;
|
||||
using FSO.Common.Utils;
|
||||
|
||||
namespace Simitone.Client.UI.Panels
|
||||
{
|
||||
|
@ -32,6 +34,8 @@ namespace Simitone.Client.UI.Panels
|
|||
private Vector2 BaseVector;
|
||||
private float StartScale;
|
||||
private float RotateAngle;
|
||||
//for 3D rotate
|
||||
private float? LastAngleX;
|
||||
|
||||
private UIRotationAnimation RotationAnim;
|
||||
|
||||
|
@ -52,6 +56,7 @@ namespace Simitone.Client.UI.Panels
|
|||
private int ZoomFreezeTime;
|
||||
public override void Update(UpdateState state)
|
||||
{
|
||||
var _3d = FSOEnvironment.Enable3D;
|
||||
base.Update(state);
|
||||
bool rotated = false;
|
||||
|
||||
|
@ -66,7 +71,7 @@ namespace Simitone.Client.UI.Panels
|
|||
if (state.WindowFocused && state.MouseState.ScrollWheelValue != LastMouseWheel)
|
||||
{
|
||||
var diff = state.MouseState.ScrollWheelValue - LastMouseWheel;
|
||||
Master.TargetZoom = Master.TargetZoom + diff / 1000f;
|
||||
Master.TargetZoom = Master.TargetZoom + diff / 1600f;
|
||||
LastMouseWheel = state.MouseState.ScrollWheelValue;
|
||||
Master.TargetZoom = Math.Max(0.25f, Math.Min(Master.TargetZoom, 2));
|
||||
ZoomFreezeTime = 10;
|
||||
|
@ -113,6 +118,7 @@ namespace Simitone.Client.UI.Panels
|
|||
var m2 = state.MouseStates.FirstOrDefault(x => x.ID == MiceDown.ElementAt(1));
|
||||
BaseVector = (new Point(m2.MouseState.X, m2.MouseState.Y) - new Point(m1.MouseState.X, m1.MouseState.Y)).ToVector2();
|
||||
StartScale = Master.TargetZoom;
|
||||
if (_3d) LastAngleX = null;
|
||||
|
||||
//scroll anchor should change to center of two touches without drastically changing scroll
|
||||
TapPoint = (new Point(m2.MouseState.X / 2, m2.MouseState.Y / 2) + new Point(m1.MouseState.X / 2, m1.MouseState.Y / 2));
|
||||
|
@ -124,8 +130,14 @@ namespace Simitone.Client.UI.Panels
|
|||
if (Mode == 0)
|
||||
{
|
||||
ScrollVelocity = new Vector2();
|
||||
if (transitionTo == -1) Mode = -1;
|
||||
else {
|
||||
if (transitionTo == -1)
|
||||
{
|
||||
Mode = -1;
|
||||
var screenMiddle = new Point(GameFacade.Screens.CurrentUIScreen.ScreenWidth / 2, GameFacade.Screens.CurrentUIScreen.ScreenHeight / 2);
|
||||
Master.ShowPieMenu(((TapPoint - screenMiddle).ToVector2() / Master.World.BackbufferScale).ToPoint() + screenMiddle, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
var mouse = state.MouseStates.FirstOrDefault(x => x.ID == MiceDown.First());
|
||||
if ((TapPoint - new Point(mouse.MouseState.X, mouse.MouseState.Y)).ToVector2().Length() > TAP_POINT_DIST)
|
||||
{
|
||||
|
@ -185,18 +197,24 @@ namespace Simitone.Client.UI.Panels
|
|||
var a = BaseVector;
|
||||
var b = vector;
|
||||
a.Normalize(); b.Normalize();
|
||||
var clockwise = ((-a.Y)*b.X + a.X*b.Y) > 0;
|
||||
var clockwise = ((-a.Y) * b.X + a.X * b.Y) > 0;
|
||||
var angle = (float)Math.Acos(Vector2.Dot(a, b));
|
||||
RotateAngle = (clockwise) ? angle : -angle;
|
||||
|
||||
if (Math.Abs(RotateAngle) > Math.PI / 8) Master.TargetZoom = StartScale;
|
||||
if (_3d)
|
||||
{
|
||||
if (LastAngleX != null) ((WorldStateRC)Master.World.State).RotationX -= (float)DirectionUtils.Difference(RotateAngle, LastAngleX.Value);
|
||||
LastAngleX = RotateAngle;
|
||||
} else {
|
||||
if (Math.Abs(RotateAngle) > Math.PI / 8) Master.TargetZoom = StartScale;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (transitionTo == -1) Mode = -1;
|
||||
break;
|
||||
}
|
||||
if (Mode != 2 && RotateAngle != 0)
|
||||
if (Mode != 2 && RotateAngle != 0 && !_3d)
|
||||
{
|
||||
if (Math.Abs(RotateAngle) > Math.PI / 4)
|
||||
{
|
||||
|
@ -237,7 +255,7 @@ namespace Simitone.Client.UI.Panels
|
|||
if (Mode == -1)
|
||||
{
|
||||
ScrollVelocity *= 0.95f * Math.Min(ScrollVelocity.Length(), 1);
|
||||
if (Master.TargetZoom < 1.25f && ZoomFreezeTime == 0) {
|
||||
if (Master.TargetZoom < 1.25f && ZoomFreezeTime == 0 && !_3d) {
|
||||
float snapZoom = 1f;
|
||||
float dist = 200f;
|
||||
foreach (var snappable in SnapZooms)
|
||||
|
@ -265,7 +283,7 @@ namespace Simitone.Client.UI.Panels
|
|||
|
||||
UpdatesSinceDraw++;
|
||||
|
||||
if (Math.Abs(RotateAngle) > Math.PI / 8) //>20 degrees starts a rotation gesture. 40 degrees ends it.
|
||||
if (Math.Abs(RotateAngle) > Math.PI / 8 && !_3d) //>20 degrees starts a rotation gesture. 40 degrees ends it.
|
||||
{
|
||||
if (RotationAnim == null)
|
||||
{
|
||||
|
|
|
@ -284,5 +284,12 @@ namespace Simitone.Client.UI.Panels
|
|||
ShowingSelect = false;
|
||||
};
|
||||
}
|
||||
|
||||
public override void GameResized()
|
||||
{
|
||||
base.GameResized();
|
||||
if (PanelActive) CurWidth = Game.ScreenWidth - (64 + 15);
|
||||
HideButton.X = Game.ScreenWidth - (50 + 64 + 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Simitone.Client.UI.Panels
|
|||
btn.OnButtonClick += LiveButtonClicked;
|
||||
Add(btn);
|
||||
LiveButton = btn;
|
||||
|
||||
|
||||
ExtendPanelBtn.Position = new Vector2(btn.X + 54, btn.Y - 50);
|
||||
|
||||
MainPanel.X = 64 + 15;
|
||||
|
@ -153,6 +153,12 @@ namespace Simitone.Client.UI.Panels
|
|||
if (CutPanel != null) CutPanel.X = CutBtn.X - 39;
|
||||
Clock.X = Game.ScreenWidth - (334 + 15);
|
||||
Clock.Y = 15;
|
||||
|
||||
Money.Position = new Vector2(15, Game.ScreenHeight - 172);
|
||||
var btn = LiveButton;
|
||||
btn.Position = new Vector2(64 + 15, Game.ScreenHeight - (64 + 15));
|
||||
ExtendPanelBtn.Position = new Vector2(btn.X + 54, btn.Y - 50);
|
||||
MainPanel.Y = btn.Y - 64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,6 +270,9 @@ namespace Simitone.Client.UI.Screens
|
|||
{
|
||||
GameFacade.Game.IsFixedTimeStep = (vm == null || vm.Ready);
|
||||
|
||||
Visible = (World?.State as FSO.LotView.RC.WorldStateRC)?.CameraMode != true;
|
||||
GameFacade.Game.IsMouseVisible = Visible;
|
||||
|
||||
base.Update(state);
|
||||
if (state.NewKeys.Contains(Keys.NumPad1)) ChangeSpeedTo(1);
|
||||
if (state.NewKeys.Contains(Keys.NumPad2)) ChangeSpeedTo(2);
|
||||
|
@ -345,7 +348,14 @@ namespace Simitone.Client.UI.Screens
|
|||
{
|
||||
CleanupLastWorld();
|
||||
|
||||
World = new FSO.LotView.World(GameFacade.GraphicsDevice);
|
||||
if (FSOEnvironment.Enable3D)
|
||||
{
|
||||
World = new FSO.LotView.RC.WorldRC(GameFacade.GraphicsDevice);
|
||||
} else
|
||||
{
|
||||
World = new FSO.LotView.World(GameFacade.GraphicsDevice);
|
||||
}
|
||||
|
||||
World.Opacity = 1;
|
||||
GameFacade.Scenes.Add(World);
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ namespace Simitone.Windows
|
|||
case "ide":
|
||||
ide = true;
|
||||
break;
|
||||
case "3d":
|
||||
FSOEnvironment.Enable3D = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +75,7 @@ namespace Simitone.Windows
|
|||
GlobalSettings.Default.TS1HybridEnable = true;
|
||||
GlobalSettings.Default.TS1HybridPath = gameLocator.FindTheSims1();
|
||||
GlobalSettings.Default.ClientVersion = "0";
|
||||
GlobalSettings.Default.AntiAlias = true;
|
||||
|
||||
GameFacade.DirectX = useDX;
|
||||
World.DirectX = useDX;
|
||||
|
|
2
FreeSO
2
FreeSO
|
@ -1 +1 @@
|
|||
Subproject commit 59ae89d8fe7bc8929e2b06be9f88c6520340911e
|
||||
Subproject commit 169dd21da177a3e2e8a7fbb7082d92957e7b0e50
|
Loading…
Reference in a new issue