mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 06:52:55 +08:00
Refactored rendering and input code, added show skeletons option to WorldForm
This commit is contained in:
parent
91712e7867
commit
77e9c0566f
@ -344,6 +344,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GameFiles\Resources\RpfFile.cs" />
|
||||
<Compile Include="Rendering\DirectX\DXUtility.cs" />
|
||||
<Compile Include="Rendering\Renderer.cs" />
|
||||
<Compile Include="Rendering\Shaders\BasicShader.cs" />
|
||||
<Compile Include="Rendering\Shaders\BoundsShader.cs" />
|
||||
<Compile Include="Rendering\Shaders\CableShader.cs" />
|
||||
@ -392,6 +393,8 @@
|
||||
</Compile>
|
||||
<Compile Include="Utils\Cache.cs" />
|
||||
<Compile Include="Utils\DDSIO.cs" />
|
||||
<Compile Include="Utils\InputUtils.cs" />
|
||||
<Compile Include="Utils\MapUtils.cs" />
|
||||
<Compile Include="Utils\Matrices.cs" />
|
||||
<Compile Include="Utils\Quaternions.cs" />
|
||||
<Compile Include="Utils\TextureLoader.cs" />
|
||||
|
@ -90,9 +90,9 @@ namespace CodeWalker
|
||||
{
|
||||
if (FileCache.IsInited)
|
||||
{
|
||||
FileCache.ContentThreadProc();
|
||||
bool fcItemsPending = FileCache.ContentThreadProc();
|
||||
|
||||
if (!FileCache.ItemsStillPending)
|
||||
if (!fcItemsPending)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
24
Forms/ModelForm.Designer.cs
generated
24
Forms/ModelForm.Designer.cs
generated
@ -51,7 +51,7 @@
|
||||
this.label19 = new System.Windows.Forms.Label();
|
||||
this.TimeOfDayTrackBar = new System.Windows.Forms.TrackBar();
|
||||
this.ControlLightDirCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ShowBoundsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ShowCollisionMeshesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.GridCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.GridCountComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
@ -258,7 +258,7 @@
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.label19);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.TimeOfDayTrackBar);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.ControlLightDirCheckBox);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.ShowBoundsCheckBox);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.ShowCollisionMeshesCheckBox);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.GridCheckBox);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.GridCountComboBox);
|
||||
this.ToolsOptionsTabPage.Controls.Add(this.label2);
|
||||
@ -341,16 +341,16 @@
|
||||
this.ControlLightDirCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ControlLightDirCheckBox.CheckedChanged += new System.EventHandler(this.ControlLightDirCheckBox_CheckedChanged);
|
||||
//
|
||||
// ShowBoundsCheckBox
|
||||
// ShowCollisionMeshesCheckBox
|
||||
//
|
||||
this.ShowBoundsCheckBox.AutoSize = true;
|
||||
this.ShowBoundsCheckBox.Location = new System.Drawing.Point(19, 176);
|
||||
this.ShowBoundsCheckBox.Name = "ShowBoundsCheckBox";
|
||||
this.ShowBoundsCheckBox.Size = new System.Drawing.Size(124, 17);
|
||||
this.ShowBoundsCheckBox.TabIndex = 7;
|
||||
this.ShowBoundsCheckBox.Text = "Show Model Bounds";
|
||||
this.ShowBoundsCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ShowBoundsCheckBox.CheckedChanged += new System.EventHandler(this.ShowBoundsCheckBox_CheckedChanged);
|
||||
this.ShowCollisionMeshesCheckBox.AutoSize = true;
|
||||
this.ShowCollisionMeshesCheckBox.Location = new System.Drawing.Point(19, 176);
|
||||
this.ShowCollisionMeshesCheckBox.Name = "ShowCollisionMeshesCheckBox";
|
||||
this.ShowCollisionMeshesCheckBox.Size = new System.Drawing.Size(132, 17);
|
||||
this.ShowCollisionMeshesCheckBox.TabIndex = 7;
|
||||
this.ShowCollisionMeshesCheckBox.Text = "Show collision meshes";
|
||||
this.ShowCollisionMeshesCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ShowCollisionMeshesCheckBox.CheckedChanged += new System.EventHandler(this.ShowCollisionMeshesCheckBox_CheckedChanged);
|
||||
//
|
||||
// GridCheckBox
|
||||
//
|
||||
@ -681,7 +681,7 @@
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ComboBox GridSizeComboBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.CheckBox ShowBoundsCheckBox;
|
||||
private System.Windows.Forms.CheckBox ShowCollisionMeshesCheckBox;
|
||||
private System.Windows.Forms.CheckBox ControlLightDirCheckBox;
|
||||
private System.Windows.Forms.Label TimeOfDayLabel;
|
||||
private System.Windows.Forms.Label label19;
|
||||
|
1623
Forms/ModelForm.cs
1623
Forms/ModelForm.cs
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,6 @@ namespace CodeWalker.GameFiles
|
||||
private Action<string> ErrorLog;
|
||||
public long CurrentMemoryUsage = 0;
|
||||
public int MaxItemsPerLoop = 1; //to keep things flowing...
|
||||
public bool ItemsStillPending = false; //whether or not we need another content thread loop
|
||||
|
||||
private ConcurrentStack<GameFile> requestQueue = new ConcurrentStack<GameFile>();
|
||||
|
||||
@ -1842,7 +1841,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
|
||||
|
||||
public void ContentThreadProc()
|
||||
public bool ContentThreadProc()
|
||||
{
|
||||
Monitor.Enter(updateSyncRoot);
|
||||
|
||||
@ -1912,10 +1911,14 @@ namespace CodeWalker.GameFiles
|
||||
//loadedsomething = true;
|
||||
}
|
||||
|
||||
ItemsStillPending = (itemcount >= MaxItemsPerLoop);
|
||||
//whether or not we need another content thread loop
|
||||
bool itemsStillPending = (itemcount >= MaxItemsPerLoop);
|
||||
|
||||
|
||||
Monitor.Exit(updateSyncRoot);
|
||||
|
||||
|
||||
return itemsStillPending;
|
||||
}
|
||||
|
||||
|
||||
@ -1991,6 +1994,75 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
|
||||
|
||||
public DrawableBase TryGetDrawable(Archetype arche)
|
||||
{
|
||||
if (arche == null) return null;
|
||||
uint drawhash = arche.Hash;
|
||||
DrawableBase drawable = null;
|
||||
if ((arche.DrawableDict != 0))// && (arche.DrawableDict != arche.Hash))
|
||||
{
|
||||
//try get drawable from ydd...
|
||||
YddFile ydd = GetYdd(arche.DrawableDict);
|
||||
if (ydd != null)
|
||||
{
|
||||
if (ydd.Loaded && (ydd.Dict != null))
|
||||
{
|
||||
Drawable d;
|
||||
ydd.Dict.TryGetValue(drawhash, out d); //can't out to base class?
|
||||
drawable = d;
|
||||
if (drawable == null)
|
||||
{
|
||||
return null; //drawable wasn't in dict!!
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null; //ydd not loaded yet, or has no dict
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//return null; //couldn't find drawable dict... quit now?
|
||||
}
|
||||
}
|
||||
if (drawable == null)
|
||||
{
|
||||
//try get drawable from ydr.
|
||||
YdrFile ydr = GetYdr(drawhash);
|
||||
if (ydr != null)
|
||||
{
|
||||
if (ydr.Loaded)
|
||||
{
|
||||
drawable = ydr.Drawable;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
YftFile yft = GetYft(drawhash);
|
||||
if (yft != null)
|
||||
{
|
||||
if (yft.Loaded)
|
||||
{
|
||||
if (yft.Fragment != null)
|
||||
{
|
||||
drawable = yft.Fragment.Drawable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private string[] GetExcludePaths()
|
||||
|
@ -21,7 +21,6 @@ namespace CodeWalker.Rendering
|
||||
public double CacheTime = Settings.Default.GPUCacheTime;// 10.0; //seconds to keep something that's not used
|
||||
public double UnloadTime = Settings.Default.GPUCacheFlushTime;// 0.1; //seconds between running unload cycles
|
||||
public int MaxItemsPerLoop = 1; //to keep things flowing
|
||||
public bool ItemsStillPending = false; //whether or not we need another content thread loop
|
||||
|
||||
public long TotalGraphicsMemoryUse
|
||||
{
|
||||
@ -92,9 +91,9 @@ namespace CodeWalker.Rendering
|
||||
waterquads.Clear();
|
||||
}
|
||||
|
||||
public void ContentThreadProc()
|
||||
public bool ContentThreadProc()
|
||||
{
|
||||
if (currentDevice == null) return; //can't do anything with no device
|
||||
if (currentDevice == null) return false; //can't do anything with no device
|
||||
|
||||
Monitor.Enter(updateSyncRoot);
|
||||
|
||||
@ -109,13 +108,14 @@ namespace CodeWalker.Rendering
|
||||
int waterquadcount = waterquads.LoadProc(currentDevice, MaxItemsPerLoop);
|
||||
|
||||
|
||||
ItemsStillPending = (renderablecount >= MaxItemsPerLoop) ||
|
||||
(texturecount >= MaxItemsPerLoop) ||
|
||||
(boundcompcount >= MaxItemsPerLoop) ||
|
||||
(instbatchcount >= MaxItemsPerLoop) ||
|
||||
(distlodlightcount >= MaxItemsPerLoop) ||
|
||||
(pathbatchcount >= MaxItemsPerLoop) ||
|
||||
(waterquadcount >= MaxItemsPerLoop);
|
||||
bool itemsStillPending =
|
||||
(renderablecount >= MaxItemsPerLoop) ||
|
||||
(texturecount >= MaxItemsPerLoop) ||
|
||||
(boundcompcount >= MaxItemsPerLoop) ||
|
||||
(instbatchcount >= MaxItemsPerLoop) ||
|
||||
(distlodlightcount >= MaxItemsPerLoop) ||
|
||||
(pathbatchcount >= MaxItemsPerLoop) ||
|
||||
(waterquadcount >= MaxItemsPerLoop);
|
||||
|
||||
|
||||
//todo: change this to unload only when necessary (ie when something is loaded)
|
||||
@ -141,6 +141,8 @@ namespace CodeWalker.Rendering
|
||||
LastUpdate = DateTime.UtcNow;
|
||||
|
||||
Monitor.Exit(updateSyncRoot);
|
||||
|
||||
return itemsStillPending;
|
||||
}
|
||||
|
||||
public void RenderThreadSync()
|
||||
|
2658
Rendering/Renderer.cs
Normal file
2658
Rendering/Renderer.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -730,7 +730,7 @@ namespace CodeWalker.Rendering
|
||||
|
||||
|
||||
|
||||
public void Enqueue(RenderableGeometryInst geom)
|
||||
public void Enqueue(ref RenderableGeometryInst geom)
|
||||
{
|
||||
var shader = geom.Geom.DrawableGeom.Shader;
|
||||
|
||||
@ -751,11 +751,11 @@ namespace CodeWalker.Rendering
|
||||
|
||||
batch.Geometries.Add(geom);
|
||||
}
|
||||
public void Enqueue(RenderableBoundGeometryInst geom)
|
||||
public void Enqueue(ref RenderableBoundGeometryInst geom)
|
||||
{
|
||||
RenderBoundGeoms.Add(geom);
|
||||
}
|
||||
public void Enqueue(RenderableInstanceBatchInst batch)
|
||||
public void Enqueue(ref RenderableInstanceBatchInst batch)
|
||||
{
|
||||
RenderInstBatches.Add(batch);
|
||||
}
|
||||
|
336
Utils/InputUtils.cs
Normal file
336
Utils/InputUtils.cs
Normal file
@ -0,0 +1,336 @@
|
||||
using CodeWalker.Properties;
|
||||
using SharpDX;
|
||||
using SharpDX.XInput;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CodeWalker
|
||||
{
|
||||
|
||||
|
||||
|
||||
public class InputManager
|
||||
{
|
||||
public Controller xbcontroller = null;
|
||||
public State xbcontrollerstate;
|
||||
public State xbcontrollerstateprev;
|
||||
public Vector4 xbmainaxes = Vector4.Zero;
|
||||
public Vector4 xbmainaxesprev = Vector4.Zero;
|
||||
public Vector2 xbtrigs = Vector2.Zero;
|
||||
public Vector2 xbtrigsprev = Vector2.Zero;
|
||||
public float xbcontrolvelocity = 0.0f;
|
||||
|
||||
public bool xbenable = false;
|
||||
public float xblx = 0; //left stick X axis
|
||||
public float xbly = 0; //left stick Y axis
|
||||
public float xbrx = 0; //right stick X axis
|
||||
public float xbry = 0; //right stick Y axis
|
||||
public float xblt = 0; //left trigger value
|
||||
public float xbrt = 0; //right trigger value
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public volatile bool kbmovefwd = false;
|
||||
public volatile bool kbmovebck = false;
|
||||
public volatile bool kbmovelft = false;
|
||||
public volatile bool kbmovergt = false;
|
||||
public volatile bool kbmoveup = false;
|
||||
public volatile bool kbmovedn = false;
|
||||
public volatile bool kbjump = false;
|
||||
public volatile bool kbmoving = false;
|
||||
|
||||
public KeyBindings keyBindings = new KeyBindings(Settings.Default.KeyBindings);
|
||||
|
||||
public bool CtrlPressed = false;
|
||||
public bool ShiftPressed = false;
|
||||
|
||||
|
||||
|
||||
|
||||
public void Init()
|
||||
{
|
||||
xbcontroller = new Controller(UserIndex.One);
|
||||
if (!xbcontroller.IsConnected)
|
||||
{
|
||||
var controllers = new[] { new Controller(UserIndex.Two), new Controller(UserIndex.Three), new Controller(UserIndex.Four) };
|
||||
foreach (var selectControler in controllers)
|
||||
{
|
||||
if (selectControler.IsConnected)
|
||||
{
|
||||
xbcontroller = selectControler;
|
||||
xbcontrollerstate = xbcontroller.GetState();
|
||||
xbcontrollerstateprev = xbcontrollerstate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xbcontrollerstate = xbcontroller.GetState();
|
||||
xbcontrollerstateprev = xbcontrollerstate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Update(float elapsed)
|
||||
{
|
||||
if (elapsed > 0.1f) elapsed = 0.1f;
|
||||
|
||||
var s = Settings.Default;
|
||||
|
||||
xbenable = (xbcontroller != null) && (xbcontroller.IsConnected);
|
||||
xblx = 0; xbly = 0; xbrx = 0; xbry = 0; xblt = 0; xbrt = 0; //input axes
|
||||
|
||||
if (xbenable)
|
||||
{
|
||||
xbcontrollerstateprev = xbcontrollerstate;
|
||||
xbcontrollerstate = xbcontroller.GetState();
|
||||
xbmainaxesprev = xbmainaxes;
|
||||
xbtrigsprev = xbtrigs;
|
||||
xbmainaxes = ControllerMainAxes();
|
||||
xbtrigs = ControllerTriggers();
|
||||
xblx = xbmainaxes.X;
|
||||
xbly = xbmainaxes.Y;
|
||||
xbrx = xbmainaxes.Z;
|
||||
xbry = xbmainaxes.W;
|
||||
xblt = xbtrigs.X;
|
||||
xbrt = xbtrigs.Y;
|
||||
float lamt = s.XInputLThumbSensitivity * elapsed;
|
||||
float ramt = s.XInputRThumbSensitivity * elapsed;
|
||||
xbly = s.XInputLThumbInvert ? xbly : -xbly;
|
||||
xbry = s.XInputRThumbInvert ? xbry : -xbry;
|
||||
xblx *= lamt;
|
||||
xbly *= lamt;
|
||||
xbrx *= ramt;
|
||||
xbry *= ramt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void KeyDown(KeyEventArgs e, bool enablemove)
|
||||
{
|
||||
var k = e.KeyCode;
|
||||
CtrlPressed = (e.Modifiers & Keys.Control) > 0;
|
||||
ShiftPressed = (e.Modifiers & Keys.Shift) > 0;
|
||||
|
||||
//enablemove = enablemove && (!ctrl);
|
||||
|
||||
//WASD move...
|
||||
if (enablemove)
|
||||
{
|
||||
if (k == keyBindings.MoveForward) kbmovefwd = true;
|
||||
if (k == keyBindings.MoveBackward) kbmovebck = true;
|
||||
if (k == keyBindings.MoveLeft) kbmovelft = true;
|
||||
if (k == keyBindings.MoveRight) kbmovergt = true;
|
||||
if (k == keyBindings.MoveUp) kbmoveup = true;
|
||||
if (k == keyBindings.MoveDown) kbmovedn = true;
|
||||
if (k == keyBindings.Jump) kbjump = true;
|
||||
}
|
||||
|
||||
kbmoving = kbmovefwd || kbmovebck || kbmovelft || kbmovergt || kbmoveup || kbmovedn || kbjump;
|
||||
|
||||
}
|
||||
|
||||
public void KeyUp(KeyEventArgs e)
|
||||
{
|
||||
CtrlPressed = (e.Modifiers & Keys.Control) > 0;
|
||||
ShiftPressed = (e.Modifiers & Keys.Shift) > 0;
|
||||
|
||||
var k = e.KeyCode;
|
||||
if (k == keyBindings.MoveForward) kbmovefwd = false;
|
||||
if (k == keyBindings.MoveBackward) kbmovebck = false;
|
||||
if (k == keyBindings.MoveLeft) kbmovelft = false;
|
||||
if (k == keyBindings.MoveRight) kbmovergt = false;
|
||||
if (k == keyBindings.MoveUp) kbmoveup = false;
|
||||
if (k == keyBindings.MoveDown) kbmovedn = false;
|
||||
if (k == keyBindings.Jump) kbjump = false;
|
||||
|
||||
kbmoving = kbmovefwd || kbmovebck || kbmovelft || kbmovergt || kbmoveup || kbmovedn || kbjump;
|
||||
|
||||
}
|
||||
|
||||
public void KeyboardStop()
|
||||
{
|
||||
kbmovefwd = false;
|
||||
kbmovebck = false;
|
||||
kbmovelft = false;
|
||||
kbmovergt = false;
|
||||
kbmoveup = false;
|
||||
kbmovedn = false;
|
||||
kbjump = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Vector3 KeyboardMoveVec(bool mapview = false)
|
||||
{
|
||||
Vector3 movevec = Vector3.Zero;
|
||||
if (mapview)
|
||||
{
|
||||
if (kbmovefwd) movevec.Y += 1.0f;
|
||||
if (kbmovebck) movevec.Y -= 1.0f;
|
||||
if (kbmovelft) movevec.X -= 1.0f;
|
||||
if (kbmovergt) movevec.X += 1.0f;
|
||||
if (kbmoveup) movevec.Y += 1.0f;
|
||||
if (kbmovedn) movevec.Y -= 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (kbmovefwd) movevec.Z -= 1.0f;
|
||||
if (kbmovebck) movevec.Z += 1.0f;
|
||||
if (kbmovelft) movevec.X -= 1.0f;
|
||||
if (kbmovergt) movevec.X += 1.0f;
|
||||
if (kbmoveup) movevec.Y += 1.0f;
|
||||
if (kbmovedn) movevec.Y -= 1.0f;
|
||||
}
|
||||
return movevec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Vector4 ControllerMainAxes()
|
||||
{
|
||||
var gp = xbcontrollerstate.Gamepad;
|
||||
var ldz = Gamepad.LeftThumbDeadZone;
|
||||
var rdz = Gamepad.RightThumbDeadZone;
|
||||
float ltnrng = -(short.MinValue + ldz);
|
||||
float ltprng = (short.MaxValue - ldz);
|
||||
float rtnrng = -(short.MinValue + rdz);
|
||||
float rtprng = (short.MaxValue - rdz);
|
||||
|
||||
float lx = (gp.LeftThumbX < 0) ? Math.Min((gp.LeftThumbX + ldz) / ltnrng, 0) :
|
||||
(gp.LeftThumbX > 0) ? Math.Max((gp.LeftThumbX - ldz) / ltprng, 0) : 0;
|
||||
float ly = (gp.LeftThumbY < 0) ? Math.Min((gp.LeftThumbY + ldz) / ltnrng, 0) :
|
||||
(gp.LeftThumbY > 0) ? Math.Max((gp.LeftThumbY - ldz) / ltprng, 0) : 0;
|
||||
float rx = (gp.RightThumbX < 0) ? Math.Min((gp.RightThumbX + rdz) / rtnrng, 0) :
|
||||
(gp.RightThumbX > 0) ? Math.Max((gp.RightThumbX - rdz) / rtprng, 0) : 0;
|
||||
float ry = (gp.RightThumbY < 0) ? Math.Min((gp.RightThumbY + rdz) / rtnrng, 0) :
|
||||
(gp.RightThumbY > 0) ? Math.Max((gp.RightThumbY - rdz) / rtprng, 0) : 0;
|
||||
|
||||
return new Vector4(lx, ly, rx, ry);
|
||||
}
|
||||
public Vector2 ControllerTriggers()
|
||||
{
|
||||
var gp = xbcontrollerstate.Gamepad;
|
||||
var tt = Gamepad.TriggerThreshold;
|
||||
float trng = byte.MaxValue - tt;
|
||||
float lt = Math.Max((gp.LeftTrigger - tt) / trng, 0);
|
||||
float rt = Math.Max((gp.RightTrigger - tt) / trng, 0);
|
||||
return new Vector2(lt, rt);
|
||||
}
|
||||
public bool ControllerButtonPressed(GamepadButtonFlags b)
|
||||
{
|
||||
return ((xbcontrollerstate.Gamepad.Buttons & b) != 0);
|
||||
}
|
||||
public bool ControllerButtonJustPressed(GamepadButtonFlags b)
|
||||
{
|
||||
return (((xbcontrollerstate.Gamepad.Buttons & b) != 0) && ((xbcontrollerstateprev.Gamepad.Buttons & b) == 0));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class KeyBindings
|
||||
{
|
||||
public Keys MoveForward = Keys.W;
|
||||
public Keys MoveBackward = Keys.S;
|
||||
public Keys MoveLeft = Keys.A;
|
||||
public Keys MoveRight = Keys.D;
|
||||
public Keys MoveUp = Keys.R;
|
||||
public Keys MoveDown = Keys.F;
|
||||
public Keys MoveSlowerZoomIn = Keys.Z;
|
||||
public Keys MoveFasterZoomOut = Keys.X;
|
||||
public Keys ToggleMouseSelect = Keys.C;
|
||||
public Keys ToggleToolbar = Keys.T;
|
||||
public Keys ExitEditMode = Keys.Q;
|
||||
public Keys EditPosition = Keys.W;
|
||||
public Keys EditRotation = Keys.E;
|
||||
public Keys EditScale = Keys.R;
|
||||
public Keys Jump = Keys.Space; //for control mode
|
||||
public Keys FirstPerson = Keys.P;
|
||||
|
||||
public KeyBindings(StringCollection sc)
|
||||
{
|
||||
foreach (string s in sc)
|
||||
{
|
||||
string[] parts = s.Split(':');
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
string sval = parts[1].Trim();
|
||||
Keys k = (Keys)Enum.Parse(typeof(Keys), sval);
|
||||
SetBinding(parts[0], k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBinding(string name, Keys k)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "Move Forwards": MoveForward = k; break;
|
||||
case "Move Backwards": MoveBackward = k; break;
|
||||
case "Move Left": MoveLeft = k; break;
|
||||
case "Move Right": MoveRight = k; break;
|
||||
case "Move Up": MoveUp = k; break;
|
||||
case "Move Down": MoveDown = k; break;
|
||||
case "Move Slower / Zoom In": MoveSlowerZoomIn = k; break;
|
||||
case "Move Faster / Zoom Out": MoveFasterZoomOut = k; break;
|
||||
case "Toggle Mouse Select": ToggleMouseSelect = k; break;
|
||||
case "Toggle Toolbar": ToggleToolbar = k; break;
|
||||
case "Exit Edit Mode": ExitEditMode = k; break;
|
||||
case "Edit Position": EditPosition = k; break;
|
||||
case "Edit Rotation": EditRotation = k; break;
|
||||
case "Edit Scale": EditScale = k; break;
|
||||
case "First Person Mode": FirstPerson = k; break;
|
||||
}
|
||||
}
|
||||
|
||||
public StringCollection GetSetting()
|
||||
{
|
||||
StringCollection sc = new StringCollection();
|
||||
sc.Add(GetSettingItem("Move Forwards", MoveForward));
|
||||
sc.Add(GetSettingItem("Move Backwards", MoveBackward));
|
||||
sc.Add(GetSettingItem("Move Left", MoveLeft));
|
||||
sc.Add(GetSettingItem("Move Right", MoveRight));
|
||||
sc.Add(GetSettingItem("Move Up", MoveUp));
|
||||
sc.Add(GetSettingItem("Move Down", MoveDown));
|
||||
sc.Add(GetSettingItem("Move Slower / Zoom In", MoveSlowerZoomIn));
|
||||
sc.Add(GetSettingItem("Move Faster / Zoom Out", MoveFasterZoomOut));
|
||||
sc.Add(GetSettingItem("Toggle Mouse Select", ToggleMouseSelect));
|
||||
sc.Add(GetSettingItem("Toggle Toolbar", ToggleToolbar));
|
||||
sc.Add(GetSettingItem("Exit Edit Mode", ExitEditMode));
|
||||
sc.Add(GetSettingItem("Edit Position", EditPosition));
|
||||
sc.Add(GetSettingItem("Edit Rotation", EditRotation));
|
||||
sc.Add(GetSettingItem("Edit Scale", EditScale));
|
||||
sc.Add(GetSettingItem("First Person Mode", FirstPerson));
|
||||
return sc;
|
||||
}
|
||||
|
||||
private string GetSettingItem(string name, Keys val)
|
||||
{
|
||||
return name + ": " + val.ToString();
|
||||
}
|
||||
|
||||
public KeyBindings Copy()
|
||||
{
|
||||
return (KeyBindings)MemberwiseClone();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
764
Utils/MapUtils.cs
Normal file
764
Utils/MapUtils.cs
Normal file
@ -0,0 +1,764 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using SharpDX;
|
||||
using SharpDX.Direct3D11;
|
||||
using CodeWalker.Utils;
|
||||
using CodeWalker.World;
|
||||
using CodeWalker.GameFiles;
|
||||
|
||||
namespace CodeWalker
|
||||
{
|
||||
|
||||
|
||||
public class MapIcon
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Filepath { get; set; }
|
||||
public Texture2D Tex { get; set; }
|
||||
public ShaderResourceView TexView { get; set; }
|
||||
public Vector3 Center { get; set; } //in image pixels
|
||||
public float Scale { get; set; } //screen pixels per icon pixel
|
||||
public int TexWidth { get; set; }
|
||||
public int TexHeight { get; set; }
|
||||
|
||||
public MapIcon(string name, string filepath, int texw, int texh, float centerx, float centery, float scale)
|
||||
{
|
||||
Name = name;
|
||||
Filepath = filepath;
|
||||
TexWidth = texw;
|
||||
TexHeight = texh;
|
||||
Center = new Vector3(centerx, centery, 0.0f);
|
||||
Scale = scale;
|
||||
|
||||
if (!File.Exists(filepath))
|
||||
{
|
||||
throw new Exception("File not found.");
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadTexture(Device device, Action<string> errorAction)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (device != null)
|
||||
{
|
||||
Tex = TextureLoader.CreateTexture2DFromBitmap(device, TextureLoader.LoadBitmap(new SharpDX.WIC.ImagingFactory2(), Filepath));
|
||||
TexView = new ShaderResourceView(device, Tex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorAction("Could not load map icon " + Filepath + " for " + Name + "!\n\n" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void UnloadTexture()
|
||||
{
|
||||
if (TexView != null)
|
||||
{
|
||||
TexView.Dispose();
|
||||
TexView = null;
|
||||
}
|
||||
if (Tex != null)
|
||||
{
|
||||
Tex.Dispose();
|
||||
Tex = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public class MapMarker
|
||||
{
|
||||
public MapIcon Icon { get; set; }
|
||||
public Vector3 WorldPos { get; set; } //actual world pos
|
||||
public Vector3 CamRelPos { get; set; } //updated per frame
|
||||
public Vector3 ScreenPos { get; set; } //position on screen (updated per frame)
|
||||
public string Name { get; set; }
|
||||
public List<string> Properties { get; set; } //additional data
|
||||
public bool IsMovable { get; set; }
|
||||
public float Distance { get; set; } //length of CamRelPos, updated per frame
|
||||
|
||||
public void Parse(string s)
|
||||
{
|
||||
Vector3 p = new Vector3(0.0f);
|
||||
string[] ss = s.Split(',');
|
||||
if (ss.Length > 1)
|
||||
{
|
||||
FloatUtil.TryParse(ss[0].Trim(), out p.X);
|
||||
FloatUtil.TryParse(ss[1].Trim(), out p.Y);
|
||||
}
|
||||
if (ss.Length > 2)
|
||||
{
|
||||
FloatUtil.TryParse(ss[2].Trim(), out p.Z);
|
||||
}
|
||||
if (ss.Length > 3)
|
||||
{
|
||||
Name = ss[3].Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = string.Empty;
|
||||
}
|
||||
for (int i = 4; i < ss.Length; i++)
|
||||
{
|
||||
if (Properties == null) Properties = new List<string>();
|
||||
Properties.Add(ss[i].Trim());
|
||||
}
|
||||
WorldPos = p;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string cstr = Get3DWorldPosString();
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
cstr += ", " + Name;
|
||||
if (Properties != null)
|
||||
{
|
||||
foreach (string prop in Properties)
|
||||
{
|
||||
cstr += ", " + prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cstr;
|
||||
}
|
||||
|
||||
public string Get2DWorldPosString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", WorldPos.X, WorldPos.Y);
|
||||
}
|
||||
public string Get3DWorldPosString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}, {1}, {2}", WorldPos.X, WorldPos.Y, WorldPos.Z);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public struct MapSphere
|
||||
{
|
||||
public Vector3 CamRelPos { get; set; }
|
||||
public float Radius { get; set; }
|
||||
}
|
||||
|
||||
public struct MapBox
|
||||
{
|
||||
public Vector3 CamRelPos { get; set; }
|
||||
public Vector3 BBMin { get; set; }
|
||||
public Vector3 BBMax { get; set; }
|
||||
public Quaternion Orientation { get; set; }
|
||||
public Vector3 Scale { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public struct MapSelection
|
||||
{
|
||||
public YmapEntityDef EntityDef { get; set; }
|
||||
public Archetype Archetype { get; set; }
|
||||
public DrawableBase Drawable { get; set; }
|
||||
public DrawableGeometry Geometry { get; set; }
|
||||
public MetaWrapper EntityExtension { get; set; }
|
||||
public MetaWrapper ArchetypeExtension { get; set; }
|
||||
public YmapTimeCycleModifier TimeCycleModifier { get; set; }
|
||||
public YmapCarGen CarGenerator { get; set; }
|
||||
public YmapGrassInstanceBatch GrassBatch { get; set; }
|
||||
public YmapDistantLODLights DistantLodLights { get; set; }
|
||||
public YmapEntityDef MloEntityDef { get; set; }
|
||||
public WaterQuad WaterQuad { get; set; }
|
||||
public Bounds CollisionBounds { get; set; }
|
||||
public YnvPoly NavPoly { get; set; }
|
||||
public YndNode PathNode { get; set; }
|
||||
public YndLink PathLink { get; set; }
|
||||
public TrainTrackNode TrainTrackNode { get; set; }
|
||||
public ScenarioNode ScenarioNode { get; set; }
|
||||
public MCScenarioChainingEdge ScenarioEdge { get; set; }
|
||||
public AudioPlacement Audio { get; set; }
|
||||
|
||||
public bool MultipleSelection { get; set; }
|
||||
public Vector3 MultipleSelectionCenter { get; set; }
|
||||
|
||||
public BoundingBox AABB { get; set; }
|
||||
public BoundingSphere BSphere { get; set; }
|
||||
public int GeometryIndex { get; set; }
|
||||
public Vector3 CamRel { get; set; }
|
||||
public float HitDist { get; set; }
|
||||
|
||||
|
||||
public bool HasValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return (EntityDef != null) ||
|
||||
(Archetype != null) ||
|
||||
(Drawable != null) ||
|
||||
(Geometry != null) ||
|
||||
(EntityExtension != null) ||
|
||||
(ArchetypeExtension != null) ||
|
||||
(TimeCycleModifier != null) ||
|
||||
(CarGenerator != null) ||
|
||||
(GrassBatch != null) ||
|
||||
(WaterQuad != null) ||
|
||||
(CollisionBounds != null) ||
|
||||
(NavPoly != null) ||
|
||||
(PathNode != null) ||
|
||||
(TrainTrackNode != null) ||
|
||||
(DistantLodLights != null) ||
|
||||
(MloEntityDef != null) ||
|
||||
(ScenarioNode != null) ||
|
||||
(Audio != null);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasHit
|
||||
{
|
||||
get { return (HitDist != float.MaxValue); }
|
||||
}
|
||||
|
||||
|
||||
public bool CheckForChanges(MapSelection mhit)
|
||||
{
|
||||
return (EntityDef != mhit.EntityDef)
|
||||
|| (Archetype != mhit.Archetype)
|
||||
|| (Drawable != mhit.Drawable)
|
||||
|| (TimeCycleModifier != mhit.TimeCycleModifier)
|
||||
|| (ArchetypeExtension != mhit.ArchetypeExtension)
|
||||
|| (EntityExtension != mhit.EntityExtension)
|
||||
|| (CarGenerator != mhit.CarGenerator)
|
||||
|| (MloEntityDef != mhit.MloEntityDef)
|
||||
|| (DistantLodLights != mhit.DistantLodLights)
|
||||
|| (GrassBatch != mhit.GrassBatch)
|
||||
|| (WaterQuad != mhit.WaterQuad)
|
||||
|| (CollisionBounds != mhit.CollisionBounds)
|
||||
|| (NavPoly != mhit.NavPoly)
|
||||
|| (PathNode != mhit.PathNode)
|
||||
|| (TrainTrackNode != mhit.TrainTrackNode)
|
||||
|| (ScenarioNode != mhit.ScenarioNode)
|
||||
|| (Audio != mhit.Audio);
|
||||
}
|
||||
public bool CheckForChanges()
|
||||
{
|
||||
return (EntityDef != null)
|
||||
|| (Archetype != null)
|
||||
|| (Drawable != null)
|
||||
|| (TimeCycleModifier != null)
|
||||
|| (ArchetypeExtension != null)
|
||||
|| (EntityExtension != null)
|
||||
|| (CarGenerator != null)
|
||||
|| (MloEntityDef != null)
|
||||
|| (DistantLodLights != null)
|
||||
|| (GrassBatch != null)
|
||||
|| (WaterQuad != null)
|
||||
|| (CollisionBounds != null)
|
||||
|| (NavPoly != null)
|
||||
|| (PathNode != null)
|
||||
|| (PathLink != null)
|
||||
|| (TrainTrackNode != null)
|
||||
|| (ScenarioNode != null)
|
||||
|| (Audio != null);
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
EntityDef = null;
|
||||
Archetype = null;
|
||||
Drawable = null;
|
||||
Geometry = null;
|
||||
EntityExtension = null;
|
||||
ArchetypeExtension = null;
|
||||
TimeCycleModifier = null;
|
||||
CarGenerator = null;
|
||||
GrassBatch = null;
|
||||
WaterQuad = null;
|
||||
CollisionBounds = null;
|
||||
NavPoly = null;
|
||||
PathNode = null;
|
||||
PathLink = null;
|
||||
TrainTrackNode = null;
|
||||
DistantLodLights = null;
|
||||
MloEntityDef = null;
|
||||
ScenarioNode = null;
|
||||
ScenarioEdge = null;
|
||||
Audio = null;
|
||||
MultipleSelection = false;
|
||||
AABB = new BoundingBox();
|
||||
GeometryIndex = 0;
|
||||
CamRel = new Vector3();
|
||||
HitDist = float.MaxValue;
|
||||
}
|
||||
|
||||
public string GetNameString(string defval)
|
||||
{
|
||||
string name = defval;
|
||||
if (MultipleSelection)
|
||||
{
|
||||
name = "Multiple items";
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
name = EntityDef.CEntityDef.archetypeName.ToString();
|
||||
}
|
||||
else if (Archetype != null)
|
||||
{
|
||||
name = Archetype.Hash.ToString();
|
||||
}
|
||||
else if (TimeCycleModifier != null)
|
||||
{
|
||||
name = TimeCycleModifier.CTimeCycleModifier.name.ToString();
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
name = CarGenerator.CCarGen.carModel.ToString();
|
||||
}
|
||||
else if (DistantLodLights != null)
|
||||
{
|
||||
name = DistantLodLights.Ymap?.Name ?? "";
|
||||
}
|
||||
else if (CollisionBounds != null)
|
||||
{
|
||||
name = CollisionBounds.GetName();
|
||||
}
|
||||
if (EntityExtension != null)
|
||||
{
|
||||
name = EntityExtension.Name;
|
||||
}
|
||||
if (ArchetypeExtension != null)
|
||||
{
|
||||
name = ArchetypeExtension.Name;
|
||||
}
|
||||
if (WaterQuad != null)
|
||||
{
|
||||
name = "WaterQuad " + WaterQuad.ToString();
|
||||
}
|
||||
if (NavPoly != null)
|
||||
{
|
||||
name = "NavPoly " + NavPoly.ToString();
|
||||
}
|
||||
if (PathNode != null)
|
||||
{
|
||||
name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString(); //+ FloatUtil.GetVector3String(PathNode.Position);
|
||||
}
|
||||
if (TrainTrackNode != null)
|
||||
{
|
||||
name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position);
|
||||
}
|
||||
if (ScenarioNode != null)
|
||||
{
|
||||
name = ScenarioNode.ToString();
|
||||
}
|
||||
if (Audio != null)
|
||||
{
|
||||
name = Audio.ShortTypeName + " " + Audio.GetNameString();// FloatUtil.GetVector3String(Audio.InnerPos);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public string GetFullNameString(string defval)
|
||||
{
|
||||
string name = defval;
|
||||
if (MultipleSelection)
|
||||
{
|
||||
name = "Multiple items";
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
name = EntityDef.CEntityDef.archetypeName.ToString();
|
||||
}
|
||||
else if (Archetype != null)
|
||||
{
|
||||
name = Archetype.Hash.ToString();
|
||||
}
|
||||
else if (CollisionBounds != null)
|
||||
{
|
||||
name = CollisionBounds.GetName();
|
||||
}
|
||||
if (Geometry != null)
|
||||
{
|
||||
name += " (" + GeometryIndex.ToString() + ")";
|
||||
}
|
||||
if (TimeCycleModifier != null)
|
||||
{
|
||||
name = TimeCycleModifier.CTimeCycleModifier.name.ToString();
|
||||
}
|
||||
if (CarGenerator != null)
|
||||
{
|
||||
name = CarGenerator.NameString();
|
||||
}
|
||||
if (EntityExtension != null)
|
||||
{
|
||||
name += ": " + EntityExtension.Name;
|
||||
}
|
||||
if (ArchetypeExtension != null)
|
||||
{
|
||||
name += ": " + ArchetypeExtension.Name;
|
||||
}
|
||||
if (WaterQuad != null)
|
||||
{
|
||||
name = "WaterQuad " + WaterQuad.ToString();
|
||||
}
|
||||
if (NavPoly != null)
|
||||
{
|
||||
name = "NavPoly " + NavPoly.ToString();
|
||||
}
|
||||
if (PathNode != null)
|
||||
{
|
||||
name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position);
|
||||
}
|
||||
if (TrainTrackNode != null)
|
||||
{
|
||||
name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position);
|
||||
}
|
||||
if (ScenarioNode != null)
|
||||
{
|
||||
name = ScenarioNode.ToString();
|
||||
}
|
||||
if (Audio != null)
|
||||
{
|
||||
name = Audio.ShortTypeName + " " + Audio.GetNameString();// + FloatUtil.GetVector3String(Audio.InnerPos);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool CanShowWidget
|
||||
{
|
||||
get
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (MultipleSelection)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
public Vector3 WidgetPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MultipleSelection)
|
||||
{
|
||||
return MultipleSelectionCenter;
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
return EntityDef.WidgetPosition;
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
return CarGenerator.Position;
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
return NavPoly.Position;
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
return PathNode.Position;
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
return TrainTrackNode.Position;
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
return ScenarioNode.Position;
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
return Audio.InnerPos;
|
||||
}
|
||||
return Vector3.Zero;
|
||||
}
|
||||
}
|
||||
public Quaternion WidgetRotation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MultipleSelection)
|
||||
{
|
||||
return Quaternion.Identity;
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
return EntityDef.WidgetOrientation;
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
return CarGenerator.Orientation;
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
return Quaternion.Identity;
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
return Quaternion.Identity;
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
return Quaternion.Identity;
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
return ScenarioNode.Orientation;
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
return Audio.Orientation;
|
||||
}
|
||||
return Quaternion.Identity;
|
||||
}
|
||||
}
|
||||
public WidgetAxis WidgetRotationAxes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MultipleSelection)
|
||||
{
|
||||
return WidgetAxis.XYZ;
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
return WidgetAxis.XYZ;
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
return WidgetAxis.Z;
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
return WidgetAxis.XYZ;
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
return WidgetAxis.None;
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
return WidgetAxis.None;
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
return WidgetAxis.Z;
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
return WidgetAxis.XYZ;
|
||||
}
|
||||
return WidgetAxis.None;
|
||||
}
|
||||
}
|
||||
public Vector3 WidgetScale
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MultipleSelection)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
return EntityDef.Scale;
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
return new Vector3(CarGenerator.CCarGen.perpendicularLength);
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
return Vector3.One;
|
||||
}
|
||||
return Vector3.One;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void SetPosition(Vector3 newpos, Vector3 oldpos, bool editPivot)
|
||||
{
|
||||
if (MultipleSelection)
|
||||
{
|
||||
//don't do anything here for multiselection
|
||||
}
|
||||
else if (EntityDef != null)
|
||||
{
|
||||
if (editPivot)
|
||||
{
|
||||
EntityDef.SetPivotPositionFromWidget(newpos);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityDef.SetPositionFromWidget(newpos);
|
||||
}
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
CarGenerator.SetPosition(newpos);
|
||||
}
|
||||
else if (PathNode != null)
|
||||
{
|
||||
PathNode.SetPosition(newpos);
|
||||
}
|
||||
else if (NavPoly != null)
|
||||
{
|
||||
//NavPoly.SetPosition(newpos);
|
||||
|
||||
//if (projectForm != null)
|
||||
//{
|
||||
// projectForm.OnWorldNavPolyModified(NavPoly);
|
||||
//}
|
||||
}
|
||||
else if (TrainTrackNode != null)
|
||||
{
|
||||
TrainTrackNode.SetPosition(newpos);
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
ScenarioNode.SetPosition(newpos);
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
Audio.SetPosition(newpos);
|
||||
}
|
||||
|
||||
}
|
||||
public void SetRotation(Quaternion newrot, Quaternion oldrot, bool editPivot)
|
||||
{
|
||||
if (EntityDef != null)
|
||||
{
|
||||
if (editPivot)
|
||||
{
|
||||
EntityDef.SetPivotOrientationFromWidget(newrot);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityDef.SetOrientationFromWidget(newrot);
|
||||
}
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
CarGenerator.SetOrientation(newrot);
|
||||
}
|
||||
else if (ScenarioNode != null)
|
||||
{
|
||||
ScenarioNode.SetOrientation(newrot);
|
||||
}
|
||||
else if (Audio != null)
|
||||
{
|
||||
Audio.SetOrientation(newrot);
|
||||
}
|
||||
}
|
||||
public void SetScale(Vector3 newscale, Vector3 oldscale, bool editPivot)
|
||||
{
|
||||
if (EntityDef != null)
|
||||
{
|
||||
EntityDef.SetScale(newscale);
|
||||
}
|
||||
else if (CarGenerator != null)
|
||||
{
|
||||
CarGenerator.SetScale(newscale);
|
||||
AABB = new BoundingBox(CarGenerator.BBMin, CarGenerator.BBMax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return GetFullNameString("[Empty]");
|
||||
}
|
||||
}
|
||||
|
||||
public enum MapSelectionMode
|
||||
{
|
||||
None = 0,
|
||||
Entity = 1,
|
||||
EntityExtension = 2,
|
||||
ArchetypeExtension = 3,
|
||||
TimeCycleModifier = 4,
|
||||
CarGenerator = 5,
|
||||
Grass = 6,
|
||||
WaterQuad = 7,
|
||||
Collision = 8,
|
||||
NavMesh = 9,
|
||||
Path = 10,
|
||||
TrainTrack = 11,
|
||||
DistantLodLights = 12,
|
||||
MloInstance = 13,
|
||||
Scenario = 14,
|
||||
PopZone = 15,
|
||||
Audio = 16,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -761,6 +761,8 @@ namespace CodeWalker.World
|
||||
if (!Inited) return;
|
||||
if (Grid == null) return;
|
||||
|
||||
if (elapsed > 0.1f) elapsed = 0.1f;
|
||||
|
||||
|
||||
Collisions.Clear();
|
||||
|
||||
|
24
WorldForm.Designer.cs
generated
24
WorldForm.Designer.cs
generated
@ -145,6 +145,7 @@ namespace CodeWalker
|
||||
this.WaitForChildrenCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.tabPage9 = new System.Windows.Forms.TabPage();
|
||||
this.SkeletonsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.AudioOuterBoundsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.PopZonesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.NavMeshesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
@ -1746,6 +1747,7 @@ namespace CodeWalker
|
||||
//
|
||||
// tabPage9
|
||||
//
|
||||
this.tabPage9.Controls.Add(this.SkeletonsCheckBox);
|
||||
this.tabPage9.Controls.Add(this.AudioOuterBoundsCheckBox);
|
||||
this.tabPage9.Controls.Add(this.PopZonesCheckBox);
|
||||
this.tabPage9.Controls.Add(this.NavMeshesCheckBox);
|
||||
@ -1774,15 +1776,26 @@ namespace CodeWalker
|
||||
this.tabPage9.Text = "Helpers";
|
||||
this.tabPage9.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SkeletonsCheckBox
|
||||
//
|
||||
this.SkeletonsCheckBox.AutoSize = true;
|
||||
this.SkeletonsCheckBox.Location = new System.Drawing.Point(10, 411);
|
||||
this.SkeletonsCheckBox.Name = "SkeletonsCheckBox";
|
||||
this.SkeletonsCheckBox.Size = new System.Drawing.Size(101, 17);
|
||||
this.SkeletonsCheckBox.TabIndex = 53;
|
||||
this.SkeletonsCheckBox.Text = "Show skeletons";
|
||||
this.SkeletonsCheckBox.UseVisualStyleBackColor = true;
|
||||
this.SkeletonsCheckBox.CheckedChanged += new System.EventHandler(this.SkeletonsCheckBox_CheckedChanged);
|
||||
//
|
||||
// AudioOuterBoundsCheckBox
|
||||
//
|
||||
this.AudioOuterBoundsCheckBox.AutoSize = true;
|
||||
this.AudioOuterBoundsCheckBox.Checked = true;
|
||||
this.AudioOuterBoundsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.AudioOuterBoundsCheckBox.Location = new System.Drawing.Point(10, 434);
|
||||
this.AudioOuterBoundsCheckBox.Location = new System.Drawing.Point(10, 457);
|
||||
this.AudioOuterBoundsCheckBox.Name = "AudioOuterBoundsCheckBox";
|
||||
this.AudioOuterBoundsCheckBox.Size = new System.Drawing.Size(147, 17);
|
||||
this.AudioOuterBoundsCheckBox.TabIndex = 54;
|
||||
this.AudioOuterBoundsCheckBox.TabIndex = 55;
|
||||
this.AudioOuterBoundsCheckBox.Text = "Show audio outer bounds";
|
||||
this.AudioOuterBoundsCheckBox.UseVisualStyleBackColor = true;
|
||||
this.AudioOuterBoundsCheckBox.CheckedChanged += new System.EventHandler(this.AudioOuterBoundsCheckBox_CheckedChanged);
|
||||
@ -1823,10 +1836,10 @@ namespace CodeWalker
|
||||
// PathsDepthClipCheckBox
|
||||
//
|
||||
this.PathsDepthClipCheckBox.AutoSize = true;
|
||||
this.PathsDepthClipCheckBox.Location = new System.Drawing.Point(10, 411);
|
||||
this.PathsDepthClipCheckBox.Location = new System.Drawing.Point(10, 434);
|
||||
this.PathsDepthClipCheckBox.Name = "PathsDepthClipCheckBox";
|
||||
this.PathsDepthClipCheckBox.Size = new System.Drawing.Size(102, 17);
|
||||
this.PathsDepthClipCheckBox.TabIndex = 53;
|
||||
this.PathsDepthClipCheckBox.TabIndex = 54;
|
||||
this.PathsDepthClipCheckBox.Text = "Paths depth clip";
|
||||
this.PathsDepthClipCheckBox.UseVisualStyleBackColor = true;
|
||||
this.PathsDepthClipCheckBox.CheckedChanged += new System.EventHandler(this.PathsDepthClipCheckBox_CheckedChanged);
|
||||
@ -2489,7 +2502,7 @@ namespace CodeWalker
|
||||
this.ToolsMenuExtractShaders,
|
||||
this.ToolsMenuOptions});
|
||||
this.ToolsMenu.Name = "ToolsMenu";
|
||||
this.ToolsMenu.Size = new System.Drawing.Size(166, 312);
|
||||
this.ToolsMenu.Size = new System.Drawing.Size(166, 290);
|
||||
//
|
||||
// ToolsMenuRPFBrowser
|
||||
//
|
||||
@ -3475,5 +3488,6 @@ namespace CodeWalker
|
||||
private System.Windows.Forms.CheckBox PopZonesCheckBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem ToolbarSelectAudioButton;
|
||||
private System.Windows.Forms.CheckBox AudioOuterBoundsCheckBox;
|
||||
private System.Windows.Forms.CheckBox SkeletonsCheckBox;
|
||||
}
|
||||
}
|
4308
WorldForm.cs
4308
WorldForm.cs
File diff suppressed because it is too large
Load Diff
@ -240,6 +240,14 @@ ufo
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB4SURBVDhP3ZC7DcAgDEQZKTMwHOvSIFriS7BlEB+HMic9
|
||||
QJbvFThLUkpXzjkSpaeuzMPlEELx3jdsBauyCHBY6UWYPQI93KEljQD3jL6EGzN6x0bASyNYwkKU8Udm
|
||||
gd6TMnIikDJyIqjVNz8T7FgKrAwFX6lVinM3aJ05lWDPRRcAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarTransformSpaceButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB0SURBVDhP7ZNBCoAgEEXnSJ3BqxmetNpaMLhVv5DNRJS2
|
||||
CxIeuvA9XSjtg5mHEILPxB6U7JyLxphmSkDK1o5x9dst87SUfTXwRsYsA+paT0BGDGsVOJ92hdz3Bz4f
|
||||
wGPC48uu7w5IGd+gBlpRMgYCnRwyESUj3CsQkYNFDwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarObjectSpaceButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -259,14 +267,6 @@ ufo
|
||||
7bHCx/miCf7qYJ1jjjYYx3Fm0nfDXfJWzhjMzuBweJJvr++b5K1dOQN7hP9AH0H96EvM83zh7q+2zsH1
|
||||
L1H0fS+TJHEX+ZsBXDRobS/oRorjWB5/aqSXVkZRJKuqQnxtJEJNXCvjTu9D9kGOmhEvW5kwJiVb43wI
|
||||
WBXYx9R1nV75RuyHKrrnzCcGjE1u9ZyD4BugoZigQ9xrngAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarTransformSpaceButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB0SURBVDhP7ZNBCoAgEEXnSJ3BqxmetNpaMLhVv5DNRJS2
|
||||
CxIeuvA9XSjtg5mHEILPxB6U7JyLxphmSkDK1o5x9dst87SUfTXwRsYsA+paT0BGDGsVOJ92hdz3Bz4f
|
||||
wGPC48uu7w5IGd+gBlpRMgYCnRwyESUj3CsQkYNFDwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarUndoButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -352,6 +352,17 @@ ufo
|
||||
4BJN+IjGo5O8ZJndGVhKxpjWWts551aih0fre+0BLaVchRAezPB2NXSSV/gVwXGYPJiVUt6ns1ghCDjn
|
||||
UQG86w3FToVgDcWCWS9Fvi/Ao0RVAcwUjwpyhzmf4n8BFApS5HZRwRuONGMbrIJ1JIN8O2QAAAAASUVO
|
||||
RK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarCameraModeButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEvSURBVDhP3dK/K0dRGMfxKxRJopCSEkLya/guUhQRmQwG
|
||||
WfwIkYySgYUSKUKJlOK/MBoMFMofYLUIsfJ+f3NuF3+A8tRree5zP/fcc070f6oHT/jAPTqQj6WvXvCM
|
||||
TZQgG3H58gFGcYVLtGIN15jBNDbwiGNUIg4pQx8GsQuHhrCDW8yjHyns4Q0DcCXpykM5bFzgHGPYxw1G
|
||||
UIVMtMHfWUUj4nIg/KurGIYrSAZYOXDGlbhXcZlegUO8Yxzb+BlQAwNW0G0jVAYK0AwHtnCEOyQDZvGC
|
||||
ObTbKIIvLMA9WIYDizhFMsDjfsAZptCA9JcdfoVBvryOSbgCe4HPTuCz+BQMKEUvJmCy96ET1ehCuAf2
|
||||
5ZF+uwdZKEYtmuBGFSIXhtejBe5PHX7dxL+qKPoEppRHcXOtiDsAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarCameraPerspectiveButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -387,17 +398,6 @@ ufo
|
||||
rp3fhGJScIRLzKMLFTC9cMIu3nCDVUyjB6WkYA93mEWbAyH9cMImPuA+rWMA31YwBU82kF6BS32Er/aO
|
||||
M8zAh+OEghpcwQ2bg3uwBW8ewFd7xQkm0IA4oaAS7bh2KHjBIZbhV/D6GJkFphrdcIP8lFrAGPwPOjCO
|
||||
QdQiTqrAWNICd7gPnUj+xBKaU9dxfhTkjwV/FxU+AbsiGnc46OYIAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarCameraModeButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEvSURBVDhP3dK/K0dRGMfxKxRJopCSEkLya/guUhQRmQwG
|
||||
WfwIkYySgYUSKUKJlOK/MBoMFMofYLUIsfJ+f3NuF3+A8tRree5zP/fcc070f6oHT/jAPTqQj6WvXvCM
|
||||
TZQgG3H58gFGcYVLtGIN15jBNDbwiGNUIg4pQx8GsQuHhrCDW8yjHyns4Q0DcCXpykM5bFzgHGPYxw1G
|
||||
UIVMtMHfWUUj4nIg/KurGIYrSAZYOXDGlbhXcZlegUO8Yxzb+BlQAwNW0G0jVAYK0AwHtnCEOyQDZvGC
|
||||
ObTbKIIvLMA9WIYDizhFMsDjfsAZptCA9JcdfoVBvryOSbgCe4HPTuCz+BQMKEUvJmCy96ET1ehCuAf2
|
||||
5ZF+uwdZKEYtmuBGFSIXhtejBe5PHX7dxL+qKPoEppRHcXOtiDsAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
Loading…
Reference in New Issue
Block a user