Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Make a 'string' using hinge joint? Is it possible?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Feb 2016 13:46 Edited at: 11th Feb 2016 13:50
Hello everybody.

I tried to make a 'string' which is supposed to be composed of multiple cubes connected together by hinge joints.
The string segments is supposed to be held together by the hinge joints, and supposed to sway around using physic.
I don't know if this is possible or not.

Now correct me if I'm wrong , because I'm not really sure if I'm on the right track.

So I make a character object that we can control. I make it as a controller
Then I made another box that is supposed to be the first segment of the string, connected by a hinge joint. I'ts supposed to be connected to the character object/controller.

Now if I move the controller/character object, the first segment is supposed to sway, right? Like a hinge?

But nothing happened. It's almost as if the joint never existed.

I made the controller using this:
//Make player object
playerObj = 1
CreateObjectBox(playerObj, 5, 5, 5)
SetObjectImage(playerObj,10,0)
characterOffsetVec = CreateVector3( 0.0, 0, 0.0 )
objectOrientationVec = CreateVector3( 0.0, 0.0, 0 )
Create3DPhysicsCharacterController( playerObj, 1, characterOffsetVec , objectOrientationVec, 0.5 )
DeleteVector3( characterOffsetVec )
DeleteVector3( objectOrientationVec )
Set3DPhysicsCharacterControllerJumpSpeed( playerObj, 3 )
Set3DPhysicsCharacterControllerFallSpeed( playerObj, 1 )
Set3DPhysicsCharacterControllerGravity( playerObj, 5 )

I made the first segment with this:
hairObj = 2
CreateObjectBox(hairObj, 5, 10, 5)
Create3DPhysicsDynamicBody( hairObj )
positionVec3 = CreateVector3( 0.0, 0, 0.0 )
rotationVec3 = CreateVector3( 1, 1, 1 )
Create3DPhysicsHingeJoint( playerObj, hairObj, positionVec3, rotationVec3, 0 )
DeleteVector3(positionVec3)
DeleteVector3(rotationVec3)

The other rigid bodies physic is working fine, so maybe it's the way the hinge joint is set up.

I'm not sure how can I do this correctly. Any help is appreciated
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Feb 2016 14:19
I managed to get a string working with the ConeTwist joint. I made an object and enabled physics, then attached objects in a chain, each time attaching to the previous object. I can then move the first object and affect the string, swaying about with full collision. It's possible to set the cone joint limits, so setting them to say, 45 degrees means the string won't bundle up so easily.

Seems to work pretty well, I can post some code later if you like.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Feb 2016 14:33
Thanks a lot. Example codes always helps.

Just in case, do anybody have any idea on how to make clothe physics too?
I used to make it in DBPro by modifying vertex data in a plane object, and apply shear and tension and all that.
Any good way to utilize AppGameKit physic for creating clothes?
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 11th Feb 2016 21:09
It is not possible to attach a joint to a character controller. You can only join rigid bodies with a joint.
A character controller is not a rigid body, it is a special physics object represented by a capsule shape.
The current AppGameKit implementation of the Bullet Physics library does not have cloth physics.
Maybe they can add cloth and softbody it in the future.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Feb 2016 22:28
Here's a small example with the cone twist joints - arrow keys to move, left mouse to raise...

hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 06:58
Thanks, that string works flawlessly.

Actually, the initial idea of making strings, is that so I can make 'hairs' for my character, that we can control.
I would put the whole lot of that strings on its head, thus we'll get hair physic.

I managed to anchor the 'hair' to a physic kinematic body, which can be repositioned freely on the character head using SetObjectPosition()
Now we just need to make 100 more hair strands and it should be a head full of hairs

Any method to make the 'string' less springy?
I tried to change the restitution and mass of the string segment, but it seems like nothing changed
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Feb 2016 07:33
Maybe reducing the angle range on the cone joints would help - but I'm not sure, it can be tricky to get physics to behave huh!

If I figure anything out I'll let you know.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Feb 2016 08:04
I'm not sure SetObjectPosition() will work. You'll probably need to use a physics command to move the object.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 08:06
Lol I'm so dumb. Increasing the gravity reduces the wild swaying significantly.
And reducing angle range, and disabling twist range, it should more closely resembling elasticity of a real hair

Sorry for asking lots of question. Since real life work resumes, I barely had time to code, so I had to resort to other people for quick solution, instead of figuring things out by myself, like before., which takes time
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 08:08
SetObjectPosition() works on kinematic physic body.
But not on dynamic rigid body.

The 'string' anchors nicely to kinematic bodies, even when we move the kinematic body around using SetObjectPosition()
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 08:44 Edited at: 12th Feb 2016 08:50
Here's the project folder. I anchored the hair to a kinematic body

That kinematic body was positioned above a character controller using SetObjectPosition().

Use mouse to rotate camera, 'w' button to move forward, space to jump

Attachments

Login to view attachments
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 6th May 2016 18:18 Edited at: 6th May 2016 18:19
I am trying to do something like this in 2D . I think i've tried all the joints, but none of them actually *join* the sprites together, and so there is no interaction.

do any sprite joints actually make other sprites move?

Or is there some global 2D physics command I need to call at the beginning.

Or am I doing something else wrong?



In this example, sprite #1 is the "player sprite", and all the other ones are supposed to be connected in a chain.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th May 2016 19:27
I would offset the string sprite, so it's rotation point is one end of the string, then check the sprite location for other string sprites and create a join there. I have got it working like that, it's actually quite neat, as it creates joints based on the collision results, so stacking string sprites together makes a connected string. I do position the string sprites where they need to be though, maybe that's what's going wrong - they're all in the same place in your code... put them in a line and offset the sprites before creating the joints.
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 7th May 2016 05:21
"they're all in the same place in your code"
- that's basically how the program is showing them,
but i don't understand.
y=y-48
each loop
should make them higher up, right? like in a string.

(my "sprite()" funciton is ID,image,x,y,depth)

...i'm probably just too tired...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th May 2016 07:43
Quote: "y=y-48
each loop
should make them higher up, right? like in a string."


You have a function called sprite() which is not illustrated in the code snippet. Van B probably missed that you are positioning the sprite in that function.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-09-29 13:36:25
Your offset time is: 2024-09-29 13:36:25