unsichtbare Wand?

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

 

LorDtaiBsn

Betreff: unsichtbare Wand?

BeitragSa, Jan 02, 2010 18:53
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo Freunde, hab' folgendes Problem - ich habe mir jetzt eine Umgebung geschaffen, bei der soweit größtenteils alles funktioniert. Aber: Wenn ich eine bestimmte höhe überschreite, will meine Kamera einfach nicht mehr höher gehen. Das selbe auch bei der Tiefe. Als würde eine unsichtbare Box existieren, die mich bei Kollision einfach nicht weiter lässt. soweit ich weiß, ist da aber keine. Warum kann ich mich nicht weiter nach oben bzw. unten bewegen?

Hier der Code:
BlitzBasic: [AUSKLAPPEN]
Include "include\FastExt.bb"	; <<<<    Include FastExt.bb file


Graphics3D 800,600,32,2


InitExt ; Initialize library after Graphics3D function

Const CAM_COL=2
Const TER_COL=1

; Customize effects

CustomPostprocessDOF 150, 300, 1, 10, 0.35, 1
CustomPostprocessGlow 0.2, 16, 8, 0.35, 2


Global xDOF = 1
Global xGlow = 1


Global Warning$ = ""
DetectSupport()


Global Camera
Global CameraSprite
CreateCameraAndLight()



Global SkyBox
Global Duck
CreateSceneObjects()



Global TextureSize = 1024
Global ReflectTexture
Global RefractAndReflectTexture
CreateRefractAndReflectTextures(TextureSize, TextureSize)



Global WaterPlane
Global WaterClipplane
Global BumpTexture
Global AlphaCubemap
Global ClipPivot
Global ClipPivotUp
CreateWater()


UnderWaterFlag = 0


; :: MONSTER ::

KnightTex=LoadTexture("media\hellknight.jpg")


Knight = LoadMesh("media\hellknight.3ds", SceneEntities)
ScaleEntity Knight,0.03,0.03,0.03
PositionEntity Knight,-5,-0,0
EntityTexture Knight, KnightTex

; :: MONSTER ENDE ::


yg#=100

cross=LoadImage("tex/cross.png")
hp=LoadImage("tex/100hp.png")

MaskImage hp,255,255,255
MaskImage cross,255,255,255



MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

While Not KeyHit(1)

CameraMove# = 0

Grav = Grav - 1

If EntityCollided(camera,TER_COL) Then Grav = 0
TranslateEntity camera,0,(Grav*0.005),0



; render reflection to texture (hide water)

CameraFogMode Camera,0
HideEntity CameraSprite

ShowClipplane WaterClipplane
AlignClipplane WaterClipplane, ClipPivot

HideEntity WaterPlane

MirrorCamera Camera, WaterPlane
SetBuffer TextureBuffer(ReflectTexture)
CameraViewport Camera, 0,0, TextureWidth(ReflectTexture), TextureHeight(ReflectTexture)
ScaleEntity Camera,1,Float(GraphicsHeight())/Float(GraphicsWidth()),1


RenderWorld
RestoreCamera Camera


; render refraction with water (set reflection texture to water)

AlignClipplane WaterClipplane, ClipPivotUp

ShowEntity WaterPlane
EntityTexture WaterPlane, ReflectTexture, 0, 0
EntityTexture WaterPlane, AlphaCubemap, 0, 1
If UnderWaterFlag Then
EntityAlpha WaterPlane,0.95
Else
EntityAlpha WaterPlane,0.85
EndIf
EntityColor WaterPlane,255,255,255

SetBuffer TextureBuffer(RefractAndReflectTexture)
CameraViewport Camera, 0,0, TextureWidth(RefractAndReflectTexture), TextureHeight(RefractAndReflectTexture)
ScaleEntity Camera,1,Float(GraphicsHeight())/Float(GraphicsWidth()),1


RenderWorld



; render world (set refraction texture to water)

If UnderWaterFlag
ShowEntity CameraSprite
CameraFogMode Camera,1
CameraFogRange Camera,0.5,25
CameraFogColor Camera,20,20,40
Else
HideEntity CameraSprite
CameraFogMode Camera,1
CameraFogRange Camera,20,250
CameraFogColor Camera,212,242,244
EndIf

HideClipplane WaterClipplane

