Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
9871571
Added BiffAnimationAttribute to PrimitiveData and Mesh.VertexData for…
ecurtz Aug 17, 2020
c8ddec3
Fixed struct size of Mesh.VertData and tag for BiffAnimation.
ecurtz Aug 17, 2020
ee0871b
Add blendshape data to meshes with vertex animation and use a Skinned…
ecurtz Aug 18, 2020
5895de4
Added (inexplicably) required calls to RecalculateNormals() and Reca…
ecurtz Aug 22, 2020
6de9e4e
Changed argument for Material.toUnityMaterial()
ecurtz Aug 27, 2020
b736b0f
Remove Mesh.VertData dependency on UnityEngine.Vector3
ecurtz Aug 27, 2020
e78a758
Added Vector3 extension methods to Mesh.VertData
ecurtz Aug 27, 2020
b539a14
Simple OBJ sequence for testing model animation. Cube that expands an…
ecurtz Aug 29, 2020
4223292
primtive: Add test coverage for reading animated mesh data.
freezy Aug 30, 2020
d81d22d
project: Add Microsoft.NET.Test.Sdk to test project.
freezy Aug 30, 2020
b687bd5
project: Update authors.
freezy Aug 30, 2020
6742897
Moved game object to item name compare from EditorApplication.hierarc…
ecurtz Oct 3, 2020
3bf80ee
Merge branch 'master' of https://github.com/freezy/VisualPinball.Engine
ecurtz Oct 3, 2020
3446153
Reverse local change to match upstream master
ecurtz Oct 4, 2020
641154d
Merge branch 'master' of https://github.com/freezy/VisualPinball.Engine
ecurtz Oct 9, 2020
dc406dc
Merge branch 'master' of https://github.com/freezy/VisualPinball.Engine
ecurtz Oct 19, 2020
4d0a4b7
Minimal boilerplate for new trough items.
ecurtz Oct 20, 2020
8670741
rubber: Add separate collision authoring component.
freezy Sep 24, 2020
e3c160d
surface: Add separate collision authoring component.
freezy Sep 24, 2020
eb04c03
import: Add collider component to rubber and surface.
freezy Sep 24, 2020
0873c18
import: Add name parse function.
freezy Sep 24, 2020
9957656
rog: Analyze name on creation.
freezy Sep 24, 2020
4aaa9d3
import: Attach objects to parent if matched by name.
freezy Sep 24, 2020
f27af51
import: Don't create mesh if it's a collider.
freezy Sep 24, 2020
c15a5a4
import: Return created MonoBehaviour.
freezy Sep 24, 2020
c26acbf
import: Remove collider component if overridden.
freezy Sep 24, 2020
e4044c3
editor: Move inspectors into their own folder, and add link interface…
freezy Sep 24, 2020
3df2bcc
collider: Override colliders when generating.
freezy Sep 26, 2020
42ffe52
editor: Refactor data handling.
freezy Sep 27, 2020
4a23a93
editor: Fix data handling for sub components.
freezy Sep 27, 2020
20c1d58
editor: Don't cache data references for collider authoring components.
freezy Sep 27, 2020
7bbc372
editor: Move collider gizmos to collider authoring.
freezy Sep 27, 2020
ac7dacf
editor: Move physics debug window into collider inspector.
freezy Sep 27, 2020
6d451ef
editor: Test moving children with parent.
freezy Sep 27, 2020
056eef2
components: Add some documentation.
freezy Sep 28, 2020
1c4cbb9
components: Update documentation.
freezy Sep 28, 2020
a60af92
editor: Update colored icons.
freezy Sep 29, 2020
de49047
doc: Update component doc.
freezy Sep 30, 2020
47d4781
editor: Set collider icons.
freezy Oct 3, 2020
de4a275
editor: Add main authoring base class.
freezy Oct 4, 2020
de06a5f
authoring: Split mesh creation into separate component.
freezy Oct 4, 2020
25986e2
bumper: Start splitting meshes.
freezy Oct 4, 2020
6f7f38e
bumper: Fix tests.
freezy Oct 4, 2020
718181b
bumper: Simplify mesh generator.
freezy Oct 5, 2020
8ec4765
bumper: Fix mesh creation.
freezy Oct 5, 2020
f61d091
bumpers: Add animation icons.
freezy Oct 5, 2020
edb465e
authoring: Hookup manual mesh rebuild.
freezy Oct 5, 2020
a9d77ff
style: Minor comments.
freezy Oct 5, 2020
0cccb00
editor: Update icons.
freezy Oct 6, 2020
aa45570
playfield: Add components.
freezy Oct 6, 2020
1de56f9
editor: Update icons.
freezy Oct 6, 2020
55afa86
editor: Restore mesh regeneration during transform.
freezy Oct 6, 2020
0e3fe2e
editor: Hide gizmos of child items.
freezy Oct 6, 2020
bd6c227
editor: Regenenerate child meshes on property change.
freezy Oct 6, 2020
da5e226
bumper: Add mesh inspectors.
freezy Oct 6, 2020
04bcaa2
fix: Set default physics engine.
freezy Oct 7, 2020
09bb9a4
editor: Add parent class to moveable components.
freezy Oct 7, 2020
a91bcd0
ecs: Parent mesh children.
freezy Oct 8, 2020
d3b0b51
components: Fix initial matrix tranformation.
freezy Oct 8, 2020
6f22e00
editor: Fix translation.
freezy Oct 9, 2020
e119d37
editor: Exclude playfield from being transformed.
freezy Oct 9, 2020
6bf41bf
bumper: Add collider authoring component.
freezy Oct 9, 2020
34375d4
surface: Add mesh component inspectors.
freezy Oct 9, 2020
6a1cba8
gate: Refactor mesh generator.
freezy Oct 9, 2020
bcfdaac
editor: Update icons.
freezy Oct 10, 2020
c0b3dae
gate: Add mesh authoring components.
freezy Oct 10, 2020
973f044
rubber: Properly generate mesh.
freezy Oct 10, 2020
dbc4186
gate: Move main authoring back up to main object.
freezy Oct 10, 2020
d948e3e
spinner: Move main authoring back up and split components.
freezy Oct 10, 2020
5ee2f98
ramp: Split components.
freezy Oct 11, 2020
289f68f
flipper: Split components.
freezy Oct 12, 2020
3763951
flipper: Handle mesh generator when rubber width is 0.
freezy Oct 12, 2020
029d1e2
flipper: Fix rubber component name.
freezy Oct 12, 2020
1d3a3f8
plunger: Add separate mesh generation.
freezy Oct 12, 2020
8d47148
unity: Add remaining authoring components.
freezy Oct 12, 2020
4a9f811
editor: Add missing mesh icons.
freezy Oct 13, 2020
3adf075
trigger: Create authoring components.
freezy Oct 13, 2020
9b4d84c
kicker: Create authoring components.
freezy Oct 13, 2020
b28adee
target: Create authoring components.
freezy Oct 13, 2020
bc0921a
primitive: Create authoring components.
freezy Oct 13, 2020
a304b2b
editor: Disable gizmos for latest icons.
freezy Oct 13, 2020
57da186
plunger: Create authoring components.
freezy Oct 13, 2020
ce71944
plunger: Update game objects on type change.
freezy Oct 13, 2020
aedc6a4
plunger: Fix mesh generation.
freezy Oct 14, 2020
b59a327
light: Create authoring components.
freezy Oct 14, 2020
ce94a15
editor: Add player icon.
freezy Oct 15, 2020
396e358
mesh: Add abstract visibility and clean up authoring component.
freezy Oct 15, 2020
e04720a
coils: Add icon to manager.
freezy Oct 21, 2020
192ac3c
chore: Remove unused imports.
freezy Oct 21, 2020
26a6d4d
patcher: Re-enable patching.
freezy Oct 21, 2020
1fc8b56
import: Patch item-only patchers before creating game object.
freezy Oct 21, 2020
4edfc70
debug: Print collider count.
freezy Oct 21, 2020
97e038d
components: Start working on parenting.
freezy Oct 21, 2020
71da130
components: Move children into parent space.
freezy Oct 22, 2020
6578c6e
flipper: Add inspector for collider and properly generate collision p…
freezy Oct 22, 2020
a5cf917
flipper: Fix collider changes in inspector.
freezy Oct 22, 2020
e709375
components: Update scene when editing collider props.
freezy Oct 23, 2020
76ae172
flipper: Add remaining inspectors.
freezy Oct 23, 2020
5b4a4ee
doc: Add lightbox for images.
freezy Oct 23, 2020
752c842
doc: Update components doc.
freezy Oct 23, 2020
79e4823
events: Emit on parent if available.
freezy Oct 24, 2020
216af00
editor: Add trough icon.
freezy Oct 24, 2020
a04519b
More empty boilerplate trough classes
ecurtz Oct 24, 2020
92afde8
components: Show error for flipper components in editor when no data …
freezy Oct 24, 2020
4f3ba85
components: Add parenting API to all components.
freezy Oct 25, 2020
0cb1d6e
primitive: Add inspectors.
freezy Oct 25, 2020
069ece3
gate: Add inspectors.
freezy Oct 25, 2020
bc78ed3
components: Add remaining inspectors.
freezy Oct 25, 2020
78b8531
components: Update name and visibility when restoring based on hierar…
freezy Oct 26, 2020
9f4ff86
doc: Update components doc.
freezy Oct 26, 2020
88f387e
Copyedit pass on Unity Components document
ecurtz Oct 26, 2020
749d618
fix: Set mesh invisible, if it's... invisible.
freezy Oct 26, 2020
e85f4c8
fix: Only add active colliders.
freezy Oct 26, 2020
b2fb8ba
physics: Measure and print kd-tree creation.
freezy Oct 26, 2020
fc404aa
components: Fix patcher.
freezy Oct 26, 2020
89a7265
import: Refactor object creation.
freezy Oct 26, 2020
33f6590
editor: Don't disable gizmos, only icons on recompilation.
freezy Oct 27, 2020
58d1242
components: Move component destruction to converter.
freezy Oct 27, 2020
a79b0da
fix: Various small fixes.
freezy Oct 27, 2020
33e3e9b
components: Don't parent on import if parenting isn't supported.
freezy Oct 27, 2020
eb95008
components: Properely unparent when parenting isn't supported.
freezy Oct 27, 2020
2c6f3e2
component: Fix parented collider position.
freezy Oct 27, 2020
7a622bc
components: Allow primitive colliders to be parented to primitives.
freezy Oct 27, 2020
0c1d647
components: Check sub components when validating parenting.
freezy Oct 27, 2020
ce806bb
chore: Fix imports.
freezy Oct 27, 2020
acb200a
Generic inspector field for references between ItemAuthoring ocmponents.
ecurtz Oct 28, 2020
8872e28
Merge branch 'feature/trough' into feature/multi-component
ecurtz Oct 28, 2020
96fa534
Post rebase cleanup of Trough classes.
ecurtz Oct 28, 2020
aedefac
Merge branch 'master' of https://github.com/freezy/VisualPinball.Engine
ecurtz Oct 28, 2020
4056e29
Merge branch 'feature/multi-component'
ecurtz Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion VisualPinball.Engine/VPT/ItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public enum ItemType
Flasher = 20,
Rubber = 21,
HitTarget = 22,
Count = 23,
Trough = 23,
Count = 24,
Invalid = -1,

