Post by DJLinux on Sept 3, 2010 10:56:44 GMT -5
After i lost some good looking textures i found these panoramic 360° sky textures
www.cgtextures.com/textures.php?t=browse&q=23740
My first test:
www.cgtextures.com/textures.php?t=browse&q=23740
My first test:
const FILE$ = "FullskiesBlueClear0006_1_S.jpg"
type VERTEX
x as single
y as single
z as single
u as single
v as single
end type
function CreateSky360()
dim v(11,11) as VERTEX
dim x#,y#,z#,r#,u#,v#,i#,j#,vi,vj
v#=1
for i#=90 to 0 step -9
r#=cosd(i#)
y#=sind(i#)
vj=0:u#=1
for j#=0 to 360 step 36
x#=cosd(j#)*r#
z#=sind(j#)*r#
v(vi,vj).x=x#
v(vi,vj).y=y#
v(vi,vj).z=z#
v(vi,vj).u=u#
v(vi,vj).v=v#
u#=u#-0.1
vj=vj+1
next
v#=v#-0.1
vi=vi+1
next
dim ret = glGenLists(1)
glNewList(ret,GL_COMPILE)
glBegin(GL_QUADS)
for vi=0 to 10
for vj=0 to 10
glTexCoord2f(v(vi,vj).u,v(vi,vj).v)
glVertex3f (v(vi,vj).x,v(vi,vj).y,v(vi,vj).z)
glTexCoord2f(v(vi,vj+1).u,v(vi,vj+1).v)
glVertex3f (v(vi,vj+1).x,v(vi,vj+1).y,v(vi,vj+1).z)
glTexCoord2f(v(vi+1,vj+1).u,v(vi+1,vj+1).v)
glVertex3f (v(vi+1,vj+1).x,v(vi+1,vj+1).y,v(vi+1,vj+1).z)
glTexCoord2f(v(vi+1,vj).u, v(vi+1,vj).v)
glVertex3f (v(vi+1,vj).x, v(vi+1,vj).y, v(vi+1,vj).z)
next
next
glEnd()
glEndList()
return ret
end function
sub DrawSky360(xrot#,yrot#,zrot#,scale#,Tex,List)
glDisable(GL_DEPTH)
glDisable(GL_LIGHTING)
'glColor4f(1,1,1,1)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D,Tex)
glScalef(scale#,scale#,scale#)
glRotatef(xrot#,1,0,0)
glRotatef(yrot#,0,1,0)
glRotatef(zrot#,0,0,1)
glCallList(List)
glEnable(GL_DEPTH)
glEnable(GL_LIGHTING)
end sub
dim TextID = LoadTex(FILE$)
dim ListID = CreateSky360()
dim x#,y#,w#
while TRUE
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
DrawSky360(x#,y#,0, 5,TextID,ListID)
' here draw the rest of your scene
' ...
SwapBuffers()
WaitTimer(1000/50)
x#=-15+sin(w#)*15
y#=y#+0.5
w#=w#+0.01
wend