TOKSIM_SetMaterial(Index%,Friction#,Restitution#)
Parameters:
Index% = The material's index
Friction# = The friction coefficient of the material. From 0-1.
Restitution# = The restitution coefficient of the material. The greater this number is, the more an the thing bounces. From 0-1.
Return value:
None
Description:
Sets the parameters for a material. Materials can be used for different things including triangles, rigid bodies, and animated bodies. (and once supported, particles)
Some code taken from the Toka_Materials demo that came with v4
TOKSIM_SetMaterial 1,80.4,0.5 ; Wood(Brown)
TOKSIM_SetMaterial 2,1.0,.9 ; Rubber(Orange)
TOKSIM_SetMaterial 3,0.1,0.6 ; Ice(BrightBlue)
Dim obj(RBODIES)
Dim rb(RBODIES)
SeedRnd Millisecs()
For i=1 To RBODIES
; change the line below to 1,3 to include "cylinders".
; I render them as cylinders but the rigidbody is really a capsule, so
; the bodies will behave like capsules and not like cylinders.
nr=Rnd(1,3)
x#=Rnd(-100,100)
If nr=1 Then
  obj(i) = CreateCube()
  rb(i) = TOKRB_Create()
  geom = TOKRB_AddBox(rb(i),2.0,2.0,2.0)
  TOKGEOM_SetMaterialIndex geom,Rnd(1,3)
  TOKRB_SetPosition rb(i),x#,35+i*0.2,50+z#
  TOKRB_SetLinearDamping rb(i),0.001
  TOKRB_SetAngularDamping rb(i),0.002
  TOKRB_SetMass rb(i),2.0
  TOKRB_SetBoxInertiaTensor rb(i),2.0,2.0,2.0,2.0
ElseIf nr=2
  obj(i) = CreateSphere()
  rb(i) = TOKRB_Create()
  geom = TOKRB_AddSphere(rb(i),2)
  TOKGEOM_SetMaterialIndex geom,Rnd(1,3)
  TOKRB_SetPosition rb(i),x#,35+i*0.2,50+z#
  TOKRB_SetLinearDamping rb(i),0.001
  TOKRB_SetAngularDamping rb(i),0.002
  TOKRB_SetMass rb(i),1.5
  TOKRB_SetSphereInertiaTensor rb(i),2,1.5
ElseIf nr=3
  obj(i) = CreateCylinder()
  rb(i) = TOKRB_Create()
  geom = TOKRB_AddCylinder(rb(i),2.0,1.0)
  TOKGEOM_SetMaterialIndex geom,Rnd(1,3)
  TOKRB_SetPosition(rb(i),x#,35+i*0.2,50+z#)
  TOKRB_SetLinearDamping rb(i),0.001
  TOKRB_SetAngularDamping rb(i),0.002
  TOKRB_SetMass rb(i),2.0
  TOKRB_SetCylinderInertiaTensor rb(i),2.0,1.0,2.0
EndIf
Select TOKGEOM_GetMaterialIndex(geom)
Case 1 ;Wood(Brown)
  EntityColor obj(i),177,118,25
Case 2 ;Rubber(Orange)
  EntityColor obj(i),219,79,10
Case 3 ;Ice(BrightBlue)
  EntityColor obj(i),144,207,228
End Select
Next



Documentation generated by Cod2Doc on 20 Jun 2004.