unequal universal joint - "manual" mass ratio in joints?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Thu Dec 19, 2019 10:47 am

Here is a question.
Aren't there automatic translators that can make wrappers fro c++ to Pascal?
Does swigg does that?
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Dave Gravel » Thu Dec 19, 2019 11:35 am

If I remember good the real problem is because the dCustomJoint dll exporting the class.
When you make it in pascal you need to use some special methods for make the class.
It is very long to implement and it is easy to get size problem if exemple one variable is change in the dll class.
It is hard to debug too.

You can use the exported name directly but because the dll exporting the class all exports name become with strange name id, It is hard to use and maintained.

The way how newton dll working with pointer and function exports is a lot more simple to use.
Here the easier method that I have find for use the customjoint is to make joint pointer similar to NewtonBody.
I export all function one by one without export the class. On this way I add the joint pointer in my export functions.
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: 725
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Thu Dec 19, 2019 11:49 am

I made my own pascal converter for newton header which fully automatic, i hope to release that once my work on fully automatic newton dll and .so compilation is done.

I tried to use NewtonUserJointMassScale but i could not join truck to trailer anymore - it looks like new bug and NewtonContactJointRemoveContact no longer works at all in my case (compound collision), which prevents truck and trailer from being attached together to get the trailer-truck joint created.

Edit: A long time ago, sascha williems made a translation of joint library for asphyre library, it still works in newest newton. Also, with operator overloading and a good vector/matrix library such code is easier to convert to pascal.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Dave Gravel » Thu Dec 19, 2019 2:11 pm

Here a project exemple with my method:
Sorry for the error in the name (dCuston / dCustom) I have see it only when I have upload the zip hehe...
You can just rename it with the good name.
https://www.mediafire.com/file/uexjen175qnb4h0/dCustonJointPascal.zip
I have add only the BallAndSocket joint for show you how I make it.
You surely need to update the dCustonJointPascal_Import.pas for use your matrix class and newton imports.
I don't have test the dll because I have nothing for test it and I don't use the Win32 version.
All look ok in the dll export viewer it is supposed to work.
I have build all for the 32bits version.
You have the dll project if you like to use this method it is easy to follow and change it for your need, I have make the project with visual studio 2017.
I have use the newton,dContainers,dCustomJoints dll but you can change the dll project setting for use the static lib.
Edited:
I don't have export all options from the joint at 100% but it is easy to do it if you need more.

Image

I'm happy if it can help you if it don't help it's ok, I just like to show you what I use here for the dCustomJoints.
Last edited by Dave Gravel on Thu Dec 19, 2019 3:10 pm, 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: 725
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Thu Dec 19, 2019 2:49 pm

I tried to use NewtonUserJointMassScale but i could not join truck to trailer anymore - it looks like new bug and NewtonContactJointRemoveContact no longer works at all in my case (compound collision), which prevents truck and trailer from being attached together to get the trailer-truck joint created.


I am so confuse with this, It seem each time a bug is fix tow more show up, how did this happens?
I have not touched that code in a while, how did stop working?
The joints in the demos are working and they use the same functions.
how are you making your joint?
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Thu Dec 19, 2019 3:13 pm

The user joint is a simple custom joint, nothing special about it.

The loops which check for contact and call NewtonContactJointRemoveContact, you can reproduce this by simply making a contact callback with iterator and remove all contacts and bodies will still collide. Unless there is a problem that removecontact now breaks something with iterator and should not be used at same time? Should i put contacts to remove on another list and remove them outside iterator?

Dave: thanks, i will check that but after the contact callback is fixed, this is a really big issue now for me.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby Julio Jerez » Thu Dec 19, 2019 5:42 pm

The loops which check for contact and call NewtonContactJointRemoveContact, you can reproduce this by simply making a contact callback with iterator and remove all contacts and bodies will still collide.

I am getting confused as to figure out what is going on.
can you post the code fragment where you are using NewtonContactJointRemoveContact so that
we can recreate it in the UsingNewtonMeshTool demo.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Fri Dec 20, 2019 2:08 am

I messed up something on my side optimizing my contact iterators, i forgot you need to get the next contact BEFORE you remove it, i think i even years ago put that info on the wiki.. long story short, i fixed my iterators, my contact removing logic works now, i will go and now test the joint mass function.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Fri Dec 20, 2019 3:21 am

I finally fixed my fault with contact iterator (sorry) - as a proposal.. i do recommend that NewtonContactJointRemoveContact returns NEXT contact aswell ( as if NewtonContactJointGetNextContact was called before it ), this will make contact iteration easier to use when iterator is used together with NewtonContactJointRemoveContact calls.

And to point of this thread: NewtonUserJointMassScale now works great, i've tried it with newton NewtonConstraintCreateBall joint, it works exactly as needed, now the truck can properly pull heavy
trailers!

Thank you for adding this, i can see NewtonUserJointMassScale as something that can be even used to simulate airplanes towing aerodynamic things like a second plane / glider - basically a heavy object that is aerodynamic, so it's movement should not affect the connection between bodies as much.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: unequal universal joint - "manual" mass ratio in joints?

Postby JernejL » Wed Jan 29, 2020 3:53 am

The inequal mass ratio joint can now be tested in the game :)

viewtopic.php?f=14&p=65410

There are some trailers on the map but they have to be found :)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron