Post by shiftygeezer on Oct 18, 2004 17:43:38 GMT
Hi,
I'm trying out the Blitz3D trial with Tokamak. If it works out I'll go with it but i need my tests working first. Thus far Tokamak looks pretty convenient and powerful but I can't get materials to do anything. I've added these code chunks to the example program from BotBuilder's tute.
The end result changes the colour of the blocks so I know their being assigned the different material Indexes, but their behaviour is identical to not using materials. The full program's here...
Am I failing to initialise some use Material flag or something?
Any help much appreciated!
Shifty Geezer
...
I'm trying out the Blitz3D trial with Tokamak. If it works out I'll go with it but i need my tests working first. Thus far Tokamak looks pretty convenient and powerful but I can't get materials to do anything. I've added these code chunks to the example program from BotBuilder's tute.
TOKSIM_SetMaterial 1,80.4,0.5 ; wood
TOKSIM_SetMaterial 2,1.0,1.0 ; rubber
TOKSIM_SetMaterial 3,0.1,0.6 ; ice
TOKGEOM_SetMaterialIndex rb(i),Rnd(1,3)
Select TOKGEOM_GetMaterialIndex(rb(i))
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
The end result changes the colour of the blocks so I know their being assigned the different material Indexes, but their behaviour is identical to not using materials. The full program's here...
Const Rigid_Bodies=100,Animated_Bodies=5,Rigid_Particles=0
TOKSIM_SetRigidBodiesCount Rigid_Bodies
TOKSIM_SetAnimatedBodiesCount Animated_Bodies
TOKSIM_SetRigidParticleCount Rigid_Particles
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount Rigid_bodies+Animated_Bodies ;Assuming each one only has one geometry. Not true with more complex rigid bodies and animated bodies.
TOKSIM_SetMaterial 1,80.4,0.5 ; wood
TOKSIM_SetMaterial 2,1.0,1.0 ; rubber
TOKSIM_SetMaterial 3,0.1,0.6 ; ice
TOKSIM_CreateSimulator(0,-10,0)
Graphics3D 800,600,0,2
Const FPS=60
Global cam = CreateCamera()
PositionEntity cam,0,10,-50
l=CreateLight()
centerpoint=CreatePivot()
ground = CreateCube()
EntityColor ground,5,5,55
ScaleEntity ground,50,5,50
PositionEntity ground,0,-5,0
abground = TOKAB_Create()
TOKAB_AddBox(abground,100.0,10.0,100.0)
TOKAB_SetPosition(abground,0.0,-5.0,0.0)
wall1 = CreateCube()
EntityColor wall1,25,25,55
ScaleEntity wall1,2,10,50
PositionEntity wall1,50,0,0
abwall1 = TOKAB_Create()
TOKAB_AddBox(abwall1,4.0,20.0,100.0)
TOKAB_SetPosition(abwall1,50.0,0,0.0)
wall2 = CreateCube()
EntityColor wall2,25,25,55
ScaleEntity wall2,2,10,50
PositionEntity wall2,-50,0,0
abwall2 = TOKAB_Create()
TOKAB_AddBox(abwall2,4.0,20.0,100.0)
TOKAB_SetPosition(abwall2,-50.0,0,0.0)
wall3 = CreateCube()
EntityColor wall3,25,25,55
ScaleEntity wall3,50,10,2
PositionEntity wall3,0,0,-50
abwall3 = TOKAB_Create()
TOKAB_AddBox(abwall3,100.0,20.0,4.0)
TOKAB_SetPosition(abwall3,0.0,0,-50.0)
wall4 = CreateCube()
EntityColor wall4,25,25,55
ScaleEntity wall4,50,10,2
PositionEntity wall4,0,0,50
abwall4 = TOKAB_Create()
TOKAB_AddBox(abwall4,100.0,20.0,4.0)
TOKAB_SetPosition(abwall4,0.0,0,50.0)
Dim obj(Rigid_Bodies)
Dim rb(Rigid_Bodies)
For i=1 To Rigid_Bodies
obj(i) = CreateCube()
ScaleEntity obj(i),1,1,1
rb(i)=TOKRB_Create()
TOKRB_AddBox rb(i),2.0,2.0,2.0
TOKRB_SetPosition rb(i),Rnd(-40,40),10,Rnd(-40,40)
TOKRB_SetLinearDamping rb(i),0.001
TOKRB_SetAngularDamping rb(i),0.02
TOKRB_SetMass rb(i),2.0
TOKRB_SetBoxInertiaTensor rb(i),4.0,2.0,2.0,2.0
TOKRB_SetVelocity rb(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
TOKRB_SetTorque rb(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
TOKGEOM_SetMaterialIndex rb(i),Rnd(1,3)
Select TOKGEOM_GetMaterialIndex(rb(i))
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
period=1000/FPS
time=MilliSecs()-period
imptime=MilliSecs()
While Not KeyHit(1)
Repeat
elapsed=MilliSecs()-time
Until elapsed
ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)
For k=1 To ticks
time=time+period
If k=ticks Then
CaptureWorld
For i=1 To Rigid_Bodies
PositionEntity obj(i),TOKRB_GetX#(rb(i)),TOKRB_GetY#(rb(i)),TOKRB_GetZ#(rb(i))
RotateEntity obj(i),TOKRB_GetPitch#(rb(i)),TOKRB_GetYaw#(rb(i)),TOKRB_GetRoll#(rb(i)),False
If KeyDown(57) Then
TOKRB_ApplyImpulse2 rb(i),Rnd(-.3,.3),Rnd(-1.5,3.0),Rnd(-.3,.3),Rnd(-.05,.05),Rnd(.05,.05),Rnd(-.05,.05)
EndIf
Next
EndIf
TOKSIM_Advance(1.5/FPS,1)
UpdateWorld
Next
camx#=Cos(rot#)*50
camz#=Sin(rot#)*50
rot#=rot#+0.05+MouseXSpeed()/5.0
If rot#>360 Then rot#=0
PositionEntity cam,camx#,40,camz#
PointEntity cam,centerpoint
RenderWorld tween
Flip False
Wend
TOKSIM_DestroySimulator()
End
TOKSIM_SetRigidBodiesCount Rigid_Bodies
TOKSIM_SetAnimatedBodiesCount Animated_Bodies
TOKSIM_SetRigidParticleCount Rigid_Particles
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount Rigid_bodies+Animated_Bodies ;Assuming each one only has one geometry. Not true with more complex rigid bodies and animated bodies.
TOKSIM_SetMaterial 1,80.4,0.5 ; wood
TOKSIM_SetMaterial 2,1.0,1.0 ; rubber
TOKSIM_SetMaterial 3,0.1,0.6 ; ice
TOKSIM_CreateSimulator(0,-10,0)
Graphics3D 800,600,0,2
Const FPS=60
Global cam = CreateCamera()
PositionEntity cam,0,10,-50
l=CreateLight()
centerpoint=CreatePivot()
ground = CreateCube()
EntityColor ground,5,5,55
ScaleEntity ground,50,5,50
PositionEntity ground,0,-5,0
abground = TOKAB_Create()
TOKAB_AddBox(abground,100.0,10.0,100.0)
TOKAB_SetPosition(abground,0.0,-5.0,0.0)
wall1 = CreateCube()
EntityColor wall1,25,25,55
ScaleEntity wall1,2,10,50
PositionEntity wall1,50,0,0
abwall1 = TOKAB_Create()
TOKAB_AddBox(abwall1,4.0,20.0,100.0)
TOKAB_SetPosition(abwall1,50.0,0,0.0)
wall2 = CreateCube()
EntityColor wall2,25,25,55
ScaleEntity wall2,2,10,50
PositionEntity wall2,-50,0,0
abwall2 = TOKAB_Create()
TOKAB_AddBox(abwall2,4.0,20.0,100.0)
TOKAB_SetPosition(abwall2,-50.0,0,0.0)
wall3 = CreateCube()
EntityColor wall3,25,25,55
ScaleEntity wall3,50,10,2
PositionEntity wall3,0,0,-50
abwall3 = TOKAB_Create()
TOKAB_AddBox(abwall3,100.0,20.0,4.0)
TOKAB_SetPosition(abwall3,0.0,0,-50.0)
wall4 = CreateCube()
EntityColor wall4,25,25,55
ScaleEntity wall4,50,10,2
PositionEntity wall4,0,0,50
abwall4 = TOKAB_Create()
TOKAB_AddBox(abwall4,100.0,20.0,4.0)
TOKAB_SetPosition(abwall4,0.0,0,50.0)
Dim obj(Rigid_Bodies)
Dim rb(Rigid_Bodies)
For i=1 To Rigid_Bodies
obj(i) = CreateCube()
ScaleEntity obj(i),1,1,1
rb(i)=TOKRB_Create()
TOKRB_AddBox rb(i),2.0,2.0,2.0
TOKRB_SetPosition rb(i),Rnd(-40,40),10,Rnd(-40,40)
TOKRB_SetLinearDamping rb(i),0.001
TOKRB_SetAngularDamping rb(i),0.02
TOKRB_SetMass rb(i),2.0
TOKRB_SetBoxInertiaTensor rb(i),4.0,2.0,2.0,2.0
TOKRB_SetVelocity rb(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
TOKRB_SetTorque rb(i),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)
TOKGEOM_SetMaterialIndex rb(i),Rnd(1,3)
Select TOKGEOM_GetMaterialIndex(rb(i))
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
period=1000/FPS
time=MilliSecs()-period
imptime=MilliSecs()
While Not KeyHit(1)
Repeat
elapsed=MilliSecs()-time
Until elapsed
ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)
For k=1 To ticks
time=time+period
If k=ticks Then
CaptureWorld
For i=1 To Rigid_Bodies
PositionEntity obj(i),TOKRB_GetX#(rb(i)),TOKRB_GetY#(rb(i)),TOKRB_GetZ#(rb(i))
RotateEntity obj(i),TOKRB_GetPitch#(rb(i)),TOKRB_GetYaw#(rb(i)),TOKRB_GetRoll#(rb(i)),False
If KeyDown(57) Then
TOKRB_ApplyImpulse2 rb(i),Rnd(-.3,.3),Rnd(-1.5,3.0),Rnd(-.3,.3),Rnd(-.05,.05),Rnd(.05,.05),Rnd(-.05,.05)
EndIf
Next
EndIf
TOKSIM_Advance(1.5/FPS,1)
UpdateWorld
Next
camx#=Cos(rot#)*50
camz#=Sin(rot#)*50
rot#=rot#+0.05+MouseXSpeed()/5.0
If rot#>360 Then rot#=0
PositionEntity cam,camx#,40,camz#
PointEntity cam,centerpoint
RenderWorld tween
Flip False
Wend
TOKSIM_DestroySimulator()
End
Am I failing to initialise some use Material flag or something?
Any help much appreciated!
Shifty Geezer
...