Newton Plugin for Unity 3D

Share with us how are you using the powerrrr of the force

Moderator: Alain

Re: Newton Plugin for Unity 3D

Postby Sweenie » Sun May 01, 2016 5:14 pm

Lets us cross our fingers and ther si not multithread creation


That shouldn't be a problem.

GameObjects and scripts are only running on the mainthread. In fact, Unity won't allow you to access a GameObject from another thread.

ye I guess we will have to do the same check even for collision


Well, if just let the colliders be types("empty" component with only Editor fields), they don't need the world. It's the body that create the dNewtonCollider. NewtonBody only use the NewtonCollider component to know what collider to create.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Sun May 01, 2016 10:04 pm

Sweenie wrote:Well, if just let the colliders be types("empty" component with only Editor fields), they don't need the world. It's the body that create the dNewtonCollider. NewtonBody only use the NewtonCollider component to know what collider to create.


yes, that would be the best, but I do not see how to do that. how to add a way to select form a drop down list of choices?
I read over the unity doc, all I can find is about component selections
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Sweenie » Mon May 02, 2016 12:16 am

Ah, you mentioned that yourself earlier.

If you created a component you can add a class attribute.

Like this...

Code: Select all
[AddComponentMenu("Newton Physics/Rigid Body")]
Class NewtonBody : MonoBehaviour

This will make the component visible in the component selector and also the top menu.

Image
Image

You can also add a component by drag and drop from the assets browser
Image
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Plugin for Unity 3D

Postby eliawestworld » Mon May 02, 2016 3:13 pm

Hello everyone , my name is Elia.

I am developing a motorcycle video game Unity3d .
My project is at the intial stage .
I saw your plugin and are very interested in developing newtondynamics in Unity3d .
I need help and I want more references and explanations regarding the library on Unity3D .

I have in Physx this problem show in my forum.Newton dynamics is better?
For collision and joint stability.

http://forum.saintwest-dev.com/viewtopic.php?f=7&t=41

http://saintwest-dev.com/
eliawestworld
 
Posts: 3
Joined: Mon May 02, 2016 3:07 pm

Re: Newton Plugin for Unity 3D

Postby Sweenie » Tue May 03, 2016 12:57 am

Hi.

This plugin isn't ready for use yet, it's still very early in the project.

I don't read or speak italian but from what I could translate you use Physx and have problems with collision response at high velocities using larger timesteps?
You tried reducing the time step to smaller values but physics than takes more cpu time than you can afford?

Do you simulate the motorcycle wheels using rigid bodies or raycast/wheel collider?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Plugin for Unity 3D

Postby eliawestworld » Tue May 03, 2016 1:19 am

I use Physx rigidbody and mesh for wheel.
Yes my problem is cpu performance and collision problem at high velocity.
Please let I need help to solve the problem on its wheels .
Also describe how to use the raycast help me .
But I think the raycast should be cast in more points and not just at a point perperdicolare the wheel .
newtondynamics collider have this same problem?
Please I need help.
eliawestworld
 
Posts: 3
Joined: Mon May 02, 2016 3:07 pm

Re: Newton Plugin for Unity 3D

Postby Sweenie » Tue May 03, 2016 2:26 am

I haven't used the WheelCollider in Unity that much but by reading in the Unity forums I believe that before Unity 5 the WheelCollider was doing a shape cast(raycast using a convex) which is needed to get smoother interaction with uneven terrain.

In Unity 5 the wheelcollider is using a normal raycast which only works well on flat or smooth terrains.

A shape cast is more forgiving and will have a higher chance of "detecting" obstacles.

But it looks like you are making some kind of high speed motorcycle racing game, what collisions are you having problem with? The tracks for those kind of games are usually very flat with no obstacles and should work fine with normal ray casts.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Newton Plugin for Unity 3D

Postby eliawestworld » Tue May 03, 2016 5:48 am

You can not help me with newtondynamics ?
eliawestworld
 
Posts: 3
Joined: Mon May 02, 2016 3:07 pm

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Tue May 03, 2016 9:53 am

we would like to help you, but we are not in the position to do so now.
we just start to make this plugin in, and it is on a very early stage.
maybe after we have a working version .
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Tue May 03, 2016 2:44 pm

Kaos wrote:
Is it possible to give steering to the backwheels?
Monster trucks have sometimes a setup where this are moveable too. And with an adjustable degree of some sorts so its not always exactly the mirrored of the front wheels.

Advanced suspension setup is something one can then do by themselvs or as demo do this in unity i suspect its easier/faster to setup this visually than in your current demo scene. But thats just standard joint stuff.

And the rest is just setup stuff... it could swing a bit more for my taste ;D
And its abit too stable ..
you can make a full turn at top speed without topling or heavy drifting. But i admit that is partly a visual and sound things without hearing slipping and seeing dirt fly its harder to get a feeling for that kind of thing. But i watched quite a few monster truck shows when i was little and i saw them flip at corners and having trouble with staying on gas in corners.


you wish is my command, four wheel turn, with the rear wheel turning lest and configurable suspensions. The suspension has three settings m_offroad, m_confort, m_race.

