Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clickable plane demo #94

Merged
merged 8 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 78 additions & 0 deletions OmsiExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,73 +25,150 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TriggersSample", "_OmsiHook
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoDemo", "_OmsiHookExamples\VideoDemo\VideoDemo.csproj", "{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClickablePlaneDemo", "_OmsiHookExamples\ClickablePlaneDemo\ClickablePlaneDemo.csproj", "{49428923-732C-4541-8C97-C6D9C004D726}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
ReleaseAndDocs|Any CPU = ReleaseAndDocs|Any CPU
ReleaseAndDocs|x86 = ReleaseAndDocs|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.ActiveCfg = Debug|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.Build.0 = Debug|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.ActiveCfg = Debug|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.Build.0 = Debug|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.ActiveCfg = Release|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.Build.0 = Release|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.ActiveCfg = Release|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.Build.0 = Release|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|Any CPU.ActiveCfg = ReleaseAndDocs|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|Any CPU.Build.0 = ReleaseAndDocs|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|x86.ActiveCfg = ReleaseAndDocs|x86
{2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|x86.Build.0 = ReleaseAndDocs|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.ActiveCfg = Debug|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.Build.0 = Debug|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.ActiveCfg = Debug|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.Build.0 = Debug|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Release|Any CPU.ActiveCfg = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Release|Any CPU.Build.0 = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.ActiveCfg = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.Build.0 = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|x86.Build.0 = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|Any CPU.ActiveCfg = Debug|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|Any CPU.Build.0 = Debug|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|x86.ActiveCfg = Debug|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|x86.Build.0 = Debug|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|Any CPU.ActiveCfg = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|Any CPU.Build.0 = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|x86.ActiveCfg = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|x86.Build.0 = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|x86.Build.0 = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|Any CPU.ActiveCfg = Debug|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|Any CPU.Build.0 = Debug|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x86.ActiveCfg = Debug|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x86.Build.0 = Debug|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|Any CPU.ActiveCfg = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|Any CPU.Build.0 = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|x86.ActiveCfg = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|x86.Build.0 = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|x86.Build.0 = Release|x86
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|Any CPU.Build.0 = Debug|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x86.ActiveCfg = Debug|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x86.Build.0 = Debug|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|Any CPU.ActiveCfg = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|Any CPU.Build.0 = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|x86.ActiveCfg = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|x86.Build.0 = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|Any CPU.Build.0 = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.ActiveCfg = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.Build.0 = Release|Win32
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.ActiveCfg = Debug|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.Build.0 = Debug|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.Build.0 = Release|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.ActiveCfg = Release|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.Build.0 = Release|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|Any CPU.Build.0 = Release|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|x86.Build.0 = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.ActiveCfg = Debug|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.Build.0 = Debug|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.ActiveCfg = Debug|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.Build.0 = Debug|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.ActiveCfg = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.Build.0 = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.ActiveCfg = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.Build.0 = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|x86.Build.0 = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.ActiveCfg = Debug|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.Build.0 = Debug|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.ActiveCfg = Debug|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.Build.0 = Debug|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.ActiveCfg = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.Build.0 = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.ActiveCfg = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.Build.0 = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|x86.Build.0 = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|Any CPU.ActiveCfg = Debug|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|Any CPU.Build.0 = Debug|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|x86.ActiveCfg = Debug|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|x86.Build.0 = Debug|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|Any CPU.ActiveCfg = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|Any CPU.Build.0 = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|x86.ActiveCfg = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|x86.Build.0 = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|x86.Build.0 = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Debug|Any CPU.ActiveCfg = Debug|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Debug|Any CPU.Build.0 = Debug|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Debug|x86.ActiveCfg = Debug|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Debug|x86.Build.0 = Debug|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Release|Any CPU.ActiveCfg = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Release|Any CPU.Build.0 = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Release|x86.ActiveCfg = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.Release|x86.Build.0 = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.ReleaseAndDocs|Any CPU.Build.0 = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.ReleaseAndDocs|x86.ActiveCfg = Release|x86
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}.ReleaseAndDocs|x86.Build.0 = Release|x86
{49428923-732C-4541-8C97-C6D9C004D726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Debug|x86.ActiveCfg = Debug|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Debug|x86.Build.0 = Debug|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Release|Any CPU.Build.0 = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Release|x86.ActiveCfg = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.Release|x86.Build.0 = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.ReleaseAndDocs|Any CPU.ActiveCfg = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.ReleaseAndDocs|Any CPU.Build.0 = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.ReleaseAndDocs|x86.ActiveCfg = Release|Any CPU
{49428923-732C-4541-8C97-C6D9C004D726}.ReleaseAndDocs|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -101,6 +178,7 @@ Global
{47659503-9923-4E74-AD26-103C1F9FF2B0} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5}
{1DF326AE-4D10-4545-B36A-5622B76987EC} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5}
{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5}
{49428923-732C-4541-8C97-C6D9C004D726} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A5F55305-C8FF-444C-9B98-FD487ADC583A}
Expand Down
40 changes: 40 additions & 0 deletions OmsiHook/docs/articles/examples/clickable-plane-demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Clickable Plane Demo

This article provides a basic understanding to a basic C# .NET example leveraging the OMSIHook library. This demo is a more advanced
demo using a specially made mesh (available [here](/doc-resources/ClickablePlaneDemo/_touch_surface.o3d)) and some of the model data properties to paint onto a script texture.

_This article is in direct relation to the Sample Project available [here](https://github.com/space928/Omsi-Extensions/tree/main/_OmsiHookExamples/ClickablePlaneDemo)._

![Paint Demo](/images/Paint-demo.png)

## Coordinate calculation
To achieve the click detection, the global mouse events are monitored, a ray is cast from the cursor onto the plane, it's intersection is computed and converted into a local coordinate space.

## The Mesh
The mesh has to be created in a specific way to allow it to be computed correctly due to how the data is accessed, we use the object transformation matrix rather than the raw vertex positions, as such for the best effect a 1m by 1m plane should be created then use the mesh transformation matrix to position scale and rotate it. This would limit this technique to flat planes however in most use cases this is an acceptable compromise.

## Model.CFG
The model configuration file is a fairly simple one - simply defining a script texture, mesh and a mouse event

```ini
2: OH Paint Demo
[scripttexture]
1024
1024


-=-=-=-=-=-=-=-=-=-=-

[mesh]
_touch_surface.o3d

[matl]
D_Matrix.bmp
0

[useScriptTexture]
2

[mouseevent]
OH_Click
```
2 changes: 2 additions & 0 deletions OmsiHook/docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
href: examples\triggers-sample.md
- name: Basic Events Example
href: examples\event-sample.md
- name: Clickable Plane Demo
href: examples\clickable-plane-demo.md
- name: Video Playback Demo
href: examples\video-demo.md
Binary file not shown.
3 changes: 2 additions & 1 deletion OmsiHook/docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"resource": [
{
"files": [
"images/**"
"images/**",
"doc-resources/**"
]
}
],
Expand Down
Binary file added OmsiHook/docs/images/Paint-demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions _OmsiHookExamples/ClickablePlaneDemo/ClickablePlaneDemo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartupObject>ClickablePlaneDemo.Program</StartupObject>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OmsiHook" Version="2.4.4" />
</ItemGroup>

</Project>
Loading
Loading