diff --git a/CHANGELOG.md b/CHANGELOG.md index 285f1fd1d..6a76a2721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Built with Unity 2021.2. ### Added +- Gate Lifter Component ([#418](https://github.com/freezy/VisualPinball.Engine/pull/418), [Documentation](https://docs.visualpinball.org/creators-guide/manual/mechanisms/lifting-gates.html)). - Asset Browser ([#412](https://github.com/freezy/VisualPinball.Engine/pull/412)) - Trigger meshes can now be easily scaled ([#374](https://github.com/freezy/VisualPinball.Engine/pull/374)) - We got a new game item called *Metal Wire Guide* (thanks @Cupiii, [#366](https://github.com/freezy/VisualPinball.Engine/pull/366)) diff --git a/README.md b/README.md index 6aa5a0944..9c047e2cf 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ This repository is part of a number of packages. It is what we're referring to a VPE is still work in progress. You can check the current features list [here](https://docs.visualpinball.org/creators-guide/introduction/features.html) and the open issues [here](https://github.com/freezy/VisualPinball.Engine/issues). -There are a few videos in the [VPF thread](https://www.vpforums.org/index.php?showtopic=43651), +There are a few videos in the [VPF thread](https://vpuniverse.com/forums/topic/5362-wip-visual-pinball-in-unity-2021-edition/), where you can discuss. Screenshots are [here](https://github.com/freezy/VisualPinball.Engine/wiki/Unity-Screenshots)! :) ## Credits diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png b/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png new file mode 100644 index 000000000..555595c46 Binary files /dev/null and b/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png differ diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png.meta b/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png.meta new file mode 100644 index 000000000..7394cb358 --- /dev/null +++ b/VisualPinball.Unity/Assets/Editor/Icons/small_blue/gate_lifter.png.meta @@ -0,0 +1,122 @@ +fileFormatVersion: 2 +guid: f8f0f43b8608e9541a2a0553c07a7d92 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png b/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png new file mode 100644 index 000000000..27bd62aef Binary files /dev/null and b/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png differ diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png.meta b/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png.meta new file mode 100644 index 000000000..9bf08c652 --- /dev/null +++ b/VisualPinball.Unity/Assets/Editor/Icons/small_gray/gate_lifter.png.meta @@ -0,0 +1,122 @@ +fileFormatVersion: 2 +guid: 089b7800e18ce404c8608d12ff6c9447 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png b/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png new file mode 100644 index 000000000..9f8ecf132 Binary files /dev/null and b/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png differ diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png.meta b/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png.meta new file mode 100644 index 000000000..3731303e2 --- /dev/null +++ b/VisualPinball.Unity/Assets/Editor/Icons/small_green/gate_lifter.png.meta @@ -0,0 +1,122 @@ +fileFormatVersion: 2 +guid: 053e6782a62aa9c4699bf978fd100260 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png b/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png new file mode 100644 index 000000000..ac6be4a67 Binary files /dev/null and b/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png differ diff --git a/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png.meta b/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png.meta new file mode 100644 index 000000000..1b0674ff2 --- /dev/null +++ b/VisualPinball.Unity/Assets/Editor/Icons/small_orange/gate_lifter.png.meta @@ -0,0 +1,122 @@ +fileFormatVersion: 2 +guid: 714ba3a4d70e7484eb2a5e702bc528b0 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate-inspector.png b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate-inspector.png new file mode 100644 index 000000000..97630a439 Binary files /dev/null and b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate-inspector.png differ diff --git a/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate.jpg b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate.jpg new file mode 100644 index 000000000..2559eba8c Binary files /dev/null and b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gate.jpg differ diff --git a/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gates.md b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gates.md new file mode 100644 index 000000000..91177bbaf --- /dev/null +++ b/VisualPinball.Unity/Documentation~/creators-guide/manual/mechanisms/lifting-gates.md @@ -0,0 +1,38 @@ +--- +uid: gate_lifter +title: Lifting Gates +description: This component makes your gate toggelable by a coil. It works by lifting it up so the ball can pass below. +--- + +# Lifting Gates + +
+ +
+ Photo © 2022 by bord +
+ +Some Gottlieb and Bally games use gates that can be activated and deactivated. It does that by connecting a stem to the wire that lifts it up so the ball can pass through in both directions. The stem is attached to a relay. When the relay is turned on, the one-way gate becomes a two-way gate. + +VPE provides a component that you can add to your existing gate. By doing that, it creates a new coil device that you can then map in the [Coil Manager](xref:coil_manager). + +## Setup + + + +In order to add the lifting gate feature to a gate, select the game object of the gate and click on *Add Component* in the inspector. Select it by searching or navigating to *Visual Pinball -> Mechs -> Gate Lifter*. + +### Lifting Angle + +How many degrees the wire rotates up to the deactivated position. About 15° should work well for most geometry. + +### Animation Speed + +How fast the gate rotates from and into the decativated position. Higher is faster. `0.1` seems a reasonable value. + +## Usage + +Adding the gate lifter component adds a coil input to the gate, i.e. you can map it to any of the gamelogic engine's coil outputs through the [Coil Manager](xref:coil_manager). + +> [!NOTE] +> If you're working on an EM game or an original game with [Visual Scripting](xref:uvs_index), don't forget to add the new coil to the [coil definitions](xref:uvs_setup#coils). \ No newline at end of file diff --git a/VisualPinball.Unity/Documentation~/creators-guide/toc.yml b/VisualPinball.Unity/Documentation~/creators-guide/toc.yml index b1a94e913..d42afcc2e 100644 --- a/VisualPinball.Unity/Documentation~/creators-guide/toc.yml +++ b/VisualPinball.Unity/Documentation~/creators-guide/toc.yml @@ -87,3 +87,5 @@ href: manual/mechanisms/rotators.md - name: Collision Switches href: manual/mechanisms/collision-switches.md + - name: Lifting Gates + href: manual/mechanisms/lifting-gates.md diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/1-prepare-artwork.md b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/1-prepare-artwork.md similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/1-prepare-artwork.md rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/1-prepare-artwork.md diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/2-create-mesh.md b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/2-create-mesh.md similarity index 98% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/2-create-mesh.md rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/2-create-mesh.md index 40d1ab3b0..1e074cbcb 100644 --- a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/2-create-mesh.md +++ b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/2-create-mesh.md @@ -1,62 +1,62 @@ ---- -uid: tutorial_plastics_2 -title: Realistic Looking Plastics - Create Mesh -description: How to create the meshes in Blender ---- - -# Create Mesh - -We're now going to import the SVG created in the [previous step](xref:tutorial_plastics_1) and create a mesh that is beveled on the top. - -## Step 1: Import - -Open Blender, clear the scene with `A`, `X`, `Enter`. Then, click on *File -> Import -> Scalable Vector Graphics (.svg)*, navigate to where you've saved the SVG in the previous step, select `Plastics.svg`, and hit *Import*. - -You might not see much due to the imported size. If there were no errors, you should see your imported plastics in the Outliner. Select them and press `.` on the numpad (not the main keyboard) while hovering over the 3D viewport to zoom in. - -> [!note] -> You might run into another issue due to the size of the plastics: Camera clipping. To fix that, press `N` with your cursor over the 3D Viewport, select *View* and set something like 0.001m for *Clip Start*. - -Your viewport should look like this now: - -![2D Outlines](blender-shapes.png) - -## Step 2: Setup - -The way we're going for this is to extrude and bevel our SVG on one side only. This however results in the bottom faces missing. To fix that, we'll duplicate our SVG and use one for extrusion and the other for the bottom mesh. - -Before we start, let's make it one single object so we can easily apply everything we do in one step. Select one element, hit `A` for select all, then `Ctrl`+`J` for joining all curves. - -Hit `Shift`+`D`, `Esc` to duplicate at the same position. In the *Outliner*, let's name our objects "bottom" and "extruded": - -![Duplicated Surface](blender-duplicated-surface.png) - -## Step 3: Extrude - -Select "extruded" in the outliner and click on the *Object Properties* tab in the *Properties* view on the right side. Under *Geometry*, there is an *Extrude* field, and a bit below a *Bevel* section. - -Now, the *Extrude* value is difficult to judge. If you have access to the physical plastics, you can calculate the scale between the real world and the object in Blender by physically measuring the size of a plastic and dividing it by the [measured value](https://docs.blender.org/manual/en/latest/editors/3dview/toolbar/measure.html) in Blender. Then, also measure the thickness of the real-world plastic and multiply it by that factor. Personally, I just eyeballed it and ended up with 0.003 m for the *Extrude* value and 0.001 m for the *Bevel Depth*. - -Then there are three more properties to change: - -- We only want to extrude the front, so set *Fill Mode* to *Front*. -- We don't want to make the object larger by beveling, so enter the negative value of the bevel depth under *Offset*. -- Finally, a *Resolution* of `0` will do. - -Here are all the non-default options in red: - -![Extrude Parameters](blender-extrude.png) - -## Step 4: Convert, Join and Clean - -As seen in the previous screenshot, our bottom object now sits in the middle of the extruded mesh. Let's fix that by typing `G` (move), `Z` (on z-axis only), and the extrude value of the previous step, in our case `0.003`, followed by `Enter`. - -Then type `A` to select all objects, choose *Object -> Convert -> Mesh*, and hit `Ctrl`+`J` to join them all. Finally, clean up the duplicated vertices from the extrusion by hitting `Tab` for edit mode, `A` to select all vertices, and choose *Mesh -> Clean Up -> Merge by Distance*. - -Exit edit mode and this is how it should look: - -![Extruded Shapes](blender-extruded.png) - -If that's the case, congrats, you're done with the meshes! Maybe now it's a good moment to save your Blender file. `Ctrl`+`S` and enter `Plastics.blend`. - -In the [next part](xref:tutorial_plastics_3) of this tutorial, we're going to UV-Map them. +--- +uid: tutorial_plastics_2 +title: Realistic Looking Plastics - Create Mesh +description: How to create the meshes in Blender +--- + +# Create Mesh + +We're now going to import the SVG created in the [previous step](xref:tutorial_plastics_1) and create a mesh that is beveled on the top. + +## Step 1: Import + +Open Blender, clear the scene with `A`, `X`, `Enter`. Then, click on *File -> Import -> Scalable Vector Graphics (.svg)*, navigate to where you've saved the SVG in the previous step, select `Plastics.svg`, and hit *Import*. + +You might not see much due to the imported size. If there were no errors, you should see your imported plastics in the Outliner. Select them and press `.` on the numpad (not the main keyboard) while hovering over the 3D viewport to zoom in. + +> [!note] +> You might run into another issue due to the size of the plastics: Camera clipping. To fix that, press `N` with your cursor over the 3D Viewport, select *View* and set something like 0.001m for *Clip Start*. + +Your viewport should look like this now: + +![2D Outlines](blender-shapes.png) + +## Step 2: Setup + +The way we're going for this is to extrude and bevel our SVG on one side only. This however results in the bottom faces missing. To fix that, we'll duplicate our SVG and use one for extrusion and the other for the bottom mesh. + +Before we start, let's make it one single object so we can easily apply everything we do in one step. Select one element, hit `A` for select all, then `Ctrl`+`J` for joining all curves. + +Hit `Shift`+`D`, `Esc` to duplicate at the same position. In the *Outliner*, let's name our objects "bottom" and "extruded": + +![Duplicated Surface](blender-duplicated-surface.png) + +## Step 3: Extrude + +Select "extruded" in the outliner and click on the *Object Properties* tab in the *Properties* view on the right side. Under *Geometry*, there is an *Extrude* field, and a bit below a *Bevel* section. + +Now, the *Extrude* value is difficult to judge. If you have access to the physical plastics, you can calculate the scale between the real world and the object in Blender by physically measuring the size of a plastic and dividing it by the [measured value](https://docs.blender.org/manual/en/latest/editors/3dview/toolbar/measure.html) in Blender. Then, also measure the thickness of the real-world plastic and multiply it by that factor. Personally, I just eyeballed it and ended up with 0.003 m for the *Extrude* value and 0.001 m for the *Bevel Depth*. + +Then there are three more properties to change: + +- We only want to extrude the front, so set *Fill Mode* to *Front*. +- We don't want to make the object larger by beveling, so enter the negative value of the bevel depth under *Offset*. +- Finally, a *Resolution* of `0` will do. + +Here are all the non-default options in red: + +![Extrude Parameters](blender-extrude.png) + +## Step 4: Convert, Join and Clean + +As seen in the previous screenshot, our bottom object now sits in the middle of the extruded mesh. Let's fix that by typing `G` (move), `Z` (on z-axis only), and the extrude value of the previous step, in our case `0.003`, followed by `Enter`. + +Then type `A` to select all objects, choose *Object -> Convert -> Mesh*, and hit `Ctrl`+`J` to join them all. Finally, clean up the duplicated vertices from the extrusion by hitting `Tab` for edit mode, `A` to select all vertices, and choose *Mesh -> Clean Up -> Merge by Distance*. + +Exit edit mode and this is how it should look: + +![Extruded Shapes](blender-extruded.png) + +If that's the case, congrats, you're done with the meshes! Maybe now it's a good moment to save your Blender file. `Ctrl`+`S` and enter `Plastics.blend`. + +In the [next part](xref:tutorial_plastics_3) of this tutorial, we're going to UV-Map them. diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/3-uv-map-mesh.md b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/3-uv-map-mesh.md similarity index 98% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/3-uv-map-mesh.md rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/3-uv-map-mesh.md index 20d7bf34f..04853325d 100644 --- a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/3-uv-map-mesh.md +++ b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/3-uv-map-mesh.md @@ -1,71 +1,71 @@ ---- -uid: tutorial_plastics_3 -title: Realistic Looking Plastics - UV-Map Mesh -description: How to UV-map the texture onto your mesh in Blender ---- - -# UV-Map Mesh - - -## Step 1: Create Material Slots - - We need three material slots, for the top and bottom faces, as well as for the edges. We'll split the vertices by firstly assigning everything to an "edge" slot, and then re-assigning the top and bottom faces to their own slots. - - - -In object mode, open *Materials* properties and remove the current material slot (hit `-`). Add three new slots (press 3× `+`), and for each slot, create a new material by hitting the *New* button when the slot is selected. Name them "top", "bottom" and "edge" and set their base color to red, green, and blue respectively. Your slots should now look like in the screenshot. - -Set the 3D viewport to *Material Preview*. Select your mesh, press `Tab` to switch to edit mode. Press `A` to select all vertices, select the "edge" material slot, and hit *Assign*. Your plastics should turn blue. Press `A` twice to deselect everything. - -Then, press `7` on the numpad to switch to top view, zoom in a bit so you can clearly see the triangles, switch to *Face Select* and click on one face of the top surface: - -![Triangle selected](blender-triangle-selected-2.png) - - - -Click on *Select -> Select Similar -> Coplanar*, which should result in all top faces of all plastics being selected (but *not* the bottoms ones). However, you might get the bottom faces selected too, because there's a threshold that might be too large. You can check it by rotating the camera and verify that the bottom faces are not selected. If they are, expand the parameters and set the threshold to a small enough value. Then, select the "top" material slot and hit *Assign*. The top surfaces should turn red. - -For the bottom faces, hit `7`, `9` on the numpad to switch to bottom view, and select again one face. Like before, select all coplanar faces, click the "bottom" material slot, and *Assign*. You should see the bottom faces turn green. - -Now, the "edges" material slot should only contain the edges. Check by unselecting all (`A` `A`), then selecting the "edge" material slot and hitting *Select*. This should only select the edges, like here: - -![Edges selected](blender-edges-selected.png) - -Your meshes should now be colored like this (from top / bottom): - -![Selecting edges](blender-material-geometry.png) - -## Step 2: UV-Map - -Switch to the *UV Editing* workspace. In the left *UV Editor*, choose *Image -> Open*, and select the exported `Plastic-01.png` you've created in part one. On the right, enter edit mode, click on the "top" material slot in the *Materials* property tab, and hit *Select*. Click on "bottom" and then on *Select* again. - -From the *UV* menu, select *Cube Projection*. Move your cursor to the left view and press `A`. You should see both the top and bottom surfaces projected onto your texture: - -![UV Mapping in Blender](blender-uv-mapping.png) - -We're now going to align the projection with the texture. You can do that by using the `G` and `S` keys. What's important is to align the **outer** contour with the texture, like so: - -![UV mapped correctly](blender-uv-mapped.png) - -## Step 3: Prepare and Export - -Once done, switch back to the *Layout* workspace. Before we export, there's still a bit of a clean up to do. In edit mode, hit `A` to select all and choose *Mesh -> Clean Up -> Limited Dissolve*. Exit edit mode, go to *Modifier Properties*, add the *Triangulate* modifier, and hit `Ctrl`+`A` to apply. - -What we just did reduced the complexity of our topology. We triangulate at the end to avoid problems during export. - -![Reduced polygons](blender-poly-reduction.png) - -From left to right: -- Original (102k vertices, 44k triangles) -- After limited dissolve (66k vertices, 30k triangles, but errors in mesh) -- After triangulation (66k vertices, 30k triangles) - -Switch to the *Object Data* properties, and under *Normals*, enable *Auto Smooth*. This will properly align the normals on the bevel side, giving it a more realistic refraction effect. - -We still have one single object, so before exporting, let's split it. In edit mode, hit `A` to select all and choose *Mesh -> Separate -> By Loose Parts*. Before exporting, feel free to rename your objects in the Outliner, it's what you'll see in Unity. - -Lastly, in object mode, hit `A` to select all objects and click on *Object -> Set Origin -> Origin to Geometry*. This will set the local origin of each object to the object itself, making it easier to place it. - -Export the plastics by selecting *File -> Export -> FBX*. Name it `Plastics.fbx` and hit *Export FBX*. - -Now let's [import this into Unity](xref:tutorial_plastics_4)! +--- +uid: tutorial_plastics_3 +title: Realistic Looking Plastics - UV-Map Mesh +description: How to UV-map the texture onto your mesh in Blender +--- + +# UV-Map Mesh + + +## Step 1: Create Material Slots + + We need three material slots, for the top and bottom faces, as well as for the edges. We'll split the vertices by firstly assigning everything to an "edge" slot, and then re-assigning the top and bottom faces to their own slots. + + + +In object mode, open *Materials* properties and remove the current material slot (hit `-`). Add three new slots (press 3× `+`), and for each slot, create a new material by hitting the *New* button when the slot is selected. Name them "top", "bottom" and "edge" and set their base color to red, green, and blue respectively. Your slots should now look like in the screenshot. + +Set the 3D viewport to *Material Preview*. Select your mesh, press `Tab` to switch to edit mode. Press `A` to select all vertices, select the "edge" material slot, and hit *Assign*. Your plastics should turn blue. Press `A` twice to deselect everything. + +Then, press `7` on the numpad to switch to top view, zoom in a bit so you can clearly see the triangles, switch to *Face Select* and click on one face of the top surface: + +![Triangle selected](blender-triangle-selected-2.png) + + + +Click on *Select -> Select Similar -> Coplanar*, which should result in all top faces of all plastics being selected (but *not* the bottoms ones). However, you might get the bottom faces selected too, because there's a threshold that might be too large. You can check it by rotating the camera and verify that the bottom faces are not selected. If they are, expand the parameters and set the threshold to a small enough value. Then, select the "top" material slot and hit *Assign*. The top surfaces should turn red. + +For the bottom faces, hit `7`, `9` on the numpad to switch to bottom view, and select again one face. Like before, select all coplanar faces, click the "bottom" material slot, and *Assign*. You should see the bottom faces turn green. + +Now, the "edges" material slot should only contain the edges. Check by unselecting all (`A` `A`), then selecting the "edge" material slot and hitting *Select*. This should only select the edges, like here: + +![Edges selected](blender-edges-selected.png) + +Your meshes should now be colored like this (from top / bottom): + +![Selecting edges](blender-material-geometry.png) + +## Step 2: UV-Map + +Switch to the *UV Editing* workspace. In the left *UV Editor*, choose *Image -> Open*, and select the exported `Plastic-01.png` you've created in part one. On the right, enter edit mode, click on the "top" material slot in the *Materials* property tab, and hit *Select*. Click on "bottom" and then on *Select* again. + +From the *UV* menu, select *Cube Projection*. Move your cursor to the left view and press `A`. You should see both the top and bottom surfaces projected onto your texture: + +![UV Mapping in Blender](blender-uv-mapping.png) + +We're now going to align the projection with the texture. You can do that by using the `G` and `S` keys. What's important is to align the **outer** contour with the texture, like so: + +![UV mapped correctly](blender-uv-mapped.png) + +## Step 3: Prepare and Export + +Once done, switch back to the *Layout* workspace. Before we export, there's still a bit of a clean up to do. In edit mode, hit `A` to select all and choose *Mesh -> Clean Up -> Limited Dissolve*. Exit edit mode, go to *Modifier Properties*, add the *Triangulate* modifier, and hit `Ctrl`+`A` to apply. + +What we just did reduced the complexity of our topology. We triangulate at the end to avoid problems during export. + +![Reduced polygons](blender-poly-reduction.png) + +From left to right: +- Original (102k vertices, 44k triangles) +- After limited dissolve (66k vertices, 30k triangles, but errors in mesh) +- After triangulation (66k vertices, 30k triangles) + +Switch to the *Object Data* properties, and under *Normals*, enable *Auto Smooth*. This will properly align the normals on the bevel side, giving it a more realistic refraction effect. + +We still have one single object, so before exporting, let's split it. In edit mode, hit `A` to select all and choose *Mesh -> Separate -> By Loose Parts*. Before exporting, feel free to rename your objects in the Outliner, it's what you'll see in Unity. + +Lastly, in object mode, hit `A` to select all objects and click on *Object -> Set Origin -> Origin to Geometry*. This will set the local origin of each object to the object itself, making it easier to place it. + +Export the plastics by selecting *File -> Export -> FBX*. Name it `Plastics.fbx` and hit *Export FBX*. + +Now let's [import this into Unity](xref:tutorial_plastics_4)! diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/4-import-into-unity.md b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/4-import-into-unity.md similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/4-import-into-unity.md rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/4-import-into-unity.md diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-duplicated-surface.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-duplicated-surface.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-duplicated-surface.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-duplicated-surface.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-edges-selected.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-edges-selected.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-edges-selected.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-edges-selected.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-extrude.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-extrude.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-extrude.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-extrude.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-extruded.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-extruded.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-extruded.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-extruded.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-material-geometry.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-material-geometry.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-material-geometry.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-material-geometry.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-material-slots.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-material-slots.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-material-slots.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-material-slots.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-no-lower-bevel.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-no-lower-bevel.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-no-lower-bevel.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-no-lower-bevel.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-normals.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-normals.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-normals.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-normals.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-poly-reduction.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-poly-reduction.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-poly-reduction.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-poly-reduction.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-select-coplanar.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-select-coplanar.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-select-coplanar.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-select-coplanar.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-shapes.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-shapes.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-shapes.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-shapes.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangle-selected-2.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangle-selected-2.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangle-selected-2.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangle-selected-2.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangle-selected.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangle-selected.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangle-selected.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangle-selected.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangulated.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangulated.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-triangulated.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-triangulated.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-uv-mapped.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-uv-mapped.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-uv-mapped.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-uv-mapped.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-uv-mapping.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-uv-mapping.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/blender-uv-mapping.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/blender-uv-mapping.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-export-svg.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-export-svg.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-export-svg.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-export-svg.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-export-texture.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-export-texture.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-export-texture.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-export-texture.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-joined-artwork.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-joined-artwork.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-joined-artwork.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-joined-artwork.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-joined-surfaces.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-joined-surfaces.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-joined-surfaces.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-joined-surfaces.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-new-document.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-new-document.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-new-document.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-new-document.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-separate-artwork.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-separate-artwork.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/illustrator-separate-artwork.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/illustrator-separate-artwork.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/index.md b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/index.md similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/index.md rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/index.md diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/overview.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/overview.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/overview.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/overview.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/t2-example.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/t2-example.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/t2-example.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/t2-example.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-decal-material-preview.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-decal-material-preview.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-decal-material-preview.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-decal-material-preview.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-imported.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-imported.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-imported.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-imported.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-textured.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-textured.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-textured.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-textured.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-transparent-textured.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-transparent-textured.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-transparent-textured.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-transparent-textured.png diff --git a/VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-transparent.png b/VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-transparent.png similarity index 100% rename from VisualPinball.Unity/Documentation~/creators-guide/tutorials/relatistic-plastics/unity-transparent.png rename to VisualPinball.Unity/Documentation~/creators-guide/tutorials/realistic-plastics/unity-transparent.png diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Display/ScoreReelDisplayInspector.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Display/ScoreReelDisplayInspector.cs index df354d35d..471792844 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Display/ScoreReelDisplayInspector.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Display/ScoreReelDisplayInspector.cs @@ -37,10 +37,14 @@ private void OnEnable() public override void OnInspectorGUI() { + serializedObject.Update(); + EditorGUILayout.PropertyField(_idProperty, new GUIContent("ID")); EditorGUILayout.PropertyField(_speedProperty); EditorGUILayout.PropertyField(_waitProperty); EditorGUILayout.PropertyField(_reelObjectsProperty); + + serializedObject.ApplyModifiedProperties(); } } } diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Utils/Icons.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Utils/Icons.cs index 041d0f9f3..6fbcf3c0c 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Utils/Icons.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Utils/Icons.cs @@ -73,6 +73,7 @@ public IconVariant(string name, IconSize size, IconColor color) private const string FlasherName = "light_flasher"; private const string FlipperName = "flipper"; private const string GateName = "gate"; + private const string GateLifterName = "gate_lifter"; private const string HitTargetName = "hit_target"; private const string KeyName = "keyboard"; private const string KickerName = "kicker"; @@ -113,7 +114,7 @@ public IconVariant(string name, IconSize size, IconColor color) private static readonly string[] Names = { AssetLibraryName, BallRollerName, BoltName, BumperName, CalendarName, CannonName, CoilName, DropTargetBankName, DropTargetName, FlasherName, - FlipperName, GateName, HitTargetName, KeyName, KickerName, LightGroupName, LightName, MechName, MechPinMameName, PlayfieldName, PlugName, + FlipperName, GateName, GateLifterName, HitTargetName, KeyName, KickerName, LightGroupName, LightName, MechName, MechPinMameName, PlayfieldName, PlugName, PlungerName, PrimitiveName, RampName, RotatorName, RubberName, ScoreReelName, ScoreReelSimpleName, SlingshotName, SpinnerName, SurfaceName, SwitchNcName, SwitchNoName, TableName, TeleporterName, TriggerName, TroughName, CoilEventName, SwitchEventName, LampEventName, LampSeqName, MetalWireGuideName, @@ -172,6 +173,7 @@ private static IIconLookup[] GetLookups() { public static Texture2D Flasher(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(FlasherName, size, color); public static Texture2D Flipper(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(FlipperName, size, color); public static Texture2D Gate(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(GateName, size, color); + public static Texture2D GateLifter(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(GateLifterName, size, color); public static Texture2D HitTarget(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(HitTargetName, size, color); public static Texture2D Key(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(KeyName, size, color); public static Texture2D Kicker(IconSize size = IconSize.Large, IconColor color = IconColor.Gray) => Instance.GetItem(KickerName, size, color); @@ -277,6 +279,7 @@ public Texture2D Lookup(T mb, IconSize size = IconSize.Large, IconColor color case DropTargetBankComponent _: return Icons.DropTargetBank(size, color); case FlipperComponent _: return Icons.Flipper(size, color); case GateComponent _: return Icons.Gate(size, color); + case GateLifterComponent _: return Icons.GateLifter(size, color); case HitTargetComponent _: return Icons.HitTarget(size, color); case KickerComponent _: return Icons.Kicker(size, color); case LightComponent _: return Icons.Light(size, color); @@ -322,6 +325,7 @@ public void DisableGizmoIcons() Icons.DisableGizmo(); Icons.DisableGizmo(); Icons.DisableGizmo(); + Icons.DisableGizmo(); Icons.DisableGizmo(); Icons.DisableGizmo(); Icons.DisableGizmo(); diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs new file mode 100644 index 000000000..8d99f35ff --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs @@ -0,0 +1,44 @@ +// Visual Pinball Engine +// Copyright (C) 2022 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 . + +using UnityEditor; +using UnityEngine; + +namespace VisualPinball.Unity.Editor +{ + [CustomEditor(typeof(GateLifterComponent)), CanEditMultipleObjects] + public class GateLifterInspector : UnityEditor.Editor + { + private SerializedProperty _angleProperty; + private SerializedProperty _speedProperty; + + private void OnEnable() + { + _angleProperty = serializedObject.FindProperty(nameof(GateLifterComponent.LiftedAngleDeg)); + _speedProperty = serializedObject.FindProperty(nameof(GateLifterComponent.AnimationSpeed)); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(_angleProperty, new GUIContent("Lifted Angle")); + EditorGUILayout.PropertyField(_speedProperty); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs.meta new file mode 100644 index 000000000..2629fcbbf --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/Gate/GateLifterInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9f8d7d8c69166434c867f04d7c8c5c3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity/Display/ScoreReelComponent.cs b/VisualPinball.Unity/VisualPinball.Unity/Display/ScoreReelComponent.cs index d4ec7352a..d0cfbbcc3 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/Display/ScoreReelComponent.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/Display/ScoreReelComponent.cs @@ -23,6 +23,14 @@ namespace VisualPinball.Unity { public class ScoreReelComponent : MonoBehaviour { + public enum ScoreReelDirection + { + Up, Down + } + + [Tooltip("In which direction the reel rotates, when looking from the front.")] + public ScoreReelDirection Direction = ScoreReelDirection.Down; + [HideInInspector] public float Speed = 1; @@ -35,6 +43,8 @@ public class ScoreReelComponent : MonoBehaviour private float _currentRotation; + private bool _isRotatingDown => Direction == ScoreReelDirection.Down; + public void AnimateTo(int position) { var numPositions = (position - _nextPosition + 10) % 10; @@ -48,9 +58,10 @@ public void AnimateTo(int position) private IEnumerator Rotate() { + var dir = _isRotatingDown ? 1 : -1; while (_remainingPositions > 0) { var lastPosition = (int)(_currentRotation / 36f); - _currentRotation += Time.deltaTime * Speed * 36f; + _currentRotation += dir * Time.deltaTime * Speed * 36f; var currentPosition = (int)(_currentRotation / 36f); _currentRotation %= 360f; diff --git a/VisualPinball.Unity/VisualPinball.Unity/Game/CoilPlayer.cs b/VisualPinball.Unity/VisualPinball.Unity/Game/CoilPlayer.cs index 2d2dd47fa..c1e0692bc 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/Game/CoilPlayer.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/Game/CoilPlayer.cs @@ -114,7 +114,8 @@ private void AssignCoilMapping(CoilMapping coilMapping, bool isLampCoil) } var hasDynamicWire = _tableComponent!.MappingConfig.Wires.FirstOrDefault(w => w.DestinationDevice == coilMapping.Device && - w.DestinationDeviceItem == coilMapping.DeviceItem) != null; + w.DestinationDeviceItem == coilMapping.DeviceItem && + w.IsDynamic) != null; _coilAssignments[coilMapping.Id].Add(new CoilDestConfig(coilMapping.Device, coilMapping.DeviceItem, isLampCoil, hasDynamicWire)); CoilStatuses[coilMapping.Id] = false; diff --git a/VisualPinball.Unity/VisualPinball.Unity/Game/Player.cs b/VisualPinball.Unity/VisualPinball.Unity/Game/Player.cs index 89c88f3a8..9e5b5545f 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/Game/Player.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/Game/Player.cs @@ -237,6 +237,11 @@ public void RegisterGate(GateComponent component, Entity entity) RegisterTransform(GateWireTransforms, component, entity); } + public void RegisterGateLifter(GateLifterComponent component) + { + Register(new GateLifterApi(component.gameObject, this), component); + } + public void RegisterHitTarget(HitTargetComponent component, Entity entity) { Register(new HitTargetApi(component.gameObject, entity, this), component, entity); diff --git a/VisualPinball.Unity/VisualPinball.Unity/Game/WirePlayer.cs b/VisualPinball.Unity/VisualPinball.Unity/Game/WirePlayer.cs index bf59bd680..fd7726c29 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/Game/WirePlayer.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/Game/WirePlayer.cs @@ -360,6 +360,9 @@ public void HandleSwitchChange(WireDestConfig wireConfig, bool isEnabled) /// Whether to enable or disable the coil. public void HandleCoilEvent(string id, bool isEnabled) { + if (!_gleDestAssignments.ContainsKey(id)) { + return; + } foreach (var wireConfig in _gleDestAssignments[id]) { if (!_wireDevices.ContainsKey(wireConfig.Device)) { continue; diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/CollidableApi.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/CollidableApi.cs index 0e12c851d..ffbc168b3 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/VPT/CollidableApi.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/CollidableApi.cs @@ -27,13 +27,20 @@ public abstract class CollidableApi : I where TCollidableComponent : ColliderComponent where TData : ItemData { + public bool IsCollidable { + get => _simulateCycleSystemGroup.ItemsColliding[Entity]; + set => _simulateCycleSystemGroup.ItemsColliding[Entity] = value; + } + protected readonly Entity Entity; protected readonly TCollidableComponent ColliderComponent; private protected EntityManager EntityManager; + private readonly SimulateCycleSystemGroup _simulateCycleSystemGroup; protected CollidableApi(GameObject go, Entity entity, Player player) : base(go, player) { + _simulateCycleSystemGroup = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem(); EntityManager = World.DefaultGameObjectInjectionWorld != null ? World.DefaultGameObjectInjectionWorld.EntityManager : default; Entity = entity; diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateApi.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateApi.cs index 2ad94e933..664fd21b8 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateApi.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateApi.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using Unity.Entities; +using Unity.Mathematics; using UnityEngine; using VisualPinball.Engine.VPT.Gate; @@ -78,6 +79,15 @@ public GateApi(GameObject go, Entity entity, Player player) { } + public void Lift(float speed, float angleDeg) + { + var data = EntityManager.GetComponentData(Entity); + data.IsLifting = true; + data.LiftSpeed = speed; + data.LiftAngle = math.radians(angleDeg); + EntityManager.SetComponentData(Entity, data); + } + #region Wiring public bool IsSwitchEnabled => SwitchHandler.IsEnabled; diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateDisplacementSystem.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateDisplacementSystem.cs index a307f6bf8..c07c58560 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateDisplacementSystem.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateDisplacementSystem.cs @@ -52,7 +52,7 @@ protected override void OnUpdate() Entities .WithName("GateDisplacementJob") - .ForEach((Entity entity, ref GateMovementData movementData, in GateStaticData data) => { + .ForEach((Entity entity, ref GateMovementData movementData, in GateStaticData data) => { marker.Begin(); @@ -117,6 +117,16 @@ protected override void OnUpdate() } } movementData.Angle += movementData.AngleSpeed * dTime; + + if (movementData.IsLifting) { + if (math.abs(movementData.Angle - movementData.LiftAngle) > 0.000001f) { + var direction = movementData.Angle < movementData.LiftAngle ? 1f : -1f; + movementData.Angle += direction * (movementData.LiftSpeed * dTime); + + } else { + movementData.IsLifting = false; + } + } marker.End(); diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs new file mode 100644 index 000000000..f989dde81 --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs @@ -0,0 +1,95 @@ +// Visual Pinball Engine +// Copyright (C) 2022 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 . + +using System; +using NLog; +using UnityEngine; +using Logger = NLog.Logger; + +namespace VisualPinball.Unity +{ + public class GateLifterApi : IApi, IApiCoilDevice, IApiWireDeviceDest + { + public DeviceCoil LifterCoil; + + public event EventHandler Init; + + private readonly Player _player; + private readonly GateComponent _gateComponent; + private readonly GateLifterComponent _gateLifterComponent; + private readonly GateColliderComponent _gateColliderComponent; + + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private GateApi _gateApi; + + internal GateLifterApi(GameObject go, Player player) + { + _gateComponent = go.GetComponent(); + _gateColliderComponent = go.GetComponent(); + _gateLifterComponent = go.GetComponent(); + _player = player; + } + + void IApi.OnInit(BallManager ballManager) + { + LifterCoil = new DeviceCoil(_player, OnLifterCoilEnabled, OnLifterCoilDisabled); + _gateApi = _player.TableApi.Gate(_gateComponent); + Init?.Invoke(this, EventArgs.Empty); + } + + public IApiCoil Coil(string deviceItem) + { + return deviceItem switch { + GateLifterComponent.LifterCoilItem => LifterCoil, + _ => throw new ArgumentException($"Unknown coil \"{deviceItem}\". Valid name is \"{GateLifterComponent.LifterCoilItem}\".") + }; + } + + public IApiWireDest Wire(string deviceItem) + { + return deviceItem switch { + GateLifterComponent.LifterCoilItem => LifterCoil, + _ => throw new ArgumentException($"Unknown wire \"{deviceItem}\". Valid name is \"{GateLifterComponent.LifterCoilItem}\".") + }; + } + + private void OnLifterCoilEnabled() + { + if (_gateColliderComponent == null) { + Logger.Warn("Lifter coil enabled, but gate collider not found."); + return; + } + + _gateApi.IsCollidable = false; + _gateApi.Lift(_gateLifterComponent.AnimationSpeed, _gateLifterComponent.LiftedAngleDeg); + } + + private void OnLifterCoilDisabled() + { + if (_gateColliderComponent == null) { + Logger.Warn("Lifter coil enabled, but gate collider not found."); + return; + } + + _gateApi.IsCollidable = true; + _gateApi.Lift(_gateLifterComponent.AnimationSpeed, 0f); + } + + void IApi.OnDestroy() + { + } + } +} diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs.meta b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs.meta new file mode 100644 index 000000000..08852d8d2 --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterApi.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dae30298e10a0894c991d49ceb01e001 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs new file mode 100644 index 000000000..9c6969bc4 --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs @@ -0,0 +1,57 @@ +// Visual Pinball Engine +// Copyright (C) 2022 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 . + +// ReSharper disable InconsistentNaming + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using VisualPinball.Engine.Game.Engines; + +namespace VisualPinball.Unity +{ + [RequireComponent(typeof(GateComponent))] + [AddComponentMenu("Visual Pinball/Mechs/Gate Lifter")] + public class GateLifterComponent : MonoBehaviour, ICoilDeviceComponent + { + public const string LifterCoilItem = "lifter_coil"; + + [Unit("degrees")] + [Tooltip("How much to rotate the wire to the end position, in degrees.")] + public float LiftedAngleDeg; + + [Tooltip("How fast to lift the wire to the end position.")] + public float AnimationSpeed = 0.1f; + + #region ICoilDeviceComponent + + IEnumerable IDeviceComponent.AvailableDeviceItems => AvailableCoils; + IEnumerable IWireableComponent.AvailableWireDestinations => AvailableCoils; + IEnumerable IDeviceComponent.AvailableDeviceItems => AvailableCoils; + public IEnumerable AvailableCoils => new[] { + new GamelogicEngineCoil(LifterCoilItem) { + Description = "Lifter Coil" + } + }; + + #endregion + + private void Awake() + { + GetComponentInParent().RegisterGateLifter(this); + } + } +} diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs.meta b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs.meta new file mode 100644 index 000000000..819d73ff8 --- /dev/null +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateLifterComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab2020dc8f79c7543b66ff6ec8830aed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 089b7800e18ce404c8608d12ff6c9447, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateMovementData.cs b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateMovementData.cs index 75e729cf9..685df1b9f 100644 --- a/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateMovementData.cs +++ b/VisualPinball.Unity/VisualPinball.Unity/VPT/Gate/GateMovementData.cs @@ -25,5 +25,9 @@ internal struct GateMovementData : IComponentData public bool ForcedMove; public bool IsOpen; public bool HitDirection; + + public bool IsLifting; + public float LiftAngle; + public float LiftSpeed; } }