Предлагаю викладывать подключаемые исходники на разные ефекты на Blitz3D новичкам:) :)
Предлагаю викладывать подключаемые исходники на разные ефекты на Blitz3D новичкам:) :)
если кто-то выложит исходничек огня, буду благодарен.
P.s. простой спрайтовый огонёк(тогда когда берётся от одного спрайта и болие(врощаем их, меняем их похицию, скалим)) - не подходит. нужно что-то, что выглядело бы вполне реально :).
Ниже приведена реализация эфекта Motion Blur.
Только этот код у меня не заработал чего-то пока не разбирался, просто интересная назодка для блитца.
Этот код был взят с одного англоязычного сайта, сорри, адресс не помню.
Код:;====== Full Screen Motion Blur ================================================================= ;====== PROGRAMMED BY JEREMY ALESSI ============================================================= ;====== Requires Rob's Sprite Functions ========================================================= ;====== SPRITE FUNCTIONS IF YOU NEED THEM ======================================================= ;====== IF NOT JUST COMMENT THEM OUT ============================================================ ;fov is the same as your CameraZoom. Function Sprite2D(sprite,x#,y#,fov#) PositionEntity sprite,2*(x#-320),-2*(y#-240),fov#*640 End Function ;scale sprite in screen pixels relative to a 640x480 res when used with Sprite2D Function ScaleSprite2(sprite,x,y) ScaleEntity sprite,x,y,1 End Function ;please pass camera to this function Or 0 for a billboard Type with mesh. Function CreateSprite2(parent) If parent<>0 m=CreateMesh(parent) Else m=CreateMesh() EndIf s=CreateSurface(m) 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 ScaleEntity m,100,100,1 Return m End Function ;================================================================================================ ;====== GLOBAL VARIABLES ======================================================================== Global blur_2 Global blur_3 Global blur_4 Global blur_timer_2#=MilliSecs() Global blur_timer_3#=MilliSecs() Global blur_timer_4#=MilliSecs() ;================================================================================================ ;====== CALL THIS TO SET UP BLUR CAMERA, CHILDREN, AND TEXTURES ================================= ;====== CALL IT AFTER SETTING UP THE MAIN CAMERA AND THEN PASS THE CAMERA ======================= ;====== BLUR_SEVERITY BECOMES WORSE WITH HIGHER NUMERICAL ALPHA LEVELS ========================== ;====== SET THE SEVERITY AND THE FALLOFF VALUES SO THAT ALL 3 BLUR HUDS TOGETHER ARE STILL ====== ;====== TRANSPARENT ============================================================================= Function SetupBlurCamera(blur_camera,blur_severity#=.5,falloff_one#=.3,falloff_two#=.4,field_of_view#=1) blur_2=CreateTexture(Float(GraphicsWidth()),Float(GraphicsHeight()),256) width_ratio#=TextureWidth(blur_2)/Float(GraphicsWidth()) height_ratio#=TextureHeight(blur_2)/Float(GraphicsHeight()) ScaleTexture(blur_2,width_ratio#,height_ratio#) blur_hud_2=CreateSprite2(blur_camera) NameEntity(blur_hud_2,"blur_hud_2") EntityOrder(blur_hud_2,-2) EntityFX(blur_hud_2,1+8) ScaleSprite2(blur_hud_2,640,480) Sprite2D(blur_hud_2,320,240,field_of_view#) EntityAlpha(blur_hud_2,blur_severity#) blur_3=CreateTexture(Float(GraphicsWidth()),Float(GraphicsHeight()),256) ScaleTexture(blur_3,width_ratio#,height_ratio#) blur_hud_3=CreateSprite2(blur_camera) NameEntity(blur_hud_3,"blur_hud_3") EntityOrder(blur_hud_3,-2) EntityFX(blur_hud_3,1+8) ScaleSprite2(blur_hud_3,640,480) Sprite2D(blur_hud_3,320,240,field_of_view#) EntityAlpha(blur_hud_3,blur_severity#-falloff_one#) blur_4=CreateTexture(Float(GraphicsWidth()),Float(GraphicsHeight()),256) ScaleTexture(blur_4,width_ratio#,height_ratio#) blur_hud_4=CreateSprite2(blur_camera) NameEntity(blur_hud_4,"blur_hud_4") EntityOrder(blur_hud_4,-2) EntityFX(blur_hud_4,1+8) ScaleSprite2(blur_hud_4,640,480) Sprite2D(blur_hud_4,320,240,field_of_view#) EntityAlpha(blur_hud_4,blur_severity#-falloff_two#) HideEntity(blur_hud_2) HideEntity(blur_hud_3) HideEntity(blur_hud_4) End Function ;================================================================================================ ;====== BLUR FUNCTION, CALL BEFORE RENDERWORLD ================================================== ;====== PASS THE CAMERA TO IT, HOW MUCH DURATION BETWEEN LATENT IMAGES OR JUST HOW MUCH BLUR ==== ;====== AND WHETHER YOU WANT TO COPY FROM THE FRONT OR BACK BUFFER 1=FRONT 2=BACK =============== ;====== BE SURE TO CALL ShowBlur() BEFORE USING THIS OR THE BLUR WILL NOT APPEAR ================ ;====== YOU CAN ALSO USE HideBlur() SO THE EFFECT CAN BE CONTROLLED FOR A CERTAIN MODE ========== Function BlurScreen(blur_camera,blur_magnitude=30,back_or_front_buffer=1) If blur_timer_2#+blur_magnitude<MilliSecs() Select back_or_front_buffer Case 1 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,FrontBuffer(),TextureBuffer(blur_2)) Case 2 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,BackBuffer(),TextureBuffer(blur_2)) End Select EntityTexture(FindChild(blur_camera,"blur_hud_2"),blur_2) blur_timer_2#=MilliSecs() EndIf If blur_timer_3#+2*blur_magnitude<MilliSecs() Select back_or_front_buffer Case 1 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,FrontBuffer(),TextureBuffer(blur_3)) Case 2 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,BackBuffer(),TextureBuffer(blur_3)) End Select EntityTexture(FindChild(blur_camera,"blur_hud_3"),blur_3) blur_timer_3#=MilliSecs() EndIf If blur_timer_4#+3*blur_magnitude<MilliSecs() Select back_or_front_buffer Case 1 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,FrontBuffer(),TextureBuffer(blur_4)) Case 2 CopyRect(0,0,Float(GraphicsWidth()),Float(GraphicsHeight()),0,0,BackBuffer(),TextureBuffer(blur_4)) End Select EntityTexture(FindChild(blur_camera,"blur_hud_4"),blur_4) blur_timer_4#=MilliSecs() EndIf End Function ;================================================================================================ ;====== HIDE THE BLUR EFFECTS =================================================================== Function HideBlur(blur_camera) HideEntity(FindChild(blur_camera,"blur_hud_2")) HideEntity(FindChild(blur_camera,"blur_hud_3")) HideEntity(FindChild(blur_camera,"blur_hud_4")) End Function ;================================================================================================ ;====== SHOW THE BLUR EFFECTS =================================================================== Function ShowBlur(blur_camera) ShowEntity(FindChild(blur_camera,"blur_hud_2")) ShowEntity(FindChild(blur_camera,"blur_hud_3")) ShowEntity(FindChild(blur_camera,"blur_hud_4")) End Function ;================================================================================================
Последний раз редактировалось rapt0r; 03.07.2006 в 11:12.
за блюр спасибо очеееень!!!!!
он у тебя заработал? а то у меня что-то не то идёт...
Вот, нашёл один исходничек, DragSelect 3D objects, очень удобно, хороший семпл, мне понравилось.
Код:Graphics3D 640,480 SetBuffer BackBuffer() Global camera=CreateCamera() PositionEntity camera,0,2,-10 light=CreateLight() RotateEntity light,90,0,0 Type cube Field status Field cube Field cube2 End Type brush=CreateBrush(0,255,0) obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,0,1,0 obj\cube2=CreateCube() PositionEntity obj\cube2,0,1,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,-5,1,0 obj\cube2=CreateCube() PositionEntity obj\cube2,-5,1,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,5,1,0 obj\cube2=CreateCube() PositionEntity obj\cube2,5,1,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,0,5,0 obj\cube2=CreateCube() PositionEntity obj\cube2,0,5,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,-5,5,0 obj\cube2=CreateCube() PositionEntity obj\cube2,-5,5,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,5,5,0 obj\cube2=CreateCube() PositionEntity obj\cube2,5,5,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,0,-3,0 obj\cube2=CreateCube() PositionEntity obj\cube2,0,-3,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,-5,-3,0 obj\cube2=CreateCube() PositionEntity obj\cube2,-5,-3,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False obj.cube=New cube obj\cube=CreateCube() PositionEntity obj\cube,5,-3,0 obj\cube2=CreateCube() PositionEntity obj\cube2,5,-3,0 ScaleEntity obj\cube2,1.1,1.1,1.1 EntityAlpha obj\cube2,0.4 HideEntity obj\cube2 PaintMesh obj\cube2,brush obj\status=False Global mouse=False,x_s=0,y_s=0,x_e=0,y_e=0 Repeat SetBuffer BackBuffer() Cls If mouse=False Then If MouseDown(1)=True Then mouse=True x_s=MouseX() y_s=MouseY() x_e=MouseX() y_e=MouseY() End If Else x_e=MouseX() y_e=MouseY() If MouseDown(1)=False Then select_cube() mouse=False End If End If For obj.cube = Each cube If obj\status=True Then TurnEntity obj\cube,1,1,1 TurnEntity obj\cube2,1,1,1 End If Next UpdateWorld() RenderWorld() If mouse=True Then Color 0,255,0 Line x_s,y_s,x_e,y_s Line x_s,y_s,x_s,y_e Line x_e,y_s,x_e,y_e Line x_e,y_e,x_s,y_e End If Flip Until KeyDown(1)=True Function select_cube() ;Setup x,y's If x_e<x_s Then x=x_e w=x_s-x_e Else x=x_s w=x_e-x_s End If If y_e<y_s Then y=y_e h=y_s-y_e Else y=y_s h=y_e-y_s End If For obj.cube = Each cube CameraProject(camera,EntityX(obj\cube),EntityY(obj\cube),EntityZ(obj\cube)) If RectsOverlap(ProjectedX()-5,ProjectedY()-5,10,10,x,y,w,h)=True Then obj\status=True ShowEntity obj\cube2 Else obj\status=False HideEntity obj\cube2 End If Next End Function
Это тоже интересны код, объект(в данном случае сфера) отбрасывает тень "перпендикулярно вниз", не идеален, много глюков, но тем не мене пример тени :).
Код:; Flexible Towel Shadows By Rob Cummings (rob@redflame.net), ; CreateFace function & assistance by David Bird ; ; Rough code here. Use for cloth sims, ; lights And shadows. Have fun! Load own image for fun or ; even use a character mesh as the Flex... AppTitle "Flexible Towel Shadows in Blitz3D" HidePointer Global camera,light,world,Flex,mx#,my#,ball,w ;setup graphics and scene Graphics3D 1024,768,16,1 SetBuffer BackBuffer() camera=CreateCamera() CameraRange camera,1,1600 MoveEntity camera,500,800,500 light=CreateLight(2) MoveEntity light,0,400,400 LightRange light,350 AmbientLight 50,50,50 ;make test world world=createworld() ;make shadow Flex=CreateFlex() ;make shadow texture t=CreateTexture(32,32,48+2) SetBuffer TextureBuffer(t) Color 255,255,255:Rect 0,0,32,32,1 For i=0 To 31 col=(255-(i*8)) pos=(i/2) wid=31-i Color col,col,col Oval pos,pos,wid,wid,1 Next Color 255,255,255 EntityTexture Flex,t EntityFX Flex,1 EntityBlend Flex,2 ;hack whitetexture=CreateTexture(32,32) ;make ball ball=CreateSphere() EntityColor ball,255,0,0 EntityShininess ball,1 ScaleEntity ball,50,50,50 MoveEntity ball,0,300,0 TurnEntity ball,0,-45,0 ;misc PointEntity camera,world SetBuffer BackBuffer() ;mainloop While Not KeyHit(1) If KeyHit(17) w=1-w WireFrame w ;visibility hack for you to test If w=1 EntityBlend Flex,1 Else EntityBlend Flex,2 EndIf EndIf mx#=MouseXSpeed()*0.5 my#=MouseYSpeed()*0.5 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 MoveEntity ball,-mx,0,my ;UpdateFlex(target deformable mesh (try a model!!),mesh that casts shadow) UpdateFlex(Flex,ball) UpdateWorld RenderWorld Text 0,0,"Use mouse to move ball, watch the shadow!" Text 0,16,"press 'w' to toggle wireframe mode, ESC to quit." Flip Wend End ;load your own level? but make it pickable. Function CreateWorld() p=CreatePivot() a=CreateCube(p) FitMesh a,-500,0,-500,1000,10,1000 a=CreateCube(p) FitMesh a,-200,10,-200,400,40,400 a=CreateSphere(8,p) ScaleEntity a,100,100,100 MoveEntity a,-200,0,-200 a=CreateSphere(8,p) ScaleEntity a,100,100,100 MoveEntity a,200,0,-200 a=CreateSphere(8,p) ScaleEntity a,100,100,100 MoveEntity a,200,0,200 a=CreateSphere(8,p) ScaleEntity a,100,100,100 MoveEntity a,-200,0,200 For i=1 To CountChildren(p) EntityPickMode GetChild(p,i),2 Next Return p End Function Function CreateFlex() m=CreateFace(8) ;segs ScaleEntity m,250,250,250 Return m End Function Function UpdateFlex(flexmesh,source) x#=EntityX(source):y#=EntityY(source):z#=EntityZ(source) PositionEntity flexmesh,x,y,z ;you can optimise by precalculating x and z s=GetSurface(flexmesh,1) For i=0 To CountVertices(s)-1 vx#=VertexX(s,i) vy#=0 vz#=VertexZ(s,i) TFormPoint vx,vy,vz,flexmesh,0 vx=TFormedX() : vy=TFormedY() : vz=TFormedZ() LinePick vx,vy,vz,vx,vy-9000,vz vy=PickedY()+50 TFormPoint vx,vy,vz,0,flexmesh vx=TFormedX() : vy=TFormedY() : vz=TFormedZ() VertexCoords s,i,vx,vy,vz Next End Function ;Creates a single sided face ;segmented Function CreateFace(segs=1,double=False,parent=0) mesh=CreateMesh( parent ) surf=CreateSurface( mesh ) stx#=-.5 sty#=stx stp#=Float(1)/Float(segs) y#=sty For a=0 To segs x#=stx v#=a/Float(segs) For b=0 To segs u#=b/Float(segs) AddVertex(surf,x,0,y,u,v) ; swap these for a different start orientation x=x+stp Next y=y+stp Next For a=0 To segs-1 For b=0 To segs-1 v0=a*(segs+1)+b:v1=v0+1 v2=(a+1)*(segs+1)+b+1:v3=v2-1 AddTriangle( surf,v0,v2,v1 ) AddTriangle( surf,v0,v3,v2 ) Next Next UpdateNormals mesh If double=True Then EntityFX mesh,16 Return mesh End Function
Последний раз редактировалось rapt0r; 06.07.2006 в 22:01.
Ну, это просто красиво :), определённое время будет просто чёрное окно, стоит подождать немного.
Vertex lighting
под водой, над водой, смотритсо симпатично, но это вам не шеКод:Graphics3D 640,480,16 ;AmbientLight 0,0,0 For x=1 To 5 For y= 1 To 5 For z= 1 To 5 sphere=CreateSphere( 32 ) PositionEntity sphere,x*5,y*5,z*5 ApplyAmbient(sphere,32,32,32) ApplyLight(sphere,25,0,0,20,1,255,32,32) ApplyLight(sphere,0,0,0,20,1,32,32,255) ApplyLight(sphere,12.5,25,0,20,1,32,255,32) ApplyLight(sphere,25,0,15,20,1,32,255,32) ApplyLight(sphere,0,0,15,20,1,255,32,32) ApplyLight(sphere,12.5,25,15,20,1,32,32,255) ApplyLight(sphere,25,0,20,20,1,32,255,255) ApplyLight(sphere,0,0,20,20,1,255,255,32) ApplyLight(sphere,12.5,25,20,20,1,255,32,255) ApplyLight(sphere,12.5,12.5,12.5,20,1,255,255,255) EntityFX sphere,3 Next Next Next camera=CreateCamera() PositionEntity camera,12,12,2 RotateEntity camera,0,0,315 While Not KeyHit(1) UpdateWorld RenderWorld Flip Wend Function ApplyLight(entity,LX#,LY#,LZ#,radius#,flag,Lr,Lg,Lb) ;Lambert shading in blitz "by Staton Richardson (Arbitrage)" ;This function is meant for 1 time lighting not realtime ;entity is the entity you wish to light ;LX, LY, LZ are the coodinates of the light in world space ;Lr, Lg, Lb are the colors of the light ;radius is the radius the light affects. Light falls off with distance so half the radius would be half the light ;flag tells the function to include the current vertex color for multiple lights count=CountSurfaces(entity) For n=1 To count surf=GetSurface(entity,n) Vcount=CountVertices(surf)-1 For v=0 To Vcount xd#=VertexX(surf,v)+EntityX(entity)-LX# yd#=VertexY(surf,v)+EntityY(entity)-LY# zd#=VertexZ(surf,v)+EntityZ(entity)-LZ# mag#=Sqr(xd#*xd# + yd#*yd# + zd#*zd#) If flag=1 vcr=VertexRed(surf,v) vcg=VertexGreen(surf,v) vcb=VertexBlue(surf,v) EndIf vr=Lr-(Lr/radius)*mag# vg=Lg-(Lg/radius)*mag# vb=Lb-(Lb/radius)*mag# If vr>255 Then vr=255 If vg>255 Then vg=255 If vb>255 Then vb=255 vx#=VertexNX(surf,v) vy#=VertexNY(surf,v) vz#=VertexNZ(surf,v) mag#=1/mag# LnY#=yd#*mag#*-1 LnX#=xd#*mag#*-1 LnZ#=zd#*mag#*-1 Kh#=((vx)*LnX+(vy)*LnY+(vz)*LnZ) If kh#>0 VertexColor surf,v,vr*Kh#+vcr,vg*Kh#+vcg,vb*Kh#+vcb EndIf Next Next End Function Function ApplyAmbient(entity,r,g,b) count=CountSurfaces(entity) For n=1 To count surf=GetSurface(entity,n) Vcount=CountVertices(surf)-1 For v=0 To Vcount VertexColor surf,v,r,g,b Next Next End Function
Под водой, над водой, смотриТСО симпатично, но это вам не шейдерный мир :).
Код:; Plasmabased Water with Seaground-Projection ; by CSP 2002 ; Graphics3D 1024,768,16,1 SetBuffer BackBuffer() AmbientLight 90,90,100 ; Camera camera=CreateCamera() CameraRange camera,0.1,17000 CameraFogMode camera,1 CameraFogRange camera,400,2500 CameraFogColor camera,150,170,200 CameraClsMode camera,1,1 CameraClsColor camera,150,170,200 light=CreateLight() RotateEntity light,0,0,45 PositionEntity light,40,300,45 ; init Cam Position Kx#=3528.0 Ky#=-120.0 Kz#=6069.0 PositionEntity camera,Kx#,Ky#,Kz# myangel#=110;70 RotateEntity camera,0,myangel,0 EntityType camera,TYPE_PLAYER EntityRadius camera,3.4;3.4 ; seafloor terrain If FileType("seahmap1.bmp")=1 ; if File exist then ground=LoadTerrain("seahmap1.bmp") ; use this 128*128 heightmap !!! Else ground=CreateTerrain(128) ; else create one on the fly For i=0 To 127 For j=0 To 127 If (i And $f)=8 ModifyTerrain ground,(i),(j),Rnd(0.7,0.9) Else ModifyTerrain ground,(i),(j),Rnd(0.2) EndIf Next Next EndIf ; terrain noise For i=0 To 127 For j=0 To 127 tlo#=(TerrainHeight(ground,i,j)+Rnd(-0.1,0.1))/2 If tlo#<0 Then tlo#=0 If tlo#>0.62 Then tlo#=0.65 ModifyTerrain ground,(i),(j),tlo# Next Next ; terrain border h059#=0.65 For i=0 To 128 ModifyTerrain ground,i,0,h059# ModifyTerrain ground,i,127,h059# ModifyTerrain ground,0,i,h059# ModifyTerrain ground,127,i,h059# Next TerrainShading ground,1 ScaleEntity ground,125,1000,125 PositionEntity ground,-8000,0,-6000 TranslateEntity ground,0,-650,0 ; init Water etc. Dim cosinus(640) position = 0 For c = 0 To 640 cosinus(c) = Cos((115*3.14159265358 * c) / 320) * 32 + 32 Next Dim div10(320) For i=0 To 320 div10(i)=i/10 Next Dim f3(255),f45(255),f5(255) For i=0 To 255 f3(i)=3*i f45(i)=4.5*i f5(i)=5*i Next mywater=CreateTexture(32,32,9) ; used 4 texture on water mywater2=CreateTexture(32,32,9) ; used 4 watershade blend on ground Gosub water water=CreateTerrain(1) ScaleTexture mywater,0.01,0.01 ScaleTexture mywater2,2,2 EntityTexture water, mywater,0 ScaleEntity water,500*32,500*32,500*32 PositionEntity water,-8000,0,-6000 EntityAlpha water,0.6 EntityFX water,17 ; init sky sky=CreateSphere() FlipMesh sky If FileType("sky.bmp")=1 Then sky_tex=LoadTexture("sky.bmp"); use a seamless sky-texture Else sky_tex=CreateTexture(256,256) SetBuffer TextureBuffer(sky_tex) Color 100,175,255 Rect 0,0,640,480,1 SetBuffer BackBuffer() EndIf EntityTexture sky,sky_tex ScaleTexture sky_tex,0.2,0.2 ScaleEntity sky,6000,12000,6000 EntityFX sky,9 EntityOrder sky,1 PositionEntity sky,Kx#,Ky#,Kz# ; cube around camera for additional 'fog' trueb=CreateCube() FlipMesh trueb ScaleEntity trueb,10,10,10 EntityTexture trueb,mywater2 EntityAlpha trueb,0.6 EntityFX trueb,1 ; blended Ground-Texture If FileType("rockground.jpg")=1 groundtex=LoadTexture("rockground.jpg") ; use a 512*512 Texture (alter Scaling if smaller) Else groundtex=CreateTexture(512,512) SetBuffer TextureBuffer(groundtex) Color 255,220,100 Rect 0,0,512,512,1 For i=0 To 1000 patt=Rand(80,255) Color patt,patt*0.6,patt*0.3 Line Rand(512),Rand(512),Rand(512),Rand(512) Next SetBuffer BackBuffer() EndIf ScaleTexture groundtex,10,10 ; relatice to Texture-Size TextureBlend groundtex,3 EntityTexture ground,groundtex,0,0 EntityTexture ground,mywater2,0,1 ; projecting waves onto Floor ; init fps-counter tt=MilliSecs() tt2=tt-50 HidePointer ; ______________________________________MAINLOOP_____________________________________ While KeyDown(1)=0 Gosub water ; update waves ; Cam Nav my=MouseYSpeed()*5 If KeyDown(200)=1 If speed#<50 speed#=speed#+2 EndIf EndIf If speed#>0 speed#=speed#-1 If speed#<0 speed#=0 EndIf EndIf Kx#=kx#-Cos(myangel#-90)*speed# Kz#=kz#-Sin(myangel#-90)*speed# camy#=camy#-my If camy#>70 Then camy#=70 If camy#<-500 Then camy#=-500 terry#=TerrainY(ground,kx#,0,kz#)+20 If camy#<terry# Then camy#=terry# PositionEntity camera,Kx#,camy#,Kz# moro#=MouseXSpeed() myangel2#=myangel2#-moro# If myangel2#<>myangel# myangel#=myangel#+((myangel2#-myangel#)/5) EndIf RotateEntity camera,0,myangel#,0 trueby#=camy# If trueby#>-10 Then trueby#=-10 PositionEntity trueb,Kx#,trueby#,Kz# RotateEntity trueb,0,myangel#,0 PositionEntity sky,Kx#,0,Kz# MoveMouse 320,240 UpdateWorld() RenderWorld() tt=MilliSecs() fps=1000.0/(tt-tt2) tt2=tt Text 0,0,fps Flip Wend ; ------------------------------------- eo mainloop ------------------------------------- End .water wave1% = wave1% + 4 wave2% = wave2% + 2 ; use this if the waves are moving to fast: ; wave1% = wave1% + 2 ; wave2% = wave2% + 1 If wave1% >= 320 Then wave1% = 0 If wave2% >= 320 Then wave2% = 0 SetBuffer TextureBuffer(mywater) LockBuffer For y% = 0 To 319 Step 10 y10=div10(y) d = cosinus(y + wave2) + cosinus(Y + wave2) For x% = 0 To 319 Step 10 x10=div10(x) f = 1 + Abs(((cosinus(x + wave1) + cosinus(x + y) + d) / 8) - 16) rr=105-f3(f) If rr<0 Then rr=0 gg=185-f45(f) If gg<0 Then gg=0 bb=195-f5(f) If bb<0 Then bb=0 WritePixelFast x10,y10,((rr Shl 16) Or (gg Shl 8) Or bb) Next Next UnlockBuffer CopyRect 0,0,32,32,0,0, TextureBuffer(mywater), TextureBuffer(mywater2) SetBuffer BackBuffer() Return
Последний раз редактировалось rapt0r; 06.07.2006 в 22:01.
Люди не поможите с блюр ефектом. Нужно менять разрешение экрана 1280 на 1024 много раз пытались и не получаеться!:_sad:
;Размер текстуры, номер эффекта, порядок прорисовки (-1 или 1)
Const texsize=1024,fx=7,o=-1
Graphics3D 800,600,32
cam=CreateCamera()
PositionEntity cam,0,0,-6
RotateEntity CreateLight(),45,0,0
;Создание сцены
cube=CreateCube()
EntityColor cube,255,128,0
cone1=CreateCone(20)
EntityColor cone1,0,255,255
PositionEntity cone1,-4,0,0
cone2=CreateCone(20)
EntityColor cone2,0,255,0
PositionEntity cone2,4,0,0
p=CreatePivot()
sph=CreateSphere(20,p)
PositionEntity sph,0,0,-4
Select fx
Case 1:bl=createblurlayer(cam,1,0,1,1,.95,1,o)
Case 2:bl=createblurlayer(cam,1,0,1,.97,1,3,o)
Case 3:bl=createblurlayer(cam,1,.2,1.02,.97,1,3,o)
Case 4:bl=createblurlayer(cam,1,0,1.01,1,.95,1,o)
Case 5
bl=createblurlayer(cam,1,0,1.01,1,.9,1,o)
EntityColor bl,240,255,225
Case 6
bl=createblurlayer(cam,1.1,0,1,1,.95,1,o)
RotateEntity bl,1,1,0
Case 7
bl=createblurlayer(cam,1.01,1,1,1,.9,1,o)
bl2=createblurlayer(cam,1.02,-1,1,1,.8,1,o)
End Select
SetBuffer BackBuffer()
While Not KeyHit(1)
TurnEntity cube,.1,.2,.3
TurnEntity p,.55,.35,.2
RenderWorld
bltex=updateblurlayer(bl,bltex)
If bl2 Then EntityTexture bl2,bltex
If fx=4 Then PositionEntity bl,Rnd(-.01,.01),Rnd(-.01,.01),1
Flip
Wend
;Функция создания слоя размытия, привязанного к камере - возвращает адрес слоя
Function createblurlayer(cam,z#,ang#,mgn#,bright#,alpha#,bm ode,ord)
Local xres=GraphicsWidth()
Local yres=GraphicsHeight()
layer=CreateMesh(cam)
s=CreateSurface(layer)
;Вычисление координат текстуры
vx#=1.0*xres/texsize
vy#=1.0*yres/texsize
AddVertex s,-1,-1,0,0,0
AddVertex s,1,-1,0,vx#,0
AddVertex s,-1,1,0,0,vy#
AddVertex s,1,1,0,vx#,vy#
AddTriangle s,0,1,2
AddTriangle s,3,2,1
;Определение величин для установки прямоугольника прямо перед камерой путем
; вычисления экранных координат точки трехмерного мира
PositionEntity layer,1,1,z#
CameraProject cam,EntityX(layer,True),EntityY(layer,True),Entity Z(layer,True)
rx#=ProjectedX#()-.5*xres
ry#=ProjectedY#()-.5*yres
;Масштабирование слоя
ScaleMesh layer,.5*xres/rx#,.5*yres/ry#,1
;Сдлвиг прямоугольника на полпиксела влево-вверх, чтобы он был в центре экрана
PositionEntity layer,-.5/rx#,-.5/ry#,z#
RotateEntity layer,0,0,ang#
;Задание эффектов слоя
ScaleEntity layer,mgn#,mgn#,mgn#
EntityAlpha layer,alpha#
EntityBlend layer,bmode
col=255*bright#
EntityColor layer,col,col,col
EntityFX layer,1
EntityOrder layer,ord
Return layer
End Function
;Функция обновления слоя (возвращает адрес текстуры)
;Нужно вызывать каждый раз после RenderWorld
Function updateblurlayer(layer,tex)
If tex=0 Then tex=CreateTexture(texsize,texsize)
EntityTexture layer,tex
CopyRect 0,0,GraphicsWidth(),GraphicsHeight(),0,0,BackBuffe r(),TextureBuffer(tex)
Return tex
End Function
Blitz3D достаточно старый 3Д движок, держит Directx 7 !!
но он очень легкий в освоении, по этому если не знаешь с чего начать начинай именно с него !!
БлицМакс - это движе более ориентирован на 2Д, но он очень гибкий и многофункциональнай по сравнению с Блиц3Д, so... немного сложнее в освоении !! к нему можно подключать разные 3Д двиги и писать 3хмерные игры используя директИкс9, шейдеры и все остальное !!
БлицПлюс по моему личному мнению проигрывает !! :)
Ну у Dark Basic Pro конечно есть свои плюсы.Один из них Dx9.Но это не делает его намного лучшим за Blitz3d.О скорости отрисовки сцены точно незнаю,но походу она уступает Blitz.А вообще если сумееш розгребсти тот затянутый синтакс темного барсика-то он вполне даже ничегодля начала ИМХО.
Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)
Социальные закладки