To try it out, do the following:
removed:use your own images...
Save this code at the same location as the two folders above.
Code: Select all
InitEngine3D()
InitMouse()
InitKeyboard()
InitSprite()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
Add3DArchive("textures",#PB_3DArchive_FileSystem)
Add3DArchive("flares",#PB_3DArchive_FileSystem)
DeclareModule _3D_Test
Structure Mesh_Data
ent.i
mesh.i
tex.i
mat.i
EndStructure
Structure Particle_Data
id.i
mat.i
tex.i
EndStructure
Global Win.i, DefaultCam.i
;Global NewSun.Mesh_Data
Global NewList par.Particle_Data()
Global Hud.i
Declare SetUpScreen()
Declare CreateNewParticles()
Declare ConstructSkyboxTexture(SaveFullName.s, PicSize.i = 1024)
Declare.i PlotStar(Img.i)
Declare Do_Mouse()
Declare ConstructHud()
EndDeclareModule
Module _3D_Test
Procedure SetUpScreen()
ExamineDesktops()
Win = OpenWindow(#PB_Any, 0, 0, DesktopWidth(0), DesktopHeight(0), "Hyperspace", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(Win), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0,#PB_Screen_SmartSynchronization)
DefaultCam = CreateCamera(#PB_Any,0,0,100,100)
MoveCamera(DefaultCam,0,0,200)
EndProcedure
Procedure CreateNewParticles()
num = 1
For x = 0 To 1
AddElement(par())
par()\id = CreateParticleEmitter(#PB_Any,2000,2000,3000,#PB_Particle_Point)
par()\tex = LoadTexture(#PB_Any,Str(num+x) + ".png")
par()\mat = CreateMaterial(#PB_Any,TextureID(par()\tex))
RotateMaterial(par()\mat,270,#PB_Absolute)
DisableMaterialLighting(par()\mat, 1)
MaterialBlendingMode(par()\mat, #PB_Material_Add)
MoveParticleEmitter(par()\id, 0,0.0,#PB_Absolute)
ParticleMaterial(par()\id, MaterialID(par()\mat))
ParticleEmissionRate(par()\id,500)
ParticleTimeToLive(par()\id,6.2,7.8)
ParticleSize(par()\id,20,20)
ParticleVelocity(par()\id,0.5,1.0)
ParticleEmitterDirection(par()\id, 0 , 0 , 1)
Next
EndProcedure
Procedure ConstructSkyboxTexture(SaveFullName.s, PicSize.i = 1024)
Protected Img.i
img = CreateImage(#PB_Any,PicSize,PicSize,32,0)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_FR.jpg",#PB_ImagePlugin_JPEG,8)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_BK.jpg",#PB_ImagePlugin_JPEG,8)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_UP.jpg",#PB_ImagePlugin_JPEG,8)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_DN.jpg",#PB_ImagePlugin_JPEG,8)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_LF.jpg",#PB_ImagePlugin_JPEG,8)
Img = PlotStar(Img)
SaveImage(Img,SaveFullName + "_RT.jpg",#PB_ImagePlugin_JPEG,8)
FreeImage(Img)
EndProcedure
Procedure PlotStar(Img.i)
Protected cloud.i
Select Random(400,1)
Case 1 To 100
cloud = LoadImage(#PB_Any,"textures\neb1.png")
Case 101 To 200
cloud = LoadImage(#PB_Any,"textures\neb2.png")
Case 201 To 300
cloud = LoadImage(#PB_Any,"textures\neb3.png")
Default ;No cloud
EndSelect
StartDrawing(ImageOutput(Img))
DrawingMode(#PB_2DDrawing_Default)
Box(0,0,ImageWidth(Img),ImageHeight(Img),0)
For x = 0 To 350
col = Random(200,80)
Plot(Random(ImageWidth(Img)-10,6),Random(ImageHeight(Img)-10,6),RGBA(col,col,col,Random(255,80)))
Next x
If IsImage(cloud)
DrawingMode(#PB_2DDrawing_AlphaClip)
For x = 0 To Random(3,1)
DrawAlphaImage(ImageID(cloud),Random(ImageWidth(Img)-256,0),Random(ImageHeight(Img)-256,0),Random(50,10))
Next x
FreeImage(cloud)
EndIf
StopDrawing()
ProcedureReturn Img
EndProcedure
Procedure ConstructHud()
Protected x2.i, x3.i, y2, y3,w.i,h.i
w = ScreenWidth():h = ScreenHeight()
hud = CreateSprite(#PB_Any, w, h, #PB_Sprite_AlphaBlending)
x2 = SpriteWidth(Hud) / 4
x3 = x2 * 3
y2 = SpriteHeight(Hud)/4
y3 = y2 * 3
StartDrawing(SpriteOutput(Hud))
LineXY(0, 0, x2, y2, $ffff40)
LineXY(x2, y2, x3, y2, $ffff40)
LineXY(x3, y2, w, 0, $ffff40)
LineXY(0, h, x2, y3, $ffff40)
LineXY(x2, y3, x3, y3, $ffff40)
LineXY(x3, y3, w, h, $ffff40)
LineXY(w/2, (h/2)-50, w/2, (h/2)-25, $ffff40)
LineXY(w/2, (h/2)+50, w/2, (h/2)+25, $ffff40)
LineXY((w/2)-50, h/2, (w/2)-25, h/2, $ffff40)
LineXY((w/2)+50, h/2, (w/2)+25, h/2, $ffff40)
StopDrawing()
TransparentSpriteColor(Hud,0)
EndProcedure
Procedure Do_Mouse()
ExamineMouse()
mx = -MouseDeltaX() * 0.05
my = -MouseDeltaY() * 0.05
RotateCamera(DefaultCam,my,mx,0,#PB_Relative)
EndProcedure
EndModule
_3D_Test::ConstructSkyboxTexture("textures\Stars",1024)
_3D_Test::SetUpScreen()
_3D_Test::ConstructHud()
_3D_Test::CreateNewParticles()
SkyBox("stars.jpg")
Repeat
ev = WindowEvent()
_3D_Test::Do_Mouse()
ExamineKeyboard()
elapsed = RenderWorld()
DisplayTransparentSprite(_3D_Test::Hud,0,0)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or ev = #PB_Event_CloseWindow
Peter