I drove the monster truck and if you do hard turn now is doe role over. The viper now can do don ought burnouts, and it does not even has the lateral control assistance.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Kaos » Tue May 03, 2016 5:28 pm

Thanks Julio,
i dont have time to try that out now but thank you.
I want to wait and see now, till your mostly done and need someone testing, instead of taking more of your time for nothing.

The other thing from my last post was a little missunderstanding because it was more about naming stuff instead of the actual relations or workings of code.

And i have to say that there may be another thing with that kind of thing, if you dont mind.
Since you come from c++ youre working mostly with an hungarian notation?
for example: "m_world" "dNewton"

In c# they decided to take another aproach. :D
https://msdn.microsoft.com/en-us/librar ... 10%29.aspx

Not that i care that much since i'm kind of an "as long as it works", kinda guy.
But If you do more in c# may begin to wonder why most code will look diffrent.

I dont wanna start an naming convention war or tell someone how to do things so please dont take it like that. I just give you some information.
Kaos
 
Posts: 38
Joined: Mon Apr 18, 2016 11:24 pm

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Thu May 12, 2016 2:40 pm

Ok Sweenie last weekend I did no do anything for the plugin. Let us resume this weekend if w=you have time.

Last time we try to decide weather we want to make the collision shape unity components or some kind of data member of a rigid body.

I have one question, and ay sodun naïve, but we are making a native plugin aren't we?
even is the is C++ code, the swig wraper do all the house keeping to make the code appear as managed does it.
Like if we want to move to another platform, wll we nee to do is to be able to compile the C++ engine for that platform and should works.


finally the goal I am setting for thee wee is to get to the point where we can make a science, form Unity and place a Box as the floor, and add boxed at will,
and we need to be able to open close, and edit the scene without crashes.

I hope we can get that resolved so that we can make more progress
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Thu May 12, 2016 2:53 pm

Sweenie wrote:Well, I tried to recreate how Unity handles collision shapes.

First you have the Game Object with the Rigid Body Component (NewtonBody).
When the NewtonBody is created it will look for NewtonCollision components, first in it's own Game Object and also in it's children Game Objects.

I use the Unity function FindComponentsInChildren<NewtonCollision>()

what was wrong with that approach?
I was under the impression that you said earlier that Unit will create components out of order.
or was I confusing GameObject with components?


The was I see the a physics world layout can be like this:
-NewtonWord is a unique component of a GameObjects.
-NewtonRigifBody is a Unique Component of a Game object.

I was thinking that NewtonCollision should be a component of a RigidBody, but that is wrong

I think it is better we can make a Netwo collision components of a Game object.
A Game object can have as many collision shape as it needs.
to go around the problem that the can be a Game object with a Body, but not a shape,
we can add a default NULL shape.

if for example a body has shape by no bodies we can add a default body and make static body.
do you think that is reasonable?

is so, then only problem we have to worry about is the order of creation of worlds and Bodies.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Julio Jerez » Thu May 12, 2016 3:05 pm

Oh I see, the way we can make a drop down list of component is by adding these lines in front of the class,

    [AddComponentMenu("Newton Physics/Colliders/Box")]
    [AddComponentMenu("Newton Physics/Colliders/Convex Hull Collider")]

but how do we make sure that can only be added to NewtonBodies? maybe like thos

    [AddComponentMenu("Rigid Body/Colliders/Box")]
    [AddComponentMenu("Rigid Body/Colliders/Convex Hull Collider")]

or like this
    [AddComponentMenu("Newton Physics/Rigid Body/Colliders/Box")]
    [AddComponentMenu("Newton Physics/Rigid Body/Colliders/Convex Hull Collider")]

I guess I can try and se what works.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton Plugin for Unity 3D

Postby Sweenie » Thu May 12, 2016 5:34 pm

Hi.

I've been working quite alot with the plugin this week. Not the last days though, Uncharted for PS4 is released and "require" alot of my attention. :lol:

I discovered the tool CppSharp which is a Swig-like tool for wrapping c++ code to .Net. It seems to have the same limitation when it comes to C code though.

But by using some components of CppSharp I made a quick tool that generates the .cxx wrapper and the C# code. So wrapping Newton.h is completely automatic. Note that my tool doesn't wrap c++ classes into managed C# classes. It makes the c-functions in Newton.h easy to use with Pinvoke.

The joints and vehicle I wrapped manually but it's so few classes so that was done I less than an hour.

Then I applied the reference stuff we discussed and currently I can create the world, bodies, joints and vehicle in any order and destroy them in any order.

The colliders works exactly as you described.
A gameobject with a rigidbody can have 0 colliders or as many as it likes. It will also pick up colliders from the child gameobjects, unless those child gameobjects has a rigidbody.

That way I can combine colliders any way I want.

The reason I tried again with simple C functions instead of creating wrapped classes is that we have to create Managed classes in Unity anyway(Components) and these we have to create manually. So if I create the Unity component NewtonRigidBody it doesn't matter if I call Newton by using a C-function or a wrapped C++ class. The amount of work is the same.

The Unity users wouldn't notice the difference because they will only interact with the Components.

It's late here now but I will explain more tomorrow. I'm not saying this is the best way to go but for now it works very well. :)
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

PreviousNext

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 6 guests

cron