// VPE internal
Expand Down
8 changes: 8 additions & 0 deletions VisualPinball.Engine/VPT/Trough.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions VisualPinball.Engine/VPT/Trough/Trough.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Visual Pinball Engine
// Copyright (C) 2020 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System.IO;
using VisualPinball.Engine.Game;
using VisualPinball.Engine.Math;

namespace VisualPinball.Engine.VPT.Trough
{
public class Trough : Item<TroughData>, IRenderable
{
public override string ItemName { get; } = "Trough";
public override string ItemGroupName { get; } = "Troughs";

public Vertex3D Position { get => Vertex3D.Zero; set { } }
public float RotationY { get => 0f; set { } }

public Trough(TroughData data) : base(data)
{
}

public Trough(BinaryReader reader, string itemName) : this(new TroughData(reader, itemName))
{
}

#region IRenderable

Matrix3D IRenderable.TransformationMatrix(Table.Table table, Origin origin)
{
return Matrix3D.Identity;
}

public RenderObject GetRenderObject(Table.Table table, string id = null, Origin origin = Origin.Global, bool asRightHanded = true)
{
return null;
}

public RenderObjectGroup GetRenderObjects(Table.Table table, Origin origin = Origin.Global, bool asRightHanded = true)
{
return new RenderObjectGroup(Data.Name, "trough", Math.Matrix3D.Identity, new RenderObject[0]);
}

#endregion
}
}
11 changes: 11 additions & 0 deletions VisualPinball.Engine/VPT/Trough/Trough.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions VisualPinball.Engine/VPT/Trough/TroughData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Visual Pinball Engine
// Copyright (C) 2020 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#region ReSharper
// ReSharper disable UnassignedField.Global
// ReSharper disable StringLiteralTypo
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable ConvertToConstant.Global
#endregion

using System;
using System.Collections.Generic;
using System.IO;
using VisualPinball.Engine.IO;
using VisualPinball.Engine.Math;
using VisualPinball.Engine.VPT.Table;

namespace VisualPinball.Engine.VPT.Trough
{
[Serializable]
public class TroughData : ItemData
{
public override string GetName() => Name;
public override void SetName(string name) { Name = name; }

[BiffString("NAME", IsWideString = true, Pos = 9)]
public string Name;

[BiffString("ENTK", Pos = 1)]
public string EntryKicker = string.Empty;

[BiffString("ENTS", Pos = 2)]
public string EntrySwitch = string.Empty;

[BiffString("EXIT", Pos = 10)]
public string ExitKicker = string.Empty;

[BiffInt("BCNT", Pos = 3)]
public int BallCount = 3;

[BiffInt("SCNT", Pos = 4)]
public int SwitchCount = 3;

[BiffFloat("TIME", Pos = 5)]
public float SettleTime = 0.1f;

#region BIFF

static TroughData()
{
Init(typeof(TroughData), Attributes);
}

public TroughData(BinaryReader reader, string storageName) : base(storageName)
{
Load(this, reader, Attributes);
}

public override void Write(BinaryWriter writer, HashWriter hashWriter)
{
writer.Write((int)ItemType.Trough);
WriteRecord(writer, Attributes, hashWriter);
WriteEnd(writer, hashWriter);
}

private static readonly Dictionary<string, List<BiffAttribute>> Attributes = new Dictionary<string, List<BiffAttribute>>();

#endregion
}
}
11 changes: 11 additions & 0 deletions VisualPinball.Engine/VPT/Trough/TroughData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/ItemInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
using System.Linq;
using UnityEditor;
using UnityEngine;
using VisualPinball.Engine.Game;
using VisualPinball.Engine.Math;
using VisualPinball.Engine.VPT;
using VisualPinball.Engine.VPT.Surface;

