BSP und Boden-Kollision

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

 

KarlosKojote

Betreff: BSP und Boden-Kollision

BeitragMi, Mai 05, 2004 18:31
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi !
Ich hab mir nun aus ein paar Beispielen ein kleines Script geschrieben, mit welchem ich mich durch einen BSP Level bewegen kann, welches wie folgt aussieht:

Code: [AUSKLAPPEN]

Graphics3D 800,600,32,1

Const TYPE_LEVEL=10,TYPE_CAMERA=1

Collisions TYPE_CAMERA,TYPE_LEVEL,2,2
level=LoadBSP( "tutor2.bsp",0.2)
ScaleEntity level,.1,.1,.1
EntityType level,TYPE_LEVEL

Global cam

cam=CreateCamera()
PositionEntity cam,5,5,10
EntityType cam,TYPE_CAMERA
CameraRange cam,.1,1000

bsp_amb=100
BSPAmbientLight level,bsp_amb,bsp_amb,bsp_amb
BSPLighting level, True

While Not KeyHit(1)
   ms=MilliSecs()
   mxs#=-MouseXSpeed()
   mys#=MouseYSpeed()

   If ms-fpsms>499 Then
      fpsms=ms
      fps=fpsf*10
      fpsf=0
      fpsfak#=50.0/Float(fps)
      If fpsfak#>10.0 Then fpsfak#=10.0
   EndIf


   If KeyDown(74)
      If bsp_amb>0
         bsp_amb=bsp_amb-3
         BSPAmbientLight level,bsp_amb,bsp_amb,bsp_amb
      EndIf
   Else If KeyDown(78)
      If bsp_amb<253
         bsp_amb=bsp_amb+3
         BSPAmbientLight level,bsp_amb,bsp_amb,bsp_amb
      EndIf
   EndIf
   
   If KeyDown(31) Then MoveEntity cam,0,0,-1.0*fpsfak#
   If KeyDown(17) Then MoveEntity cam,0,0,1.0*fpsfak#
   If KeyDown(30) Then MoveEntity cam,-1.0*fpsfak#,0,0
   If KeyDown(32) Then MoveEntity cam,1.0*fpsfak#,0,0
   
   If mxs#<>0 Then RotateEntity cam,EntityPitch(cam),EntityYaw(cam)+mxs#,EntityRoll(cam)
   If mys#<>0 Then
      If mys#>0 Then
         If EntityPitch(cam)+mys#>70
            mys#=70-EntityPitch(cam)
         EndIf
         RotateEntity cam,EntityPitch(cam)+mys#,EntityYaw(cam),EntityRoll(cam)
      ElseIf mys#<0 Then
         If EntityPitch(cam)+mys#<-70
            mys#=-70-EntityPitch(cam)
         EndIf
         RotateEntity cam,EntityPitch(cam)+mys#,EntityYaw(cam),EntityRoll(cam)
      EndIf
   EndIf

   UpdateWorld
   RenderWorld
   Text 0,10, "Info"
   Text 0,30, "+/- Licht heller/dunkler"
   Flip
   fpsf=fpsf+1
   
Wend

End


Collisions TYPE_CAMERA,TYPE_LEVEL,2,2 <- Hiermit bestimme ich ja, daß ich an dem Level mit der Camera kollidiere, aber wie mache ich es, das ich immer auf dem Boden bleibe ? Ich hatte gestern was zusammengeschustert das hat soweit funktioniert aber immer nur soweit, das ich auf einer Treppe bei der 5. Stufe hängen geblieben bin ....

So wie es jetzt ist, fliege ich immer durch den Level.
(ja und ich weiß, irgendwas stimmt noch nicht so ganz mit dem umschauen mit der Maus (versuch ich später zu lösen Smile )
 

IonPainter

BeitragFr, Mai 07, 2004 23:08
Antworten mit Zitat
Benutzer-Profile anzeigen
du musst gravitation einbauen, also den player mit translateentity nach unten bewegen in jedem schleifendurchlauf.
 

YellowRider2

Gast

BeitragSa, Mai 08, 2004 13:43
Antworten mit Zitat
Am Umschauen mit der Maus habe ich ziemlich lange dran gehangen. Was hinterher rauskam ist aber umso besser:

Code: [AUSKLAPPEN]


Global ms=20
Global cx#
Global cy#

Global down#=-0.2 ;Erdanzieungsgeschwindigkeit

Global player=CreatePivot()
PositionEntity player,6,4,-6
EntityRadius player,1.8
EntityType player,1

Global cam=CreateCamera()
PositionEntity cam,EntityX(player),EntityY(player)+3,EntityZ(player)

While Not KeyHit(1)
 mouse()
 
 TranslateEntity player,0,down#,0
 PositionEntity cam,EntityX(player),EntityY(player)+3,EntityZ(player)

Wend


Function mouse()
   
   mxs=MouseXSpeed()*ms ;(20)
   mys=MouseYSpeed()*ms ;(20)
   
   cx#=EntityPitch(cam)+mys*0.01
   cy#=EntityYaw(cam)-mxs*0.01
   
   If cx#>89 Then cx#=89
   If cx#<-89 Then cx#=-89
   
   RotateEntity cam,cx,cy,0
   RotateEntity player,EntityPitch(player),cy,0
   MoveMouse grx2,gry2
End Function
 

KarlosKojote

BeitragSa, Mai 08, 2004 15:39
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke, das mit der Gravitation hat geklappt und das mit dem umschauen mit der Maus werde ich mir nun auch mal reintun Smile

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group