[B3D] Schwerkraft - Kamera

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

BastianA

Betreff: [B3D] Schwerkraft - Kamera

BeitragMo, Aug 23, 2010 14:06
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo, ich habe ein kleines Problem mit der Schwerkraft.

Meine Kamera habe ich mithilfe
Code: [AUSKLAPPEN]

MoveEntity cam1,0,0,-0.3


in der Hauptschleife nach unten gezogen. Allerdings fliege ich dann unendlich. Die Kamera hat Kollisionen mit ner Box:
Code: [AUSKLAPPEN]
;Kollisionen
EntityType map, 1
EntityType cam1, 2
EntityBox cam1, 0.2, 0.9, 0.25, 0.4, 1.8, 0.5
Collisions 2, 1, 2, 3


Die Kollisionen zwischen Kamera und Map klappen, nur wenn man halt über nen Gehsteig nicht drüber kommt, wird man so hochgezgen und wenn man dann zurück auf etwas tiefer gelegens geht, bleibt die Kamera auf der Position. Ich hab auch schon versucht, die Kamera um weniger nach unten zu bewegen, allerdings passiert im Endefekkt das gleiche. Wenn ich irgendwo runtergehe, fliege ich unendlich lang, was mache ich falsch?

Hier mein kompletter Code, unnötige Sachen weggelassen:
Code: [AUSKLAPPEN]

Graphics3D 1024, 600, 32, 0
SetBuffer BackBuffer()
AntiAlias enabled


;Ladebildschirm

Text 640,512,"Bitte Warten . . . ",True,True
Rect 255, 255, 800, 600 Bild = LoadImage  ("GUI\laden.bmp")
DrawBlock Bild, 255, 255
Delay(200)
Cls
Text 400,300,"Done!",True,True


light = CreateLight()
RotateEntity light, 90, 0, 0
AppTitle "VTram 2"
font = LoadFont("Calibri",20,1)
SetFont font

Tram = LoadMesh("model\Greenspring\Tram2.3DS")
PositionEntity Tram, 1.4, 0, 0
RotateEntity Tram, 0, 45, 0

Dash = LoadMesh("model\Greenspring\dash.3DS", Tram)

nachlaeufer = LoadMesh("model\Greenspring\Tram1.3DS")
PositionEntity nachlaeufer, 6.75, 0, -5.2406
RotateEntity nachlaeufer, 0, 45, 0

LightMesh Tram, -50, -50, -50, 200, 0, 1, 8

Map = LoadMesh("Scene\Föhrenried\map2.3ds")
PositionEntity map, 0, 0, 0
RotateEntity map, 0, 0, 0

Glas = LoadMesh("Scene\Föhrenried\Glas.3ds")
PositionEntity glas, 0, 0, 0
RotateEntity glas, 0, 0, 0
EntityAlpha glas, 0.8

Tuer1 = LoadMesh("Scene\Föhrenried\Tuer2.3ds")
PositionEntity Tuer1, 2.55, 0, -30.2

Tuer2 = LoadMesh("Scene\Föhrenried\Tuer1.3ds")
PositionEntity Tuer2, -2.55, 0, -30.2

dspeed = LoadMesh("model\Greenspring\speed.3ds", Tram)
PositionEntity dspeed, -0.188, 1.5327, 6.918
RotateEntity dspeed, 0, 180, 180

TurHebel = LoadMesh("model\Greenspring\TurHebel.3ds", Tram)
PositionEntity TurHebel, 0.008, 1.7154, 6.625
RotateEntity TurHebel, 0, 220, 180

Box = LoadMesh("Skybox\Skybox.3ds")
PositionEntity map, 0, 0, 0
AddMesh Box, Tram

Global cam1=CreateCamera(Tram)
CameraZoom cam1, 1

Global AmpleZeit%, AmpleFrame%
CameraRange cam1, 0.001, 5000

PositionEntity cam1, 0, 2.2, 6.1
RotateEntity cam1, 20, 0, 0

Baum1 = CreateCube()
PositionEntity Baum1, -5, 6, -07
textur1 = CreateTexture (1024, 1024, 4)
textur1 = LoadTexture ("Scene\BMP\baum7.bmp", 4)
EntityTexture  baum1, textur1
ScaleEntity Baum1, 0.001, 6, 6

Baum1a = CreateCube()
PositionEntity Baum1a, -5, 6, -07
EntityTexture  baum1a, textur1
ScaleEntity Baum1a, 0.001, 6, 6
RotateEntity Baum1a, 0, 90, 0

;Ansagen Laden

;Ampeln :!
Amp1 = CreateCube()
PositionEntity Amp1, 44.544, 4.75, -15.811
tAmp1 = LoadAnimTexture("Signale\ampel.bmp", 1, 128, 512, 0, 4)
EntityTexture Amp1, tAmp1, 0.1
ScaleEntity Amp1, 0.01, 0.32, 0.12

Amp2 = CreateCube()
PositionEntity Amp2, 44.536, 2.71, -20.985
tAmp1 = LoadAnimTexture("Signale\ampel.bmp", 1, 128, 512, 0, 4)
EntityTexture Amp2, tAmp1, 0.1
ScaleEntity Amp2, 0.01, 0.32, 0.12

;-----------------------------------------------------------------------------

;Signale Texturen:
;Ganz ohne Kontakt:
Ssl = LoadAnimTexture("Signale\Sig8.bmp", 1, 256, 512, 0, 2)
Ssgt = LoadAnimTexture("Signale\Sig9.bmp", 1, 128, 512, 0, 4)
Ssglkt = LoadAnimTexture("Signale\Sig10.bmp", 1, 128, 1024, 0, 4)
;Mit Kontakt:
StK = CreateTexture (512, 512, 4)
StK = LoadTexture ("Signale/Sig4.bmp", 4)
St = CreateTexture (512, 512, 4)
St = LoadTexture ("Signale/Sig1.bmp", 4)
Sfl= CreateTexture (512, 512, 4)
Sfl = LoadTexture ("Signale/Sig5.bmp", 4)
SK= CreateTexture (512, 512, 4)
SK = LoadTexture ("Signale/Sig6.bmp", 4)
SOT= CreateTexture (512, 512, 4)
SOT = LoadTexture ("Signale/Sig7.bmp", 4)
;Signal 1 mit Kontaktplatte:
Sig2 = CreateCube()
PositionEntity Sig2, -10.398, 2.4245, 6.898
ScaleEntity Sig2, 0.01, 0.32, 0.12
RotateEntity Sig2, 0, 145, 0
;Signal 2 mit Kontaktplatte:
Sig1 = CreateCube()
PositionEntity Sig1, 59.287, 2.4245, -125.2
ScaleEntity Sig1, 0.01, 0.32, 0.12
RotateEntity Sig1, 0, 90, 0
EntityTexture Sig1, Ssl, 0.1
Sig1K = CreateCube()
PositionEntity Sig1K, 59.287, 2.4245, -125.18
ScaleEntity Sig1K, 0.01, 0.12, 0.12
EntityTexture  Sig1K, SOT
RotateEntity Sig1K, 0, 90, 0
;Signal 3, Kontaktplatte WIP
Sig3 = CreateCube()
PositionEntity Sig3, 61.802, 2.241, -77.963
ScaleEntity Sig3, 0.01, 0.5, 0.12
RotateEntity Sig3, 0, 90, 0
EntityTexture Sig3, Ssglkt, 0.1

;Kollisionen
EntityType map, 1
EntityType cam1, 2
EntityBox cam1, 0.2, 0.9, 0.25, 0.4, 1.8, 0.5
Collisions 2, 1, 2, 3

;Verkehr Laden

Auto1 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto1, -300, 0, -21.9
RotateEntity auto1, 0, -90, 0
Auto2 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto2, -250, 0, -21.9
RotateEntity auto2, 0, -90, 0
Auto3 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto3, -200, 0, -21.9
RotateEntity auto3, 0, -90, 0
Auto4 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto4, -150, 0, -21.9
RotateEntity auto4, 0, -90, 0
Auto5 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto5, -100, 0, -21.9
RotateEntity auto5, 0, -90, 0
Auto6 = LoadMesh("Verkehr\maluch1\tex\car.3ds")
PositionEntity auto6, -80, 0, -21.9
RotateEntity auto6, 0, -90, 0

(...)
;-----------------------------------------------------------------------------

; Beleuchtung:
Licht=CreateLight()
TurnEntity licht, 0,90,0
MoveEntity licht,-30,30,30

;-----------------------------------------------------------------------------

;Variablen!
Global speed# = 0
Global brake# = 0.001
Global accelerate# = 0.00035
Global force# = 0.00004
Global Gangstufe# = 0
Global ubas# = 0
Global AZ1# = 0
Global Ma# = 0
Global ubas1# = 0
Global Bla# = 0
Global Bla2# = 500
Global Sek# = 33
Global Min# = 14
Global Std# = 15
Global TOpen# = 0
Global T1Open# = 0
Global cockpit# = 1.2
Global yansicht# = 0
Global Ibis_Intro_Zeit# = 0
Global IBIS_Sicht# = 0
Global kamerazoom# = 1


;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------


;Reinladen der Sounds
Include "Soundladen.bb"

;Dashboard-Funktionen

LoopSound kulisse
channelID = PlaySound (kulisse)

ChannelVolume channelID, 0.5

While Not KeyHit(1)

(...)

;Kamerasteuerung für Rumlaufen mit Camera
   
   TurnEntity cam1,MouseYSpeed(),0,0
   TurnEntity cam1,0,MouseXSpeed(),0,1
   MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
   
   MoveEntity cam1,0,-0.01,0

   If KeyDown(17) Then
   MoveEntity cam1, 0, 0, +0.02
    If ZaehlStart1 + 500 < MilliSecs() Then
     chn3 = PlaySound(s_schritte)
    ZaehlStart1 = MilliSecs()
   EndIf
   EndIf
   
   If KeyDown(31) Then
   MoveEntity cam1, 0, 0, -0.02
    If ZaehlStart1 + 500 < MilliSecs() Then
     chn3 = PlaySound(s_schritte)
    ZaehlStart1 = MilliSecs()
   EndIf
   EndIf
   
   If KeyDown(32) Then
   MoveEntity cam1, +0.02, 0, 0
    If ZaehlStart1 + 500 < MilliSecs() Then
     chn3 = PlaySound(s_schritte)
    ZaehlStart1 = MilliSecs()
   EndIf
   EndIf
   
   If KeyDown(30) Then
   MoveEntity cam1, -0.02, 0, 0
    If ZaehlStart1 + 500 < MilliSecs() Then
     chn3 = PlaySound(s_schritte)
    ZaehlStart1 = MilliSecs()
   EndIf
   EndIf
   
;Kamera-Schwenken   
   
If KeyDown(14) Then
PositionEntity cam1, 0, 1.8, 7
EndIf

If KeyDown(14) Then
PositionEntity cam1, 0, 1.8, 7
EndIf

If KeyDown(46) Then
TurnEntity cam1,0,0,0
EndIf

;Cockpit-Kamera-Standart-Einstellungen

If KeyDown(19) Then
PositionEntity cam1, 0, 2.2, 6.1
RotateEntity cam1, 20, 0, 0
kamerazoom# = 1
EndIf

If KeyDown(18) Then
TurnEntity cam1,0,-02.5,0
EndIf

If KeyDown(16) Then
TurnEntity cam1,0,+02.5,0
EndIf

;Kamera-Zoom

If KeyDown(22) Then
   kamerazoom# = kamerazoom# + 0.01
   EndIf
   
If KeyDown(23) Then
   kamerazoom# = kamerazoom# +-0.01
   EndIf      

CameraZoom cam1,kamerazoom#

(...)

RenderWorld   
UpdateWorld
Text 0,75, "Weg: " + Int(FahrStrecke#)
Text 0,0, "Himmelsrichtung: " + Int(Winkel#)
Text 0,15, "Position-X: " + Int(EntityX(Tram))
Text 0,30, "Position-Y: " + Int(EntityZ(Tram))
Text 0,45, "Abschnitt: " + Int(Abschnitt)
Text 0,60,"Tempo= " + speed * 100 + " km/h"
Text 0,90,"Gangstufe: " + Int(Gangstufe#)
Text 0,105,"Nicht Beachtete Ampeln/Signale: " + Int(ubas#) 
Text 0,120,"Schaltzeit: " + Int(AZ1#)
Text 0,135,"Motor: " + Int(Ma#)
Text 0,155,"Speed (falsche Umrechnung!): " + speed
Text 950,20,Int Std# + ":" + Int Min# + ":" + Int Sek#
Text 0,170,"Alle Türen: " + Int(TOpen#)
Text 0,185,"Z-Achse: " + EntityZ(Cam1)
Text 0,200,"X-Achse " + EntityX(Cam1)
Text 0,215,"Y-Achse " + EntityY(Cam1)
Text 0,230, "Cockpit: " + Int(cockpit#)
Text 0,245, "Y-Ansicht: " + Int(yansicht#)
Text 0,260, "Z-Maus-Speed: " + MouseZSpeed()
Text 0,275, "IBIS Frame: " + IBISFrame
Text 0,300, "Kamera-Zoom: " + kamerazoom#
Flip
Wend
End


Sry fürs Falsche Forum.

Holzchopf

Meisterpacker

BeitragMo, Aug 23, 2010 14:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Na dann...

~VERSCHOBEN~
Dieser Thread passte nicht in das Forum, in dem er ursprünglich gepostet wurde.

mfG
Holzchopf
Erledige alles Schritt um Schritt - erledige alles. - Holzchopf
CC BYBinaryBorn - Yogurt ♫ (31.10.2018)
Im Kopf da knackt's und knistert's sturm - 's ist kein Gedanke, nur ein Wurm

Xeres

Moderator

BeitragMo, Aug 23, 2010 14:18
Antworten mit Zitat
Benutzer-Profile anzeigen
a) TranslateEntity statt Moveentity und b) ist Y im Normalfall die Höhe, X und Z bilden die Standfläche im Koordinatensystem (es sei denn, du drehst alle Objekte entsprechend).
Die Gravitation musst du nur wirken lassen, wenn kein Kontakt zum Boden besteht.

Code: [AUSKLAPPEN]
StK = CreateTexture (512, 512, 4)
StK = LoadTexture ("Signale/Sig4.bmp", 4)
Damit verschwendest du Speicher; Beim Laden wird selbstverständlich auch der passende Speicher bereit gestellt, die Textur die du davor manuell erstellst und nicht mehr freigibst, müllt den Speicher zu.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group