Unreal engine integration

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Unreal engine integration

Postby PJani » Sun Jul 08, 2018 1:55 pm

Hey everyone!
And hey Julio!


I used Newton Physics engine A LOT in combination with Ogre3D. I have used modified wrapper for Newton and Ogre. The lack of Ogre3D development put me off. Developing anything useful without proper editor in Ogre3D is such a pain.

I have been busy with work and stuff for the past 4 years and I have used Unity engine for almost 4 years now and PhysiX(sorry fanboys) * big time, especially the Unity integration. Performance is bad and customization is non existant.

I have used Newton a lot in my old days. Its one of the best physics engines available. If there was a way to integrate Newton into Unreal Engine. Sadly I don't have much time anymore at hand to undertake such task.

The best feature that Newton has it is, its ability to make custom Joints. I love this engine. It is just one of the best. Period.

Basically I am asking if there is any existing integration in Unreal?
Last edited by PJani on Wed Aug 08, 2018 4:51 am, edited 1 time in total.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Unreal engine integration

Postby Dave Gravel » Sun Jul 08, 2018 6:17 pm

This can maybe help for compile newton with unreal engine.

Link:
https://github.com/hausfrau87/Boost_PCL ... artyPlugin

The most big problem I can see is about rewrite all physx options for all objects properties with newton.
Physx is implemented with many objects class in the engine.
The other place where I can see problem is about network multiplayer options...
It can come long to rewrite all and setup all to get similar result or better.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby PJani » Mon Jul 09, 2018 6:33 pm

Hmm I see. Basically the problem is with wrapper. But at least it looks like its not impossible. :)

Tnx for info. Will see what I can do.

I found Julios post about him trying to integrate Newton Engine into Unreal engine build pipeline.

Not sure what happend with that at the end :)
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Unreal engine integration

Postby Dave Gravel » Mon Jul 09, 2018 8:21 pm

Yes, I have do some tests here on older unreal version without success. I have just get some parts working but the plugin method have change now. Later I have find this link but I don't have get time for test it.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Dave Gravel » Tue Jul 10, 2018 1:49 am

I have success to make a plug-in and compile it with newton and customjoints.
I get only warning from customjoints Deserialize procedure.
Newton don't seen to cause any problem for now.
I can load the plug-in with newton without error.

Now I need to see how I can use it and create objects and update the world.
I have already some ideas about how to do it, but I never have test.
If you don't get it working, I let's you know later how it going for me.

Screenshots:
https://sites.google.com/site/evadlevarg/UTNewton.png
https://sites.google.com/site/evadlevarg/UTNewton2.png

Here a exemple test exe with newton.dll + Unreal Engine :
http://www.mediafire.com/file/7js3yyo9t ... namics.zip

The exemple only Init newton.dll and create a NewtonWorld, no dynamics object.
You can start the exemple and close it with escape.
Open the last log in folder OXNewtonDynamics\Saved\Logs
You can find in the log NewtonDynamics: ## Newton World Created Successfully.
NewtonDynamics: ## Newton World Successfully Destroyed.

Or just rename the Newton.dll to a temporary name and execute the exemple again, and see what happen.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Julio Jerez » Tue Jul 10, 2018 1:58 pm

David are you making and unreal plugin?
Am I reading this right?
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unreal engine integration

Postby Dave Gravel » Tue Jul 10, 2018 2:02 pm

I'm looking for this yes, I can create the newtonworld successfully.
I try to see the best way to do the implementation.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby PJani » Tue Jul 10, 2018 2:33 pm

Dave Interesting stuff :P i must say :)

I wonder how it will work.

But the PhysiX gets replaced or?
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Unreal engine integration

Postby Julio Jerez » Tue Jul 10, 2018 2:44 pm

PJani wrote:
Tnx for info. Will see what I can do.

I found Julios post about him trying to integrate Newton Engine into Unreal engine build pipeline.

Not sure what happend with that at the end :)

What happens was that I was trying to integrate Newton the same way they integrate physx, so that the end use could select a physic solver from a section list and all existing functionality would work.
This turned out to be a huge task because unreal decided to make internal Unreal assets, physx native types, so scripts and all kind of other interfaces read those types.

I am not sure why the did that instead of making an abstract layer that any physics solution can derived from, but that move make it virtually impossible for a small developer to take sush large task for not gain whatsoever.
when I realized that that kind of integration would be rejected summarily because it required internal changes of unreal, I abandoned the project.

The best way to do it like David said a plain vanilla plugin that will required the user to recreate the assets by adding that physic component manually.

This is a very big task, if you look at unreal tick update of Pawns, the pawn assume it has physics component, and will try the script try to use it, this rules out using Pawns, but the moment you has to make a new Pawn as base class, then you practically have nothing, SkelatalMesh would not work, so are other subpawn and so on.

We can resumed if you guys want to make a vanilla plug in I am all for it, It is just that I do not want to be the single owner.
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unreal engine integration

Postby Dave Gravel » Tue Jul 10, 2018 2:58 pm

But the PhysiX gets replaced or?

For now I don't have try to disable physx.
I just don't call it and don't use physx object, it is present in background.

Currently I try to create only a base plug-in, with custom newton objects without physx.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Dave Gravel » Sat Jul 14, 2018 1:27 pm

Hi, This video show what I currently get from my plugin newton.
I get problem about the matrix mesh rotation and scale.
I'm not 100% sure from where exactly the problem coming, I try to fix it.

