Download

Integrating MATLAB With Sheel Extension ?

Hello mates !

I managed to synthesize physically based gun sounds with equations on MATLAB and able to write them on wav files. It is my thesis work on Game Technologies.
You define caliber, barrel length, your azimuth and distance to gun and get the Muzzle Blast with one reflection, Cracking Sound and Impact Sound. Good for FPS, TPS, action games and animations. No longer searching for free firearm sounds on the net.

Here is a form of Muzzle Blast M16 (5.56 NATO, 18 meters)

So now I want to integrate it into UE4 in some way. It would be a great way to demonstrate it and even a bit later I can release it to community.My advisor told me about a possiblity of turning it into an .exe and using shell extension to integrate it into UE4. I am not good with this stuff yet.

Is it possible ? Is there an easier way ? Or how to do this ?

Thanks.

I suppose the question is how to get UE4 to communicate with MATLAB, correct? Does it need to happen real-time or would it be through some interim file/process on the disk?

I wouldn’t do it through a .exe shell extension as for one it limits it to a single platform (Windows), plus it might need elevated privileges to setup/run.

I did not look into MATLAB API so that’s something you need to check, but with UE4 you can add plugins to communicate with external events/processes or use existing things (perhaps OSC comes to mind, not sure if applicable here).

Maybe if you give us more details, we could come up with a way of integration?

I know this post is old, but I am working on something similar for my thesis.

MATLAB has an API and can interface with C++.

The documentation for that is: https://www.mathworks.com/help/matlab/calling-matlab-engine-from-c-c-and-fortran-programs.html
with a video of how to do it in Visual Studio here: Integrating MATLAB and C/C++, Part 2: Visualizing and Testing C/C++ Code - Video - MATLAB

What needs to happen is you need to add the following directory for includes:
C:\Program Files\MATLAB\R2015b\extern\include

Add the following directory for libraries:
C:\Program Files\MATLAB\R2015b\extern\lib\win64\microsoft

And add the following libraries to your solution:
libmx.lib
libmat.lib
libeng.lib

From what I have understood of adding these to an unreal program, you need to modify the build.cs by adding the following lines (i don’t know if this could be cleaner…):
PublicSystemIncludePaths.Add(“C:/Program Files/MATLAB/R2015b/extern/include”);

PublicLibraryPaths.Add(“C:/Program Files/MATLAB/R2015b/extern/lib/win64/microsoft”);

PublicAdditionalLibraries.Add(“C:/Program Files/MATLAB/R2015b/extern/lib/win64/microsoft/libmx.lib”);
PublicAdditionalLibraries.Add(“C:/Program Files/MATLAB/R2015b/extern/lib/win64/microsoft/libmat.lib”);
PublicAdditionalLibraries.Add(“C:/Program Files/MATLAB/R2015b/extern/lib/win64/microsoft/libeng.lib”);

When I do this, everything compiles fine. The problem begins when I try to run a new instance and debug the program. I get the following error:

The program can’t start because libeng.dll is missing from your computer. Try reinstalling the program to fix this problem.

I know the dll exists. It exists at C:/Program Files/MATLAB/R2015b/bin/win64/.

When I had this issue just doing this for a normal visual studio program, I added the following to the Environment in the properties tab of the project:

PATH=C:\Program File\MATLAB\R2015b\bin\win64\

And it fixed it.

However, when I do the same for unreal, it does not work…any ideas?

I know its been a long time, maybe you found the solution or maybe quit but i will send the code i use for sharing data via staticlibrary method any way

this is .build.cs from my game prject. I needed to send some data to another application via sockets, and i add the socket part in a static library and use this library in my game. Since you are doing the same thing (static library i’m guessing) maybe this thing can help

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System;
using System.IO;
using System.Text.RegularExpressions;

public class BugsAndLizards : ModuleRules
{
public BugsAndLizards(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string] { “Core”, “CoreUObject”, “Engine”, “InputCore”, “HeadMountedDisplay” });

    //----------------TELEMETRY
    bool isLbrSupported = false;
    string ThirdPartyPath = "D:/Unreal Projects/BugsAndLizards/ThirdParty/";
    if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
    {
        isLbrSupported = true;
        string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
        string LibrariesPath = Path.Combine(ThirdPartyPath, "TelemetrySender", "Libraries");

        PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "TelemetrySender." + PlatformString + ".lib"));
    }

    if (isLbrSupported)
        PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "TelemetrySender", "Includes"));

    Definitions.Add(string.Format("WITH_TelemetrySender_BINDING={0}", isLbrSupported ? 1 : 0));


    //----------------TELEMETRY
}

}

any comment to use things like this on blueprints, please?