ShowEntity WaterPlane
EntityTexture WaterPlane, BumpTexture, (BumpTextureFrame Mod 32), 0
EntityTexture WaterPlane, RefractAndReflectTexture, 0, 1
EntityAlpha WaterPlane,1
EntityColor WaterPlane,220,230,240

SetBuffer BackBuffer()
CameraViewport Camera, 0,0, GraphicsWidth(), GraphicsHeight()
ScaleEntity Camera,1,1,1

Collisions CAM_COL,TER_COL,2,2


UpdateWorld
RenderWorld




; input management

MouseLook Camera

If KeyHit(2) Then PositionEntity Camera, -10.3, 1.3, 34 : RotateEntity Camera, 0, 52, 0
If KeyHit(3) Then PositionEntity Camera, 2, 14.5, 12.8 : RotateEntity Camera, 53, -163, 0
If KeyHit(4) Then PositionEntity Camera, 0, -2, -4 : RotateEntity Camera, 0, 0, 0
If KeyHit(5) Then PositionEntity Camera, 0, 3, 0 : RotateEntity Camera, 0, 0, 0
If KeyHit(6) Then PositionEntity Camera, 0, 0, 0 : RotateEntity Camera, 0, 0, 0

; camera under water?
If EntityY(Camera)>=0 Then
UnderWaterFlag = 0
RotateEntity WaterPlane,0,0,0
RotateEntity ClipPivot,0,0,0
RotateEntity ClipPivotUp,0,0,180
PositionEntity ClipPivotUp, 0, 0.05, 0
Else
UnderWaterFlag = 1
RotateEntity WaterPlane,0,0,180
RotateEntity ClipPivot,0,0,180
RotateEntity ClipPivotUp,0,0,0
PositionEntity ClipPivotUp, 0, -0.05, 0
EndIf



; other input management and texture animation

PositionEntity SkyBox,EntityX(Camera,1),EntityY(Camera,1),EntityZ(Camera,1),1
; MoveEntity Duck,0,0,-0.01 : TurnEntity Duck,0,0.1,0

If (MilliSecs()-BumpTextureFrameF)>33 Then
BumpTextureFrame = BumpTextureFrame + 1
BumpTextureFrameF = MilliSecs()
EndIf

If KeyHit(28) Then
If TextureSize=256 Then
TextureSize=512
Else
TextureSize=256
EndIf
CreateRefractAndReflectTextures (TextureSize, TextureSize)
EndIf
If KeyHit(59) Then HelpFlag=1-HelpFlag
If KeyHit(60) Then FlipSync=1-FlipSync



; ---- âûâîä òåêñòà
; draw text

Text GraphicsWidth()-70,10,"Fps: "+FPS()
If HelpFlag
Color 0,0,0
Text 10,10,"F1 for hide help"
Text 10,30,"Keys 1,2,3,4 - change position"
Text 10,50,"Keys W,S,A,D and mouse - flying"
Text 10,70,"Key Enter - reflection and refraction quality: "+TextureSize+" x "+TextureSize
Text 10,90,"Key F2 - Flip synchronization: "+FlipSync
If Len(Warning)>0 Then
Color 255,0,0
Text 10,110,Warning
EndIf
Else
Color 0,0,0
; Text 10,10,"F1 for help"
If Len(Warning)>0 Then
Color 255,0,0
Text 10,30,Warning
EndIf
EndIf

DrawImage cross,GraphicsWidth()/2,GraphicsHeight()/2
DrawImage hp,30,GraphicsHeight()-84


; RenderPostprocess xDOF
RenderPostprocess FE_GLOW


Flip FlipSync
Wend

FreeTexture ReflectTexture
FreeTexture RefractAndReflectTexture
End





Function DetectSupport()
If GfxDriverCapsEx\ClipplanesMax=0 Then Warning = "Warning! Your video-card not support clipplanes. "
If GfxDriverCapsEx\Bump=0 Then Warning = Warning + "Warning! Your video-card not support EMBM (Bump). "
End Function


Function CreateRefractAndReflectTextures(w,h)
; ----
If ReflectTexture Then FreeTexture ReflectTexture
If RefractAndReflectTexture Then FreeTexture RefractAndReflectTexture
; ----
ReflectTexture = CreateTexture (w, h, 1+16+32+256 + FE_RENDER + FE_ZRENDER)
TextureBlend ReflectTexture, FE_PROJECT
PositionTexture ReflectTexture, 0.5, 0.5
ScaleTexture ReflectTexture, 2, -2
; ----
RefractAndReflectTexture = CreateTexture ( w, h, 1+16+32+256 + FE_RENDER + FE_ZRENDER)
TextureBlend RefractAndReflectTexture, FE_PROJECT
PositionTexture RefractAndReflectTexture, 0.5, 0.5
ScaleTexture RefractAndReflectTexture, 2, 2
; ----
End Function


Function CreateWater()
; ----
;
BumpTexture = LoadAnimTexture ( "media\water_anim.jpg", 9, 64, 64, 0, 32 )
TextureBlend BumpTexture, FE_BUMP
ScaleTexture BumpTexture,0.0125,0.0125
; ----
;
AlphaCubemap = LoadTexture("media\grad.png",1+2+16+32+128)
TextureBlend AlphaCubemap, FE_ALPHAMODULATE
; ----
;
WaterPlane = LoadMesh("media\Water32.3DS")
ScaleMesh WaterPlane,8,1,8;2,1,2
EntityFX WaterPlane,1
; ----
;
;
WaterClipplane = CreateClipplane ( WaterPlane )
; ----
;
;
ClipPivot = CreatePivot()
ClipPivotUp = CreatePivot() : RotateEntity ClipPivotUp,0,0,180 : PositionEntity ClipPivotUp, 0, 0.05, 0
; ----
End Function



Function CreateCameraAndLight()
; ----
SetFont LoadFont("",14)
Color 0,0,0
; ----
Camera=CreateCamera()
PositionEntity Camera,50,10,50
CameraRange Camera,0.1,5000
CameraClsColor Camera,222,252,254
CameraSprite = CreateSprite(Camera)
PositionEntity CameraSprite,0,0,0.11
EntityColor CameraSprite,20,20,40
EntityAlpha CameraSprite,0.35
EntityType camera,CAM_COL
; ----
Light = CreateLight()
; ----
End Function




Function CreateSceneObjects()
; ----
SkyBox = LoadSkyBox ( "media\sky2" )
; ----
; Tower = LoadMesh("media\tower.b3d")
; ScaleEntity Tower,0.03,0.03,0.03
; PositionEntity Tower,0,-7,15
; EntityFX Tower,16
; EntityColor Tower,180,180,180
; ----
For i=1 To 15
If i=1 Then
Box = LoadMesh("media\wcrate.3ds") : j = Box
Else
j=CopyEntity (Box)
EndIf: ScaleEntity j,0.025,0.025,0.025
PositionEntity j,Rnd(-15,15),Rnd(-0.5,0.5),Rnd(-15,15)
TurnEntity j,Rnd(-15,15),Rnd(-15,15),Rnd(-15,15)
EntityFX j,16
EntityType j,TER_COL
Next
; ----
; Duck = LoadMesh("media\RDuck.3ds")
; ScaleEntity Duck,0.5,0.5,0.5
; PositionEntity Duck,5,0,6
; EntityFX Duck,16
; ----
LandTex1=LoadTexture("media\dgrass.jpg") : ScaleTexture LandTex1, 10, 10
LandTex2=LoadTexture("media\lmap.JPG")
Landscape=LoadTerrain( "media\hmap.jpg")
Landcol=LoadTerrain("media\hmap.jpg")
ScaleEntity Landscape,2,25,2;2,15,2
ScaleEntity Landcol,2,15,2;1,15,1
PositionEntity Landscape,-2*64,-10,-2*64
PositionEntity Landcol,-2*64,-3,-2*64
EntityAlpha Landcol,0
TerrainDetail Landcol, 3000, 1
TerrainDetail Landscape, 3000, 1
EntityTexture Landscape, LandTex1, 0, 0
EntityTexture Landscape, LandTex2, 0, 1
ScaleTexture LandTex2,TerrainSize(Landscape)/1,TerrainSize(Landscape)/1
EntityFX Landscape,1+16
; LandscapeDown = CreateCube()
; ScaleEntity LandscapeDown,256,0.1,256
; EntityColor LandscapeDown,80,120,80
; PositionEntity LandscapeDown,0,-4.5,0
EntityType Landscape,TER_COL
; ----
End Function






Global FPSCount = 0
Global FPSCountTemp = 0
Global FPSTime = 0
Function FPS()
If (MilliSecs()-FPSTime)>=1000 Then
FPSTime = MilliSecs()
FPSCount = FPSCountTemp
FPSCountTemp = 0
EndIf
FPSCountTemp = FPSCountTemp + 1
Return FPSCount
End Function


Global DeltaTimeOld = MilliSecs()

Function MouseLook(cam)



Local t=MilliSecs()
Local dt = t - DeltaTimeOld
DeltaTimeOld = t
Local dk# = Float(dt)/16.666
DeltaTimeK = dk
s#=0.2*dk
dx#=(GraphicsWidth()/2-MouseX())*0.2
dy#=(GraphicsHeight()/2-MouseY())*0.2
TurnEntity cam,-dy,dx,0
RotateEntity cam,EntityPitch(cam,1),EntityYaw(cam,1),0,1
If KeyDown(17) MoveEntity cam,0,0,s
If KeyDown(31) MoveEntity cam,0,0,-s
If KeyDown(32) MoveEntity cam,s,0,0
If KeyDown(30) MoveEntity cam,-s,0,0
If KeyDown(57) MoveEntity cam,0,s,0
If KeyDown(17) And KeyDown(42) MoveEntity cam,0,0,(s*1.5)
If KeyDown(31) And KeyDown(42) MoveEntity cam,0,0,-(s*1.5)
If KeyDown(32) And KeyDown(42) MoveEntity cam,(s*1.5),0,0
If KeyDown(30) And KeyDown(42) MoveEntity cam,-(s*1.5),0,0
y# = EntityY(cam,1)
If y<-3 Then y=-3
If y>5 Then y=5
PositionEntity cam, EntityX(cam,1),y,EntityZ(cam,1)
MoveMouse GraphicsWidth()/2, GraphicsHeight()/2
RotateEntity cam,EntityPitch(cam,1),EntityYaw(cam,1),0,1



End Function

Function LoadSkyBox( file$ )
m=CreateMesh()
;front face
b=LoadBrush( file$+"_FR.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3:
FreeBrush b
;right face
b=LoadBrush( file$+"_LF.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;back face
b=LoadBrush( file$+"_BK.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;left face
b=LoadBrush( file$+"_RT.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;top face
b=LoadBrush( file$+"_UP.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;bottom face
b=LoadBrush( file$+"_DN.jpg",49 )
If b=0 b=CreateBrush (0,30,50)
s=CreateSurface( m,b )
AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,500,500,500
FlipMesh m
EntityFX m,1+8
EntityOrder m,999
Return m
End Function


Desweiteren brauche ich Ideen, ich bin jetzt froh, die Grundumgebung mit schönem Wasser so hingekriegt zu haben, jetzt weiß ich nicht, wie ich weiter machen soll. Soll ein Ego-Shooter werden. So in Richtung Far Cry, natürlich nur vom Prinzip her. Smile Hier mal nen paar Screens, wie's bis jetzt aussieht.

user posted image

user posted image

Chester

BeitragSa, Jan 02, 2010 19:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich nehme an, dass da ein bisschen was aus irgendwelchen Samples kopiert wurde? Wink

In der MouseLook Funktion steht nämlich folgende Begrenzung drin:

BlitzBasic: [AUSKLAPPEN]
y# = EntityY(cam,1)
If y<-3 Then y=-3
If y>5 Then y=5
PositionEntity cam, EntityX(cam,1),y,EntityZ(cam,1)
 

LorDtaiBsn

BeitragSa, Jan 02, 2010 19:23
Antworten mit Zitat
Benutzer-Profile anzeigen
Ähh,.. Samples? Rolling Eyes Very Happy ja, leider schon. Vor allem aus UserLib-Samples. Aber ich versuche das soweit wie möglich einzugrenzen. Danke aber für die Hilfe!!

Eine Frage habe ich aber noch, kann man die Hitbox von der Kollision etwas kleiner machen? Die Abstände sind nämlich ziemlich krass meiner Meinung nach.

Nicdel

BeitragSa, Jan 02, 2010 19:28
Antworten mit Zitat
Benutzer-Profile anzeigen
EntityRadius auf die Kamera anwenden.
Desktop: Intel Pentium 4 2650 Mhz, 2 GB RAM, ATI Radeon HD 3850 512 MB, Windows XP
Notebook: Intel Core i7 720 QM 1.6 Ghz, 4 GB DDR3 RAM, nVidia 230M GT, Windows 7
 

LorDtaiBsn

BeitragSo, Jan 03, 2010 3:13
Antworten mit Zitat
Benutzer-Profile anzeigen
Cool, danke Jungs!

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group