namespace VisualPinball.Unity.Editor
Expand All @@ -28,7 +30,7 @@ public abstract class ItemInspector : UnityEditor.Editor
public abstract MonoBehaviour UndoTarget { get; }

private TableAuthoring _table;
private SurfaceAuthoring _surface;
private MonoBehaviour _item;

private string[] _allMaterials = new string[0];
private string[] _allTextures = new string[0];
Expand Down Expand Up @@ -238,28 +240,35 @@ protected void ItemDataField(string label, ref Engine.Math.Color field, bool dir
}
}

protected void SurfaceField(string label, ref string field, bool dirtyMesh = true)
protected void ItemReferenceField<TItemAuthoring, TItem, TData>(string label, ref string field, bool dirtyMesh = true)
where TItemAuthoring : ItemMainAuthoring<TItem, TData>
where TData : ItemData where TItem : Item<TData>, IRenderable
{
if (_surface?.name != field) {
_surface = null;
if (_item?.name != field) {
_item = null;
}

if (_surface == null && _table != null) {
var currentFieldName = field;
if (currentFieldName != null && _table.Table.Has<Surface>(currentFieldName)) {
_surface = _table.gameObject.GetComponentsInChildren<SurfaceAuthoring>(true)
if (_item == null && _table != null) {
string currentFieldName = field;
if (currentFieldName != null && _table.Table.Has<TItem>(currentFieldName)) {
_item = _table.gameObject.GetComponentsInChildren<TItemAuthoring>(true)
.FirstOrDefault(s => s.name == currentFieldName);
}
}

EditorGUI.BeginChangeCheck();
_surface = (SurfaceAuthoring)EditorGUILayout.ObjectField(label, _surface, typeof(SurfaceAuthoring), true);
_item = (TItemAuthoring)EditorGUILayout.ObjectField(label, _item, typeof(TItemAuthoring), true);
if (EditorGUI.EndChangeCheck()) {
FinishEdit(label, dirtyMesh);
field = _surface != null ? _surface.name : string.Empty;
field = _item != null ? _item.name : string.Empty;
}
}

protected void SurfaceField(string label, ref string field, bool dirtyMesh = true)
{
ItemReferenceField<SurfaceAuthoring, Surface, SurfaceData>(label, ref field, dirtyMesh);
}

protected void DropDownField<T>(string label, ref T field, string[] optionStrings, T[] optionValues, bool dirtyMesh = true, Action<T, T> onChanged = null) where T : IEquatable<T>
{
if (optionStrings == null || optionValues == null || optionStrings.Length != optionValues.Length) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Visual Pinball Engine
// Copyright (C) 2020 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using UnityEditor;
using VisualPinball.Unity;
using VisualPinball.Engine.VPT.Trough;
using VisualPinball.Engine.VPT.Kicker;

namespace VisualPinball.Unity.Editor
{
[CustomEditor(typeof(TroughAuthoring))]
public class TroughInspector : ItemMainInspector<Trough, TroughData, TroughAuthoring>
{
private TroughAuthoring _trough;
private bool _foldoutPosition = true;
private bool _foldoutMisc = true;

protected override void OnEnable()
{
base.OnEnable();
_trough = target as TroughAuthoring;
}

public override void OnInspectorGUI()
{
OnPreInspectorGUI();

if (_foldoutPosition = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutPosition, "Position")) {
ItemReferenceField<KickerAuthoring, Kicker, KickerData>("Entry Kicker", ref _trough.Data.EntryKicker);
ItemReferenceField<KickerAuthoring, Kicker, KickerData>("Exit Kicker", ref _trough.Data.ExitKicker);
}
EditorGUILayout.EndFoldoutHeaderGroup();

if (_foldoutMisc = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutMisc, "Misc")) {
ItemDataField("Max Balls", ref _trough.Data.BallCount, dirtyMesh: false);
ItemDataField("Switch Count", ref _trough.Data.SwitchCount, dirtyMesh: false);
ItemDataField("Settle Time", ref _trough.Data.SettleTime, dirtyMesh: false);
}
EditorGUILayout.EndFoldoutHeaderGroup();

base.OnInspectorGUI();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions VisualPinball.Unity/VisualPinball.Unity/Game/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
using VisualPinball.Engine.VPT.Surface;
using VisualPinball.Engine.VPT.Table;
using VisualPinball.Engine.VPT.Trigger;
using VisualPinball.Engine.VPT.Trough;
using Logger = NLog.Logger;

namespace VisualPinball.Unity
{
public class Player : MonoBehaviour
{
public Table Table { get; private set; }
public TableApi TableApi { get { return _tableApi; } }

// shortcuts
public Matrix4x4 TableToWorld => transform.localToWorldMatrix;
Expand Down Expand Up @@ -258,6 +260,12 @@ public void RegisterTrigger(Trigger trigger, Entity entity, GameObject go)
_switches[trigger.Name] = triggerApi;
}

public void RegisterTrough(Trough trough, Entity entity, GameObject go)
{
var troughApi = new TroughApi(trough, entity, this);
_initializables.Add(troughApi);
}

#endregion

#region Mapping
Expand Down
1 change: 1 addition & 0 deletions VisualPinball.Unity/VisualPinball.Unity/VPT/ItemApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class ItemApi<T, TData> : IApi where T : Item<TData> where TData

protected TData Data => Item.Data;
protected Table Table => _player.Table;
protected TableApi TableApi => _player.TableApi;

protected readonly EntityManager EntityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

Expand Down
8 changes: 8 additions & 0 deletions VisualPinball.Unity/VisualPinball.Unity/VPT/Trough.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading