Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by AntonSynytsia » Wed Jun 04, 2014 8:17 pm
Can anyone give me a good reference to a custom spring joint?
Edit: Sorry, should've posted this in General Discussion
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
by DashW » Fri Sep 19, 2014 12:54 pm
I would appreciate this myself. Clearly it can be done, since it's been implemented in this sandbox application (written in Delphi?! ten years ago?!), but of course it doesn't come with any source code.
http://www.saschawillems.de/?page_id=80For the moment, I'm going to try implementing the mouse-pick functionality from Newton's sandbox as a custom joint. I'll let you know how it goes.
-
DashW
-
- Posts: 5
- Joined: Sun Aug 03, 2014 4:45 am
by arkeon » Fri Sep 19, 2014 6:48 pm
Hi,
to make a spring joint, use a customSlider joint and add this code in the submitConstraint callback
Sure you you have to define m_useSpring, m_springStrength and m_springDamping in your joint class.
- Code: Select all
if (m_useSpring)
{
NewtonUserJointSetRowStiffness(joint, 0.8f);
NewtonUserJointSetRowSpringDamperAcceleration(joint, m_springStrength, m_springDamping);
};
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by AntonSynytsia » Sat Sep 20, 2014 4:49 am
Thanks arkeon, I will implement this piece of code.
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
by AntonSynytsia » Sat Sep 20, 2014 5:05 am
@DashW Thanks for informing me with the sandbox. Played it, looks fun! Quite similar to SketchyPhysics (if you know what I'm talking about).
Speaking of the pick and drag tool, Newton Demos 3.13 uses force and torque technique, rather than the custom joint like in Newton2. I don't know which one would be a better solution though, a constraint or a force and toque technique.
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
by manny » Sat Sep 20, 2014 6:09 am
You can also use:
- Code: Select all
NewtonCalculateSpringDamperAcceleration
and apply the force manually.
-
manny
- Site Admin
-
- Posts: 131
- Joined: Tue Feb 11, 2014 6:49 pm
by Julio Jerez » Sat Sep 20, 2014 6:33 am
using the force is simpler, but gives you less control.
I would go for the force method. BTW I made some changes to how the force is calculated,
before the force was calculated in the demo, now the relevant part of the code is a function in the PhysicUtil.cpp file.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by AntonSynytsia » Sat Sep 20, 2014 12:39 pm
Thank you, Juleo.
I will implement it in my wrapper.
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
by manny » Sun Sep 21, 2014 5:55 am
sovled+locked.
-
manny
- Site Admin
-
- Posts: 131
- Joined: Tue Feb 11, 2014 6:49 pm
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 5 guests