Filax, new EasyTok functions for you to include!

Blitz3D Forums/Blitz3D Userlibs/Filax, new EasyTok functions for you to include!

Please add these to the next official release (I'll be posting a few...)

Function TOK_GetRBBody%(Name$)
	For G.TOK_ObjectStruct = Each TOK_ObjectStruct
		If  G\BodyType%=TOK_TypeRigidBody% And Upper$(Name$)=Upper$(G\Name$) Then
			Return G\Body%
		EndIf 
	Next

	Return False
End Function


I don't use EasyTok, never have, but..

Why does the function definition declare a floating point return value and then the return command returns an integer?

Ok ! No problem ! :)

Gabriel : The % sign return a int not a float !
if you want return a float you must do a #.

Sorry for the confusion - Gabriel was 100% correct. I amended the original post to match what he said.

Filax,

A couple more, please add these to the official lib - many thanks.

; -----------------------------------------
; Apply a velocity to a direction
; -----------------------------------------
Function TOK_ApplyVelocity(Name$,X#,Y#,Z#)
		For G.TOK_ObjectStruct = Each TOK_ObjectStruct
			If G\BodyType%=TOK_TypeRigidBody%
				If Name$="" Then 
					 TOKRB_SetVelocity G\Body,X#,Y#,Z#
				Else
					If Upper$(Name$)=Upper$(G\Name$) Then
						 TOKRB_SetVelocity G\Body,X#,Y#,Z#
					EndIf 
				EndIf 
			EndIf 
		Next
End Function

; -----------------------------------------
; Apply angular momentum to a direction
; -----------------------------------------
Function TOK_ApplyAngularMomentum(Name$,X#,Y#,Z#)
		For G.TOK_ObjectStruct = Each TOK_ObjectStruct
			If G\BodyType%=TOK_TypeRigidBody%
				If Name$="" Then 
					 TOKRB_SetAngularMomentum G\Body,X#,Y#,Z#
				Else
					If Upper$(Name$)=Upper$(G\Name$) Then
						 TOKRB_SetAngularMomentum G\Body,X#,Y#,Z#
					EndIf 
				EndIf 
			EndIf 
		Next
End Function



When is the next release planned by the way?

Euh boiled :) do you see under EasyTOK include the function :

; ----------------------------------------------------
; Get the rigidbody body from a name
; ----------------------------------------------------
Function TOK_GetRBToka(Name$)
	For G.TOK_ObjectStruct = Each TOK_ObjectStruct
		If  G\BodyType%=TOK_TypeRigidBody% And Upper$(Name$)=Upper$(G\Name$) Then
			Return G\Body
		EndIf 
	Next

	Return False
End Function


?? :) For the update do you receive my beta with ragdoll ?
but don't panic the release coming.

Hi Fliax,

no I didn't see that - will use it. Perhaps the name of the function wasn't clear enough ;-)

But I would like these included too (best check they are correct first :-) )

; -----------------------------------------
; Enable/display gravity to a Rigid Body
; -----------------------------------------
Function TOK_ApplyGravity(Name$,Gravity%)
		For G.TOK_ObjectStruct = Each TOK_ObjectStruct
			If G\BodyType%=TOK_TypeRigidBody%
				If Name$="" Then 
					TOKRB_GravityEnable G\Body, Gravity%
				Else
					If Upper$(Name$)=Upper$(G\Name$) Then
						TOKRB_GravityEnable G\Body, Gravity%
					EndIf 
				EndIf 
			EndIf 
		Next
End Function


; -----------------------------------------
; is gravity enabled for this Rigid Body?
; -----------------------------------------
Function TOK_IsGravityEnabled%(Name$)
		For G.TOK_ObjectStruct = Each TOK_ObjectStruct
			If G\BodyType%=TOK_TypeRigidBody%
				If Name$="" Then 
					Return TOKRB_IsGravityEnabled G\Body
				Else
					If Upper$(Name$)=Upper$(G\Name$) Then
						Return TOKRB_IsGravityEnabled G\Body
					EndIf 
				EndIf 
			EndIf 
		Next
