Cartography Shop Collisions

Blitz3D Forums/Blitz3D Programming/Cartography Shop Collisions

TAGGART UK(Posted 2003) [#1]
Hi

Just wondering if anybody has any code for collision???


Graphics3D 640,480,16,1

SetBuffer BackBuffer()
AmbientLight 255,255,255


Player=CreateCamera(player)
CameraClsColor Player,225,225,225
PositionEntity Player,-15.0,12.0,-16




Level1=LoadAnimMesh("Map/level1.b3d")
ScaleEntity level1,.1,.1,.1
PositionEntity level1,0,0,0





While Not KeyHit(1)
If KeyHit (17) Then
WireMode = Not WireMode
WireFrame WireMode
End If


If KeyDown(200) Then

MoveEntity Player,0.0,0.0,0.5 ;move forward

EndIf

If KeyDown(208) Then

MoveEntity Player,0.0,0.0,-0.5 ;move backward

EndIf


If KeyDown(203) Then

TurnEntity Player,0.0,2.0,0.0
;move left

EndIf


If KeyDown(205) Then

TurnEntity Player,0.0,-2.0,0.0 ;move right

EndIf



If KeyDown(201) Then

MoveEntity Player,0.0,0.1,0.0 ;up

EndIf

If KeyDown(209) Then

MoveEntity Player,0.0,-0.1,-0.0 ;down

EndIf




UpdateWorld
RenderWorld



; FPS *********************************************************************************************
frames=frames+1
If MilliSecs()-render_time=>1000 Then fps=frames : frames=0 : render_time=MilliSecs()
Text 10,700,"FPS "+fps


Text 100,700,"Surfaces:"+CountSurfaces(level1)
For i=1 To CountSurfaces(level1)
Text 200,i*760,"Triangles in Surface "+i+":"+CountTriangles(GetSurface(level1,i))
Next


Flip
Wend

End


jfk EO-11110(Posted 2003) [#2]
I think you can use a standard collision. Use Sphere-to-Polygon Collison checks for Player-to-level Situations.
Something like:
t_player=1
t_level=2
entitytype level1,t_level
entitytype player,t_player
entityradius player,1.5,.75

collisions t_player,t_level,2,2 ; define Collisions checks

;main game loop:----------------------------
while whatever
;... keys aso.

translateentity player,0,-.01,0 ; simplified Gravity
uptateworld()
renderworld()
flip
wend



jfk EO-11110(Posted 2003) [#3]
oops - sorry, there was a little bug (confused type of level and player), now it should be correct.


TAGGART UK(Posted 2003) [#4]
Still no collisions?????



Graphics3D 640,480,16,1

SetBuffer BackBuffer()
AmbientLight 255,255,255


player=CreateCamera()
CameraClsColor player,225,225,225
PositionEntity player,-15.0,12.0,-16


Level1=LoadAnimMesh("Map/level1.b3d")
ScaleEntity level1,.1,.1,.1
PositionEntity level1,0,0,0


t_player=1
t_level=2
EntityType level1,t_level
EntityType player,t_player
EntityRadius player,1.5,.75

Collisions t_player,t_level,2,2 ; define Collisions checks



While Not KeyHit(1)
If KeyHit (17) Then
WireMode = Not WireMode
WireFrame WireMode
End If



TranslateEntity player,0,-.01,0 ; simplified Gravity



If KeyDown(200) Then

MoveEntity Player,0.0,0.0,0.5 ;move forward

EndIf

If KeyDown(208) Then

MoveEntity Player,0.0,0.0,-0.5 ;move backward

EndIf


If KeyDown(203) Then

TurnEntity Player,0.0,2.0,0.0
;move left

EndIf


If KeyDown(205) Then

TurnEntity Player,0.0,-2.0,0.0 ;move right

EndIf



If KeyDown(201) Then

MoveEntity Player,0.0,0.1,0.0 ;up

EndIf

If KeyDown(209) Then

MoveEntity Player,0.0,-0.1,-0.0 ;down

EndIf




UpdateWorld
RenderWorld



; FPS *********************************************************************************************
frames=frames+1
If MilliSecs()-render_time=>1000 Then fps=frames : frames=0 : render_time=MilliSecs()
Text 10,700,"FPS "+fps


Text 100,700,"Surfaces:"+CountSurfaces(level1)
For i=1 To CountSurfaces(level1)
Text 200,i*760,"Triangles in Surface "+i+":"+CountTriangles(GetSurface(level1,i))
Next


Flip
Wend

End


jfk EO-11110(Posted 2003) [#5]
Is the level animated? If not so then use LoadMesh() instead of LoadAnimMesh(). An other reason why it dind't work could be the initial position of the player - if it's below or byside the level from beginning on. Try this:

player=CreateCamera()
CameraClsColor player,225,225,225
PositionEntity player,-15.0,15.0,-16 ; maybe use 0,15,0 ?


Level1=LoadMesh("Map/level1.b3d")
ScaleEntity level1,.1,.1,.1
;or maybe better use: ScaleMesh level1,.1,.1,.1
PositionEntity level1,0,0,0


Warren(Posted 2003) [#6]
xbox

Dude, put some effort in. Read up on the collision functions. Tell us what you've tried, tell us what the results were, give us information ... don't just keep spamming code and crying for people to fix it for you.


jfk EO-11110(Posted 2003) [#7]
cmon - I was surprised the code he posted didn't work.


TAGGART UK(Posted 2003) [#8]
Epic boy i have read the book
thats why i asked for help because it would not work???


jfk
Thanks For Helping Me.
You were correct about the LoadAnimMesh()
Changed to LoadMesh() Works Great

Many Thanks