Jump to content

[solved] Joints not working.


AnniXa
 Share

Recommended Posts

Hello, i just try to make some bodys with joints together, so i was very lucky to found this example:

 

http://www.leadwerks.com/wiki/index.php?title=CreateJointBall

 

but for any reason even the sample wont work: the cubes are all falling down B)

 

Maybe this is out of date?

 

What do i need to do, for joining the balls together like a chain in the screenshot?

Whuts wroong?

Link to comment
Share on other sites

I used LEBuilder to make the CodeBlocks example for Rotating Cube, and replaced the code by pasting the BallJoint example there, and it worked.

I didn't try the BlitzMax example, because I don't use BlitzMax anymore. But maybe the LEBuilder BlitzMax cube example will work too.

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

ty, that was worth a try B)

 

i did the same, used the sample with the rotating cube, and just pasted the code from the bmx joint sample in.

 

thats what i get:

 

8954293joints.JPG

 

LW and stuff seems to work fine, also the physics stuff, the cubes falling down, but they are not chained together with joints, like they should, they just fall down, instead of hanging on the "crane" thingie.

Whuts wroong?

Link to comment
Share on other sites

I tried the BlitzMax example too, and it works fine also.

I had to fix these lines though, because someone who made the example made it only for vsync hardcoded PCs, and mine is vsync free (like most hardcore gamer's PCs are), so this vsync free code works on all PCs:

If KeyHit(KEY_SPACE)
AddBodyForce(cubePhy[Rand(9)],Vec3(10000,0,10000),0)' apply force
End If

UpdateAppTime() 
UpdateWorld(AppSpeed())

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

I just tried this, and the ball joints are holding the chain together:

SuperStrict
Framework leadwerks.ENGINE 
Graphics 640,480 

RegisterAbstractPath "C:\Leadwerks Engine SDK"


RegisterAbstractPath AppDir 
If Not CreateWorld() RuntimeError "Failed to create world." 
Local camera:TCamera=CreateCamera() 


Local buffer0:tbuffer=CreateBuffer(640,480,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL)

MoveEntity    Camera, Vec3(0,40,-30) 
RotateEntity  Camera, Vec3(45,0,0),0 

SetShadowQuality(1)

Local light:tlight=CreateDirectionalLight()' Create light
MoveEntity (Light, Vec3(0,10,0) )
RotateEntity (Light, Vec3(45,45,0) ,0)
EntityColor(Light, Vec4(1))
AmbientLight (Vec3(.2,.2,.3))

Local ground:tentity= CreateCube()' Ground
Local groundphy:tbody = CreateBodyBox(100,100,100)
EntityParent (ground,groundphy)
ScaleEntity(ground,Vec3(100,100,100))
MoveEntity (groundphy, Vec3(0,-50,0))
SetBodyMass(groundphy, 0);
EntityType (groundphy, 1, 1);

Local crane:TEntity= CreateCube()
Local cranephy:tbody = CreateBodyBox(100,2,2)

EntityParent (crane,cranephy,0)
ScaleEntity(crane,Vec3(100,2,2))
MoveEntity (cranephy, Vec3(0,30,0))
SetBodyMass(cranephy, 0)
EntityType (cranephy, 1, 1)

Local cubePhy:tbody[10]
Local cube:tentity
Local joint:tjoint

For Local i:Int=1 To 10

cube= CreateCube()'boxes

cubePhy[i-1]= CreateBodyBox(1,1,1)

EntityParent (cube,cubePhy[i-1],1)
ScaleEntity(cube,Vec3(2,2,2))
SweptCollision (cubePhy[i-1], 1)
MoveEntity (cubePhy[i-1], Vec3(0,i*2-1+10,0))
SetBodyMass(cubePhy[i-1], 1)
EntityType (cubePhy[i-1], 1,0)

If i=10 
Joint:tjoint = CreateJointBall( cranephy,cubePhy[i-1], Vec3(0,29,0))
End If

If i>1 
Joint:tjoint = CreateJointBall( cubePhy[i-1],cubePhy[i-2], Vec3(0,i*2-2+10,0))
End If

Next

Collisions(1,1,1)' Important! Enable collision between bodys of Type 1


While Not KeyHit(KEY_ESCAPE)

If KeyHit(KEY_SPACE)
AddBodyForce(cubePhy[Rand(9)],Vec3(10000,0,10000),0)' apply force
End If


UpdateWorld(1)
SetBuffer(Buffer0)
RenderWorld()
SetBuffer(BackBuffer())
RenderLights(Buffer0)

DrawText ("Press SPACE to apply force to one of the boxes!",0,0)

Flip 1
Wend

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

Yeah, but if you delete JointLibrary.dll then the joints don't hold together, and there is no error message either of a missing dll.

But this is kinda not really a bug, since it's obviously designed so that if JointLibrary.dll was not found, then joints just don't work.

It might be useful sometimes that way, instead of simply crashing the app.

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

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...