Jump to content

Fixed joint how to ?


Wchris
 Share

Recommended Posts

Hello,

 

I need a fixed joint. I have used ball joints before and it worked well so i thought fixed joints would be easyer ... but i ran into a problem i do not understand.

 

Here's the problem. i have 2 models. One big and one small. (the body of my "lander" and a "booster")

 

the lander body is at position -4,110,-253

the booster is at position -5.5,110,-253

the joint is setup like this Fjoint := LECreateJointFixed(Fparent.Entity, Fchild.Entity, Vec3( -5.5,110,-253));

 

if i set the models mass to 0 i get

post-44-0-34448600-1320263453_thumb.jpg

 

and if i set the models mass to 1

post-44-0-37767300-1320263464_thumb.jpg

 

why is the small model inside the big one ? I expected it to be fixed on main body side like when mass=0 ?

 

i really don't understand what's wrong. if someone has an idea I'm all ears. Many thanks

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

Joints positions are always relative to the position 0,0,0. This means you need to make the joint when your bodies are at position 0,0,0, or manually add the offset to the joint if they are somewhere else.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Joints positions are always relative to the position 0,0,0. This means you need to make the joint when your bodies are at position 0,0,0, or manually add the offset to the joint if they are somewhere else.

Tryed to follow your advice, but no luck so far i still get the same result.

Hopefully a good night of sleep will help :D

Thank you

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

I can't tell what is going on from your images, but the position of a fixed joint doesn't matter much, since there is no axis of rotation. I suppose it would probably be more stable when the joint is near either body, and not 10000 units away, but that's the only difference I can think of.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

seems to work fine for me in this little example:

require("scripts/constants/engine_const")
RegisterAbstractPath("")        
Graphics(800,600)        

fw=CreateFramework()        
fw.main.camera:SetPosition(Vec3(-2,5,-2))

light = CreateDirectionalLight()
light:SetRotation(Vec3(45,45,0))

function Reset()
if landerphy~=nil then
	landerphy:Free()
	boosterphy:Free()
end
landerphy = CreateBodyBox(.5,.5,.5)
landerphy:SetPosition(Vec3(0,3,0))
lander = CreateCube(landerphy)
lander:SetScale(Vec3(.5,.5,.5))
lander:SetColor(Vec4(.2,0,1,1))

boosterphy = CreateBodyCylinder(.1,1)
boosterphy:SetPosition(Vec3(-.3,3,0))
booster = CreateCylinder(16,1,boosterphy)
booster:SetScale(Vec3(.1,1,.1))
booster:SetColor(Vec4(1,0,.2,1))

joint = CreateJointFixed(landerphy,boosterphy,Vec3(0,3,0))
end

function AddMass()
landerphy:SetCollisionType(1)
boosterphy:SetCollisionType(1)
landerphy:SetMass(1)
boosterphy:SetMass(1)
end

Reset()

groundphy = CreateBodyBox(20,1,20)
ground=CreateCube(groundphy)
ground:SetScale(Vec3(20,1,20))
groundphy:SetPosition(Vec3(0,-2,0))
groundphy:SetCollisionType(2)
ground:SetColor(Vec4(1,.7,0,1))

fw.main.camera:Point(landerphy,3,1)
HideMouse()
while KeyHit(KEY_ESCAPE)==0 do   
if KeyHit(KEY_SPACE)==1 then Reset() end
if MouseHit(1)==1 then AddMass() end

fw:Update()
fw:Render()

SetBlend(1)
DrawText("Press SPACE to reset scene", 0, 20)
DrawText("Left-click to add mass", 0, 40)
SetBlend(0)
collectgarbage(collect)
Flip(1)
end
ShowMouse()

 

just thinking out loud here, but couldn't you get the same effect if you just parent the booster to the lander in your example instead of using a fixed joint? Or is there a particular reason behind needing a joint?

 

Edit-- forgot the require at the top when i copied over...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I can't tell what is going on from your images, but the position of a fixed joint doesn't matter much, since there is no axis of rotation. I suppose it would probably be more stable when the joint is near either body, and not 10000 units away, but that's the only difference I can think of.

I know images are not enought, i'll try mack's sample and investigate further. Thanks for providing your opinion Josh.

 

 

seems to work fine for me in this little example:

just thinking out loud here, but couldn't you get the same effect if you just parent the booster to the lander in your example instead of using a fixed joint? Or is there a particular reason behind needing a joint?

 

I'll try your sample with my models this evening and report here. Thank you for your help.

There are no examples in the wiki yet and it's good to have a working reference.

 

at first glance, joint were just the most evident way of doing it. Normaly they are not just a link between 2 objects ... they should also control how the energy and forces are dispatched between the linked bodies. when the booster bumps into something a part of the forces is automaticaly dispatched to the lander hull. Parenting cannot do that i think. But if i cannot bring it to work i'll search for a workaround. I was just surprised by my result.

 

again many thanks for the working sample. maybe it should be added to the wiki with metatron's above answser and the two good answers i've found here previously http://www.leadwerks.com/werkspace/topic/3837-joint-creation/page__p__34303__hl__joint__fromsearch__1#entry34303

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

Joints positions are always relative to the position 0,0,0. This means you need to make the joint when your bodies are at position 0,0,0, or manually add the offset to the joint if they are somewhere else.

Metatron hint was actually the answer.

I tryed Mack's sample yesterday and found out that i had to use positionentity( , ,1) with my bodies to use global space.

 

positionentity defaults to ( , ,0) which is not global space, whereas joints position defaults to global space. I found this very confusing :huh:

 

non experienced users will go directly in the wall with such antagonist default settings. but it's too late to change ... because if you change a default setting every program using it will behave eratically.

 

Therefore Metatron's answer should be added to the joints wiki too.

 

Cheers

thank you all

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

if an entity has no parent, then local = global... fyi...

Yes I know. That's why i could not understand why I have to specify the global space with ,1 while you in your sample have no problems with default values.

 

But i was tired and happy i found a way to make it work, so I did not mention this strange fact .. because I needed to investigate a bit more.

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...