End Function


Yes I did get your update. I'm not too interested in ragdoll stuff just yet. Will these 4 functions be included in the next release? Many thanks.

Just found this gravity stuff and will be VERY useful for me.

It's ok your function are included :) if you have other's
don't hesitate :)

Filax,

a couple of things, another new function ( that is very useful to me) and a small mod that is also very handy.

PLEASE include these updates!

; -----------------------------------------
; Enable/disable active to a Rigid Body
; -----------------------------------------
Function TOK_ApplyActive(Name$,Active%)
		For G.TOK_ObjectStruct = Each TOK_ObjectStruct
			If G\BodyType%=TOK_TypeRigidBody%
				If Name$="" Then 
					TOKRB_Active G\Body, Active%
				Else
					If Upper$(Name$)=Upper$(G\Name$) Then
						TOKRB_Active G\Body, Active%
					EndIf 
				EndIf 
			EndIf 
		Next
End Function


could you please modify the 2 create sphere functions to allow the number of segments to be passed in, i.e.

TOK_CreateRBSphere(Name$,Mesh%=False,Px#=0,Py#=0,Pz#=0,Pitch#=0,Yaw#=0,Roll#=0,Scale#=1,Mass#=1,Sound$="",Red=255,Green=255,Blue=255,View%=1,Life%=15, Segments%=16)


then in that function...

G\Mesh = CreateSphere(Segments)


Many thanks! This would save me having 3 different EasyTok libs!

For that matter please do the cylinder functions too. Oh and any idea when the next version is out?

No problem :) Fixed for the moment :

Version 1.4 :
-------------

New function  : TOK_ApplyVelocity(Name$,X#,Y#,Z#) (thanks Boiled Sweets)
New function  : TOK_ApplyAngularMomentum(Name$,X#,Y#,Z#) (thanks Boiled Sweets)
New function  : TOK_ApplyGravity(Name$,Gravity%) (thanks Boiled Sweets)
New function  : TOK_ApplyActive(Name$,Active%) (thanks Boiled Sweets)

New function  : TOK_IsGravityEnabled%(Name$) (thanks Boiled Sweets)

New function  : TOK_GetRBPitch#(Name$,Global_Value)
New function  : TOK_GetRBYaw#(Name$,Global_Value)
New function  : TOK_GetRBRoll#(Name$,Global_Value)

New function  : TOK_CreateBomb(Name$,Px#,Py#,Pz#,Radius#,Force#,Second,Launch_Sound$,Explode_Sound$)
New function  : TOK_DeleteBomb(Name$)
New function  : TOK_ActivateAllBomb()


For the release just let me 2 days. There is changes at my
job :/

Woah whats that bomb thing?

Surprise :)

:-) I guess that'll be the 'explode' function. I tried it but didn't work as expected. I trust you will be adding a bomb demo bb to show it in action?

No worries regards a few days for the release. I've made the changes to my EasyTok here so I'm up and running I just wanted an 'official' release for piece of mind.

A question : there seems to be a problem with entities passing through one another. I think this might be down to the fact that Blitz does do dymanic collisions very well. Try the push object 1.bb, if a cube is moving it's possible for the camera to pass straight through it. Is there a cunning way to prevent this?

No ! because you know the problem with blitz collisions and
animated/moving objects ... :( I'll release EasyTOK this
night.

Then is it possible to get round this by using a Tokamak sphere as the 'player' and Tokamak cubes?

Would that then handle the dymanic collisions?

maybe ! i have try some test to control a physic
camera (attached RB sphere to camera) and it work !

WOAH! Could you please send me the example?

Do you look the example : Beginning - Camera Move 01.bb
It's an example with camera moving with physic + collisions :)

I have EasyTok 1.1 - it does not have that example