Post by shadow008 on Aug 19, 2009 18:25:18 GMT -5
i would have posted this about 5 days ago but my flash drive crashed my moms comp and it had to be brought in...
anyways, ive been working on a modeler (cause i gave up on blender) and heres what ive came up with. you might wanna look over what the buttons do first, and this is NOT user friendly (sorry ).
and a loader, which runs faster than the modeler and im hoping to add collsion detection
?... if anyone wants to help me with lighting, that would be appreciated, i dont understand it really at all. well anyways, have fun coding -.-.
-shadow008
well?...
ill take my big fat goverment check and 100 acre shore line mansion resort now.
...
or maybe just a thumbs up? ;D
check the dates when this post was modded ive decided instead of posting the entire code every time i make some changes, ill just mod this post. - aug 20
anyways, ive been working on a modeler (cause i gave up on blender) and heres what ive came up with. you might wanna look over what the buttons do first, and this is NOT user friendly (sorry ).
dim camx#,camy#,camz#,camang#(1),x,y,select,x1,y1,texture,viewtype,i,n,filelen,load$
dim lightambient#(3),lightdiffuse#(3),lightposition#(3),option(6),savefile,filename$
dim loadfile$,loadfile,texture$
for i = 1 to 6
option(i) = false
next
lightambient# = vec4 (.7,.7,.7,1)
lightdiffuse# = vec4 (1,1,1,1)
lightposition# = vec4 (-200,-30,0,0)
viewtype = gl_triangles
x1 = 1
y1 = 1
select = false
struc sobj
dim h#(36)(36)
endstruc
dim sobj obj
camX# = -33
camZ# = 10
camy# = -2
camang#(1) = 90
textmode(text_buffered)
textureload:
clearkeys()
cls
printr "enter texture to use:"
input ":";texture$
texture = loadtex("textures/"+texture$)
if FileError () <> "" then
printr "wrong file name"
drawtext()
sleep (600)
goto textureload
else option(0) = false:cls:select = false:endif
textmode(text_overlaid)
glenable(gl_depth_test)
glenable(gl_cull_face)
gldisable(gl_lighting)
'glEnable (GL_BLEND)
'glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
gllightfv(gl_light0, gl_ambient, lightambient#)
gllightfv(gl_light0, gl_diffuse, lightdiffuse#)
gllightfv(gl_light0, gl_position,lightposition#(0))
glenable(gl_light0)
sub terrain()
glenable(gl_texture_2d)
glpushmatrix ()
glscalef(5,1,5)
glbindtexture(gl_texture_2d,texture)
glBegin (viewtype)
for x = 1 to 35
for y = 1 to 35
glcolor4f(1,1,1,1)
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
y = y + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x - 1:y = y - 1
next
next
glEnd ()
glcullface(gl_back)
glBegin (viewtype)
for x = 1 to 35
for y = 1 to 35
glcolor4f(1,1,1,1)
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
y = y + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x - 1:y = y - 1
next
next
glEnd ()
glcullface(gl_front)
glpopmatrix()
endsub
start:
while true
cls
glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT)
glLoadIdentity ()
glRotatef ( camang#(0), 1, 0, 0)
glRotatef (-camAng#(1), 0, 1, 0)
glTranslatef (camX#, camY#, -camZ#)
glscalef (1,1,1)
terrain()
if select then
printr "selecting: true"
elseif not select then
printr "selecting: false"
endif
printr "x = ";x1
printr "y = ";y1
printr "camx :";camx#
printr "camy :";camy#
printr "camz :";camz#
printr "press o for options"
drawtext()
SwapBuffers ()
while SyncTimer (10)
gosub controls
wend
wend
controls:
camAng#(0) = camAng#(0) + mouse_yd() * 30
if not select then camAng#(1) = camAng#(1) - mouse_xd() * 30:endif
if camAng#(0) < -90 then camAng#(0) = -90:endif
if camAng#(0) > 90 then camAng#(0) = 90:endif
if camAng#(1) > 360 then camAng#(1) = 0:endif
if camAng#(1) < 0 then camAng#(1) = 360:endif
if keydown ("A") and not select then camAng#(1) = camAng#(1) + 1: endif
if keydown ("D") and not select then camAng#(1) = camAng#(1) - 1: endif
if keydown ("W") and not option(3) then
camX# = camX# + sind (camAng#(1)) * .2
camZ# = camZ# - cosd (camAng#(1)) * .2
camY# = camY# + sind (camAng#(0)) * .2
elseif keydown ("W") and option(3) then
camy# = -2
camX# = camX# + sind (camAng#(1)) * .2
camZ# = camZ# - cosd (camAng#(1)) * .2
endif
if keydown ("S") and not option(3) and not option(0) then
camX# = camX# - sind (camAng#(1)) * .2
camZ# = camZ# + cosd (camAng#(1)) * .2
camY# = camY# - sind (camAng#(0)) * .2
elseif keydown ("S") and option(3) and not option(0) then
camy# = -2
camX# = camX# - sind (camAng#(1)) * .2
camZ# = camZ# + cosd (camAng#(1)) * .2
endif
if keydown ("O") then
option(0) = true
gosub options
textmode(text_overlaid)
endif
if scankeydown (vk_return) and not option(0) then
if select = true then select = false:sleep(100)
elseif select = false then select = true :sleep(100):endif
endif
if scankeydown(vk_left) then x1 = x1 + 1 :sleep(150):endif
if scankeydown(vk_right) then x1 = x1 - 1 :sleep(150):endif
if scankeydown(vk_up) then
if not select then
y1 = y1 + 1:sleep(150)
elseif select then
obj.h# (y1)(x1) = obj.h# (y1)(x1) + .25
endif
endif
if scankeydown(vk_down) then
if not select then
y1 = y1 - 1:sleep(150)
elseif select then
obj.h# (y1)(x1) = obj.h# (y1)(x1) - .25
endif
endif
if scankeydown(vk_prior) then
if select then
y1 = y1 + 1:sleep(150)
endif
endif
if scankeydown(vk_next) then
if select then
y1 = y1 - 1:sleep(150)
endif
endif
if scankeydown(vk_space) then
camx# = y1 * 5 * -1 - 10
camy# = -2
camz# = (x1 - 1) * 5 + 5
camang#(1) = 90
camang#(0) = 0
endif
if x1 < 1 then x1 = 36:endif
if x1 > 36 then x1 = 1:endif
if y1 < 1 then y1 = 1:endif
if y1 > 36 then y1 = 36:endif
return
'''''''''''''''--''|--''-----'---''--''|\'''|''sss'''''''''
''''''''''''''/ \'| |'''|''''|''/ \'|'\''|'s''''''''''''
''''''''''''''\ /'|--''''|''''|''\ /'|''\'|''ss''''''''''
'''''''''''''''--''|''''''|'''---''--''|'''\|''''s'''''''''
options: 'sss''''''''''
textmode(text_buffered)
glclear(gl_depth_buffer_bit or gl_color_buffer_bit)
cls
do
cls
printr "options:"
locate 1,2
if not option(1) then
printr "cull face(c): enabled"
glenable(gl_cull_face)
elseif option(1) then
printr "cull face(c): disabled"
gldisable(gl_cull_face)
endif
locate 1,4
if not option(2) then
printr "view type(v): solid"
viewtype = gl_triangles
elseif option(2) then
printr "view type(v): wire frame"
viewtype = gl_line_strip
endif
locate 1,6
if not option(3) then
printr "movement(m): free"
elseif option(3) then
printr "movement(m): fixed"
endif
locate 1,8
if not option(4) then
printr "lighting(i): disabled"
gldisable(gl_lighting)
elseif option(4) then
printr "lighting(i): enabled"
glenable(gl_lighting)
endif
locate 9,12
printr "press s to save"
locate 9,16
printr "press l to load a file"
if option(5) then
locate 9,13
printr "saving..."
sleep(150)
locate 19,13
printr "done"
endif
if option(6) then
locate 9,18
printr "loaded"
endif
locate 24,1
printr "files found:"
load$ = findfirstfile ("*.map")
if load$ = "" then
locate 24,2
printr "none"
endif
n = 3
while load$ <> ""
locate 24,n
printr load$
load$ = findnextfile ()
n = n + 1
wend
findclose()
locate 6,22
printr "press t to reload texture"
locate 6,23
printr "press backspace to return"
drawtext()
if keydown("C") then
if not option(1) then option(1) = true :sleep (100)
elseif option(1) then option(1) = false:sleep (100)
endif
endif
if keydown("V") then
if not option(2) then option(2) = true :sleep (100)
elseif option(2) then option(2) = false:sleep (100)
endif
endif
if keydown("M") then
if not option(3) then option(3) = true :sleep (100)
elseif option(3) then option(3) = false:sleep (100)
endif
endif
if keydown("I") then
if not option(4) then option(4) = true :sleep (100)
elseif option(4) then option(4) = false:sleep (100)
endif
endif
if keydown ("T") then goto textureload:endif
'save
if keydown("S") then
option(5) = false
clearkeys()
locate 9,14
input "save file as: ";filename$
option(5) = true
savefile = openfilewrite(filename$+".map")
writeline (savefile,"textures/"+texture$)
for x = 1 to 35
for y = 1 to 35
writeline (savefile,obj.h#(x)(y))
next
next
endif
'load
if keydown("L") then
option(6) = false
clearkeys()
locate 9,17
printr "enter file name to load:"
locate 9,18
input "file name: ";loadfile$
option(6) = true
filelen = len(loadfile$) - 3
if mid$(loadfile$,filelen,4) <> ".map" then
loadfile = openfileread (loadfile$+".map")
elseif mid$(loadfile$,filelen,4) = ".map" then
loadfile = openfileread (loadfile$)
endif
if FileError () <> "" then
locate 9,19
printr "file not found"
drawtext()
sleep(1000)
option(6) = false
endif
if option(6) then
texture$ = readtext(loadfile,true)
for x = 1 to 35
for y = 1 to 35
obj.h#(x)(y) = val(readtext(loadfile,true))
next
next
texture = loadtex (texture$)
endif
endif
if scankeydown(vk_back) then option(0)=false:option(5)=false:option(6)=false:endif
loop until scankeydown (vk_back)
return
and a loader, which runs faster than the modeler and im hoping to add collsion detection
dim campos#(2),camang#(1),x,y,texture,texture$
dim loadfile$,loadfile,list,files$,filelength
struc sobj
dim h#(36)(36)
endstruc
dim sobj obj
'load file
textmode(text_buffered)
load:
clearkeys()
cls
printr "files found:"
files$ = findfirstfile ("*.map")
if files$ = "" then
printr "none"
drawtext()
end
endif
while files$ <> ""
printr files$
files$ = findnextfile()
wend
printr ""
printr "load which file?"
input ":";loadfile$
drawtext()
filelength = len (loadfile$) - 3
if mid$(loadfile$,filelength,4) <> ".map" then
loadfile = openfileread (loadfile$+".map")
elseif mid$(loadfile$,filelength,4) = ".map" then
loadfile = openfileread (loadfile$)
endif
if FileError () <> "" then
printr "file not found"
drawtext()
sleep (600)
goto load
else
texture$ = readtext (loadfile,true)
for x = 1 to 35
for y = 1 to 35
obj.h#(x)(y) = val(readtext(loadfile,true))
next
next
texture = loadmipmaptexture(texture$)
printr "loaded"
drawtext()
sleep (500)
cls
findclose()
endif
textmode (text_overlaid)
'end load
campos#(0) = -33
campos#(2) = 10
campos#(1) = -2
camang#(1) = 90
glenable(gl_depth_test)
glenable(gl_cull_face)
list = glgenlists(1)
glnewlist(list,gl_compile)
glenable(gl_texture_2d)
glpushmatrix ()
glscalef(5,1,5)
glbindtexture(gl_texture_2d,texture)
glBegin (gl_triangles)
for x = 1 to 35
for y = 1 to 35
glcolor4f(1,1,1,1)
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
y = y + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x - 1:y = y - 1
next
next
glEnd ()
glcullface(gl_back)
glBegin (gl_triangles)
for x = 1 to 35
for y = 1 to 35
glcolor4f(1,1,1,1)
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
y = y + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x + 1
glnormal3f(x,obj.h#(x)(y),y)
gltexcoord2f (y*.999/36,x*.999/36)
glvertex3f(x,obj.h#(x)(y),y)
x = x - 1:y = y - 1
next
next
glEnd ()
glcullface(gl_front)
glpopmatrix()
glendlist()
while true
glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT)
glLoadIdentity ()
glRotatef ( camang#(0), 1, 0, 0)
glRotatef (-camAng#(1), 0, 1, 0)
glTranslatef (campos#(0), campos#(1), -campos#(2))
glscalef (1,1,1)
glcalllist(list)
SwapBuffers ()
while SyncTimer (10)
gosub controls
wend
wend
controls:
camAng#(0) = camAng#(0) + mouse_yd() * 30
camAng#(1) = camAng#(1) - mouse_xd() * 30
if camAng#(0) < -90 then camAng#(0) = -90:endif
if camAng#(0) > 90 then camAng#(0) = 90:endif
if camAng#(1) > 360 then camAng#(1) = 0:endif
if camAng#(1) < 0 then camAng#(1) = 360:endif
if keydown ("A") then camAng#(1) = camAng#(1) + 1:endif
if keydown ("D") then camAng#(1) = camAng#(1) - 1:endif
if keydown ("W") then
campos#(0) = campos#(0) + sind (camAng#(1)) * .1
campos#(2) = campos#(2) - cosd (camAng#(1)) * .1
endif
if keydown ("S") then
campos#(0) = campos#(0) - sind (camAng#(1)) * .1
campos#(2) = campos#(2) + cosd (camAng#(1)) * .1
endif
return
?... if anyone wants to help me with lighting, that would be appreciated, i dont understand it really at all. well anyways, have fun coding -.-.
-shadow008
well?...
ill take my big fat goverment check and 100 acre shore line mansion resort now.
...
or maybe just a thumbs up? ;D
check the dates when this post was modded ive decided instead of posting the entire code every time i make some changes, ill just mod this post. - aug 20