Edit: The objects can use a auto initnewton method, or use the blueprint method.
The Newton update is normally done inside the component manager, The blueprint method that I use in the video is only for test.
My first test is with staticmesh, now i'm going to try with custom mesh.

Video:
https://www.youtube.com/watch?v=jAi4zMIXdT0
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Dave Gravel » Mon Jul 16, 2018 1:37 am

Experimental tests, not the final implementation.

Plugin V2 Video:
https://www.youtube.com/watch?v=-ZiBKOEh528


Newton Dynamics + UT collision system.
Plugin V3 Video:
https://www.youtube.com/watch?v=C8f7ekNaL_I
Last edited by Dave Gravel on Fri Jul 20, 2018 11:50 am, edited 1 time in total.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Julio Jerez » Tue Jul 17, 2018 2:11 pm

are you planning to put this on GitHub?
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unreal engine integration

Postby Dave Gravel » Tue Jul 17, 2018 4:51 pm

Hi Julio,
I wait before do anything like this.
Like I have already say before in a other post,
I don't try to make money with my stuff.
I make this plugin for let's it public.
I just wait to get something ready to use with all newton basic objects and basic joints.
I never have use GitHub for project, I don't have any problem to make one when I come ready about the code.

The real problem I don't have choose again for the final way to implement the manager.
I have try to create a gamemode class with newton manager integrated, but it cause many problems.
The gamemode class is bad idea to use, Because many people use personal gamemode class already.
The gamemode sceneroot and BeginPlay and some other parts behaving differently on gamemode class.

You need to have access to the newton manager from anywhere,
And it need to become the first created component and the first updated component.
It coming complex to make a simple newton component manager.
The newton dll is load when the plugin is load,
The manager need to become create after this,
And all newton objects after the manager creation.
The manager class need to have access to a Tick() update function,
Or you need to do it from a function in blueprint.
The other major problem is about editor mode and final game packaged mode.
The editor can do simulation in blueprint for test your stuff, and in the editor you can play the total scene.
It is where the order to create the manager and the newton object become important...
The simulation and the playmode from the editor do not execute or use all the same way order or functions.

I get a other problem to transform the objects normally too.
I can't use NewtonTransformCallback normally, I need to do it manually.
I can call NewtonTransformCallback for any objects, I can modify a simple variable inside the callback.
The problem start when I try to modify the object transform from the NewtonTransformCallback, It give a error.
I think it happen because multithreading race condition between newton and unreal thread.
I have try to put a lock, but it don't seen to work.
Maybe to make it work I need to disable the Tick() from any newton objects and let's only the manager have the Tick().
The transform in unreal is surely updated from the tick update, maybe it conflic with newton.
For now I set the manager tick update to PrePhysics, And I set the object tick to DuringPhysics or PostPhysics...
In the NewtonTransformCallback I set the transform to the object but I don't apply it, I set a personal flag TransformUpdated.
In the object tick I read the personal flag TransformUpdated and I update the transform if it have change.

It's the only working way that I have find for now.
Any commands to transform a ut object in NewtonTransformCallback crashing..
You can only assign the value and update the component transform outside the callback.
I don't have try to hack unreal engine loop,
I know where to modify the engine loop but I don't think to touch or modify it.
I'm not sure if it is possible to get a better way about the transform without modify the unreal engine code.
One good thing with this method you can continue to query physx and mix it with newton,
For exemple interacting with particles collision or fracture particles or bullets collision & playercontroller...

I need to test more but currently it give nice results.
With this way your are limited to configure the newton step with the physx step setup value.

Currently to get all working in good order the best I have find is to create the manager in a modified actor class.
On this way I can create all newton object as children, and edit or simulate it anytimes without take care about manager order creation or update.
The order is important because all meshes is create with newton and the manager need to become created if you like to display mesh in the editor mode.
I have choose to try this way for now, I'm close to have something to share in public.
I currently work on my custom mesh object to get the visual in the editor mode, And I need to add joints.
The visual c++ intellisense is very slow with ut plugin + the whole compile time, sometimes it become long to just change little things and tests hehe :cry: .

Sorry about my english explanation...
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Unreal engine integration

Postby Dave Gravel » Tue Jul 17, 2018 7:34 pm

This is the error that I get when I try to use the NewtonTransformCallback normally.
To me it seen like a multithreading error.

Image:
https://sites.google.com/site/oxnewton/updateerror.png

Text:
https://sites.google.com/site/oxnewton/updatetrans.txt

This error happen if I call
ent->mesh->SetWorldTransform(vTrans); inside the NewtonTransformCallback
Or any other commands to transform the object give the same error.

My work around in NewtonTransformCallback I set only the variable like this
ent->mesh->RelativeLocation = vTrans.GetLocation();
ent->mesh->RelativeRotation = vTrans.Rotator();

Inside the objects mesh Tick() I call UpdateComponentTransforms();
It is the only way how I can get it working without error.

Edited:
I need to try without use the UObject as UserData and just use a custom pointer, Maybe it can fix the problem with the transform callback.
I'm going to try this method tonight.
PS:
After have think more to it and tests.
Any pointer types do the same behaving because the problem is not the pointer.
The problem is to apply the transform on the UTObject inside the callback.
About the tick, It is possible to make a custom Tick() class derrived, but it's a complex class to deal with.
Last edited by Dave Gravel on Thu Jul 19, 2018 12:15 am, edited 1 time in total.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Next

Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron