Ooops
October 28, 2021, 13:12:32

Author Topic: [bb] SkyPanorama loading code by John Blackledge [ 1+ years ago ]  (Read 978 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : SkyPanorama loading code
Author : John Blackledge
Posted : 1+ years ago

Description : I've adapted Mark's skybox code to load the output from Fredborg's SkyPanorama. <a href="http://www.frecle.net/cloud/skypanorama.zip" target="_blank">http://www.frecle.net/cloud/skypanorama.zip[/url]
Please note that LoadAnimTexture needs the clamp_u and clanp_v flags setting otherwise the 'join' line shows.


Code :
Code: BlitzBasic
  1. ;------------------
  2. Function LoadSkyStrip(file$)
  3. ;------------------
  4.         tex = LoadAnimTexture(file$,1+8+16+32,512,512,0,6)
  5.         hEntSkyBox=CreateMesh()
  6.         b = CreateBrush()
  7.         BrushTexture b,tex,0
  8.  
  9.         ;back face
  10.         b = CreateBrush()
  11.         BrushTexture b,tex,0
  12.         s=CreateSurface(hEntSkyBox,b )
  13.         AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
  14.         AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
  15.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  16.         FreeBrush b
  17.         ;left face
  18.         b = CreateBrush()
  19.         BrushTexture b,tex,1
  20.         s=CreateSurface(hEntSkyBox,b )
  21.         AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
  22.         AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
  23.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  24.         FreeBrush b
  25.         ;front face
  26.         b = CreateBrush()
  27.         BrushTexture b,tex,2
  28.         s=CreateSurface(hEntSkyBox,b )
  29.         AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
  30.         AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
  31.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  32.         FreeBrush b
  33.         ;right face
  34.         b = CreateBrush()
  35.         BrushTexture b,tex,3
  36.         s=CreateSurface(hEntSkyBox,b )
  37.         AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
  38.         AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
  39.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  40.         FreeBrush b
  41.  
  42.         ;top face
  43.         b = CreateBrush()
  44.         BrushTexture b,tex,4
  45.         s=CreateSurface(hEntSkyBox,b )
  46.         AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
  47.         AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
  48.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  49.         FreeBrush b
  50.         ;bottom face   
  51.         b = CreateBrush()
  52.         BrushTexture b,tex,5
  53.         s=CreateSurface(hEntSkyBox,b )
  54.         AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
  55.         AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
  56.         AddTriangle s,0,1,2:AddTriangle s,0,2,3
  57.         FreeBrush b
  58.        
  59.         ScaleMesh hEntSkyBox,3000,3000,3000
  60.         FlipMesh hEntSkyBox
  61.         EntityFX hEntSkyBox,1+8
  62.        
  63.         Return hEntSkyBox
  64. End Function


Comments :


Chroma(Posted 1+ years ago)

 Nice!  And here's a little Viewer app so you can drag and drop the SkyPanorama files onto the .exe for quick viewing.
Code: [Select]
;SkyPanorama Tester - Drag and Drop

Graphics3D 1680,1050,32,2

light = CreateLight()

camera = CreateCamera()
CameraRange camera,1,6000

box = CreateCube()
PositionEntity box,0,0,10


a$=CommandLine$()

sky = LoadSkyStrip(a)
PositionEntity sky,0,0,0

While Not KeyHit(1)
Cls

RotateEntity camera,EntityPitch(camera),EntityYaw(camera),0
TurnEntity camera,MouseYSpeed()*.3,-MouseXSpeed()*.3,0

MoveMouse 500,500

UpdateWorld
RenderWorld

Text 10,10,a

Flip
Wend
End

;------------------
Function LoadSkyStrip(file$)
;------------------
tex = LoadAnimTexture(file$,1+8+16+32,512,512,0,6)
hEntSkyBox=CreateMesh()
b = CreateBrush()
BrushTexture b,tex,0

;back face
b = CreateBrush()
BrushTexture b,tex,0
s=CreateSurface(hEntSkyBox,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 = CreateBrush()
BrushTexture b,tex,1
s=CreateSurface(hEntSkyBox,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
;front face
b = CreateBrush()
BrushTexture b,tex,2
s=CreateSurface(hEntSkyBox,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 = CreateBrush()
BrushTexture b,tex,3
s=CreateSurface(hEntSkyBox,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 = CreateBrush()
BrushTexture b,tex,4
s=CreateSurface(hEntSkyBox,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 = CreateBrush()
BrushTexture b,tex,5
s=CreateSurface(hEntSkyBox,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 hEntSkyBox,3000,3000,3000
FlipMesh hEntSkyBox
EntityFX hEntSkyBox,1+8

Return hEntSkyBox
End Function






Chroma(Posted 1+ years ago)

 Btw, I wish Fredborg would update this.  I know he's busy but it's a great app. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal