Rigid Kebab! (the only way to describe it)

Blitz3D Forums/Blitz3D Programming/Rigid Kebab! (the only way to describe it)

aCiD2(Posted 2004) [#1]
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

TOKSIM_CreateSimulator 0, -10, 0

Global cube1 = CreateCube()
Global cube2 = CreateCube()

Global rbCube1 = TOKRB_Create()
	TOKRB_AddBox(rbCube1, 2, 2, 2)
	TOKRB_SetPosition rbCube1, 3, 0, 0
	
Global abCube = TOKAB_Create()
	TOKAB_AddBox(abCube, 2, 2, 2)
	TOKAB_SetPosition abCube, 3, -4, 0

Global rbCube2 = TOKRB_Create()
	TOKRB_AddBox(rbCube2, 2, 2, 2)
	TOKRB_SetPosition rbCube2, -3, 0, 0
	
Global rbJoiner = TOKRB_Create()
	TOKRB_AddCylinder rbJoiner, 1, 6
	
Global jCube1 = TOKJOINT_Create(2, rbCube1, rbJoiner)
	TOKJOINT_SetPositionAndRotationWorld jCube1, 2, 0, 0, 0, 0, 0
	TOKJOINT_SetType jCube1, 2
	TOKJOINT_SetUpperLimit jCube1, 0
	TOKJOINT_SetLowerLimit jCube1, 0
	TOKJOINT_Enable jCube1, True
	
Global jCube2 = TOKJOINT_Create(2, rbCube2, rbJoiner)
	TOKJOINT_SetPositionAndRotationWorld jCube2, -2, 0, 0, 0, 0, 0
	TOKJOINT_SetType jCube2, 2
	TOKJOINT_SetUpperLimit jCube2, 0
	TOKJOINT_SetLowerLimit jCube2, 0
	TOKJOINT_Enable jCube2, True
	
Global abFloor = TOKAB_Create()
	TOKAB_AddBox abFloor, 50, 1, 50
	TOKAB_SetPosition abFloor, 0, -5, 0
	
Global cam = CreateCamera()
	MoveEntity cam, 0, 0, -10
	
While Not KeyHit(1)

	Cls
	
	TOKSIM_Advance .01, 2
	
	Position(cube1, rbcube1)
	position(cube2, rbcube2)
	
	RenderWorld
	
	Flip
	
Wend

Function Position(ent, rb)
	PositionEntity ent, TOKRB_GetX(rb), TOKRB_GetY(rb), TOKRB_GetZ(rb)
	RotateEntity ent, TOKRB_GetPitch(rb), TOKRB_GetYaw(rb), TOKRB_GetRoll(rb)
End Function


Im trying to make it like there is a pole holding two rigid bodies together, so that they are completely locked together. That code above is what i thought does it.. but i cnat get it to work :\


Rob(Posted 2004) [#2]
;make 2 rigid bodies called rb_A and rb_B then...

joint=TOKJOINT_Create(2,rb_A,rb_B)
TOKJOINT_SetType joint,3

That will glue two rb's together.


aCiD2(Posted 2004) [#3]
I need them to always stay a fixed distance apart


Rob(Posted 2004) [#4]
They do. You must be doing something wild and zany.


aCiD2(Posted 2004) [#5]
hmmmm...think i am :)
any chance of a demo bit of code?


Bot Builder(Posted 2004) [#6]
So, all you want to do is have the boxes be as if they were the same rigid body? Just do this:
Global rbCube = TOKRB_Create()
TOKGEOM_SetPositionAndRotation TOKRB_AddBox(rbCube, 2, 2, 2),0,-3,0,0,0,0
TOKGEOM_SetPositionAndRotation TOKRB_AddBox(rbCube, 2, 2, 2),0,3,0,0,0,0



aCiD2(Posted 2004) [#7]
No can't do that bot. This is for a cloth engine, so I therefore need to get the positions of a rigid body (one on each verex). This post should clear up some issues:
http://www.blitzbasic.com/Community/posts.php?topic=33962