https://transfert.free.fr/CN2ASdD
Code: Select all
'-------------------------------------------------------------------------------
' compiler path : C:\FreeBasic\fbc64.exe
' compiler command : "<$fbc>" "<$file>"
' run command : "<$file>" <$param>
randomize timer
#include "windows.bi" ' Respecter l'ordre de chargement des librairies, sinon erreur !
#include "gl/glu.bi"
#include "\LIB\math.bi"
#include "\LIB\str_lib.bi"
dim shared as single z_visibilite=128*10
dim shared as single angle_vision=50
dim shared as single cam_angle_xz=90 ' vers la droite quand on augmente
dim shared as single cam_angle_y=0 ' vers le bas quand on augmente
dim shared as single eye_move_step=.1
dim shared as single eye_rot_step=.000001
dim shared as single eye_x=0 ' gauche/droite
dim shared as single eye_z=0 ' eloignement
dim shared as single eye_y=0
dim shared as single visee_x
dim shared as single visee_y
dim shared as single visee_z
'-------------------------------------------------------------------------------
const size_ptx_mem=40000000
redim shared as single px(size_ptx_mem)
redim shared as single py(size_ptx_mem)
redim shared as single pz(size_ptx_mem)
redim shared as single col_r(size_ptx_mem)
redim shared as single col_g(size_ptx_mem)
redim shared as single col_b(size_ptx_mem)
redim shared as single relief_gl_points(size_ptx_mem)
redim shared as single relief_gl_color(size_ptx_mem)
redim shared as single relief_gl_normale(size_ptx_mem)
#include "\LIB\initgl.bi"
#include "\LIB\trace_points.bi"
'-------------------------------------------------------------------------------
screenres 1024,768,32
?
? " load PTX points, please wait ..."
?
dim as string pts_file,pts_txt
dim as integer pts_ch
dim as integer pts_line_index,pts_line_index_old,pts_line_index_max
pts_ch=freefile()
pts_file=exepath+"\POINTS\points.pts"
open pts_file for input as #pts_ch
line input #pts_ch,pts_txt ' premiere ligne = nombre max de points
pts_line_index_max=val(pts_txt)
do until eof(pts_ch)
pts_line_index+=1
if pts_line_index>=(pts_line_index_old+10000) then
pts_line_index_old=pts_line_index
locate 4,4
? pts_line_index;" /";pts_line_index_max
end if
line input #pts_ch,pts_txt
px(pts_line_index)=-val(str_colonne(pts_txt,1))
py(pts_line_index)=val(str_colonne(pts_txt,2))
pz(pts_line_index)=val(str_colonne(pts_txt,3))
col_r(pts_line_index)=val(str_colonne(pts_txt,5))/255
col_g(pts_line_index)=val(str_colonne(pts_txt,6))/255
col_b(pts_line_index)=val(str_colonne(pts_txt,7))/255
loop
close #pts_ch
pts_line_index_max=pts_line_index
'-------------------------------------------------------------------------------
screen 21,32,,2
init_gl()
points_to_array(pts_line_index_max)
'-------------------------------------------------------------------------------
dim as integer xmouse,xmouse_old,xmouse_dif
dim as integer ymouse,ymouse_old,ymouse_dif
dim as integer molette,molette_old
dim as integer mousebouton
dim as string key
GETMOUSE xmouse,ymouse,molette,mousebouton
xmouse_old=xmouse
ymouse_old=ymouse
molette_old=molette
do:
GETMOUSE xmouse,ymouse,molette,mousebouton
if mousebouton=1 then
xmouse_dif=xmouse-1280/2
ymouse_dif=ymouse-1024/2
cam_angle_xz+=xmouse_dif*eye_rot_step*angle_vision
cam_angle_y+=ymouse_dif*eye_rot_step*angle_vision
eye_x+=eye_move_step*cos(cam_angle_xz)
eye_z-=eye_move_step*sin(cam_angle_xz)
eye_y-=eye_move_step*sin(cam_angle_y)*.2
end if
if mousebouton=2 then
xmouse_dif=xmouse-1280/2
ymouse_dif=ymouse-1024/2
cam_angle_xz+=xmouse_dif*eye_rot_step*2*angle_vision
cam_angle_y+=ymouse_dif*eye_rot_step*2*angle_vision
end if
if cam_angle_y>=pisur2 then cam_angle_y=pisur2
if cam_angle_y<=-pisur2 then cam_angle_y=-pisur2
if xmouse>-1 then xmouse_old=xmouse
if ymouse>-1 then ymouse_old=ymouse
if molette<>-1 then
if molette<molette_old then
angle_vision+=2:if angle_vision>120 then angle_vision=120
molette_old=molette
end if
if molette>molette_old then
angle_vision-=2:if angle_vision<2 then angle_vision=2
molette_old=molette
end if
end if
key=inkey
if key=Chr(27) then end
if key=Chr(255)&"H" then ' fleche haut
eye_x+=eye_move_step*cos(cam_angle_xz)
eye_z-=eye_move_step*sin(cam_angle_xz)
end if
if key=Chr(255)&"P" then ' fleche bas
eye_x-=eye_move_step*cos(cam_angle_xz)
eye_z+=eye_move_step*sin(cam_angle_xz)
end if
if key=Chr(255)&"K" then ' fleche gauche
eye_x-=eye_move_step*cos(cam_angle_xz+pisur2)
eye_z-=eye_move_step*sin(cam_angle_xz-pisur2)
end if
if key=Chr(255)&"M" then ' fleche droite
eye_x+=eye_move_step*cos(cam_angle_xz+pisur2)
eye_z+=eye_move_step*sin(cam_angle_xz-pisur2)
end if
if key=Chr(255)&"I" then eye_y+=eye_move_step ' fleche page up
if key=Chr(255)&"Q" then eye_y-=eye_move_step ' fleche page down
visee_x=eye_x+256*cos(cam_angle_xz)
visee_z=eye_z-256*sin(cam_angle_xz)
visee_y=eye_y-256*sin(cam_angle_y)
rafresh_gl()
trace_relief(pts_line_index_max)
flip
loop
Initgl.bi
Code: Select all
'-------------------------------------------------------------------------------
function init_gl() as integer
'dim as GLfloat lightAmbient(3) => {1,1,1,1}
'dim as GLfloat lightDiffuse(3) => {0,0,0,0}
'dim as GLfloat lightPosition(3) => {0,0,0}
glViewport 0,0,1280,1024
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective angle_vision,1280/1024,1,z_visibilite 'angle suivant y,x aspect ratio,znear,zfar
glMatrixMode GL_MODELVIEW
'glClearColor(180/256,207/256,228/256,1)
glClearColor(0,0,0,1)
glEnable(GL_DEPTH_TEST)
'glEnable(GL_LIGHTING)
'glEnable(GL_LIGHT1)
'glLightfv(GL_LIGHT1,GL_AMBIENT,@lightAmbient(0))
'glLightfv(GL_LIGHT1,GL_DIFFUSE,@lightDiffuse(0))
'glLightfv(GL_LIGHT1,GL_POSITION,@lightPosition(0))
'glEnable(GL_LIGHT2)
'glLightfv(GL_LIGHT2,GL_AMBIENT,@lightAmbient(0))
'glLightfv(GL_LIGHT2,GL_DIFFUSE,@lightDiffuse(0))
'glLightfv(GL_LIGHT2,GL_POSITION,@lightPosition(0))
end function
'-------------------------------------------------------------------------------
function rafresh_gl() as integer
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective angle_vision,1280/1024,1,z_visibilite 'angle suivant y,x aspect ratio,znear,zfar
gluLookAt eye_x,eye_y,-eye_z,visee_x,visee_y,-visee_z,0,1,0
glMatrixMode GL_MODELVIEW
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
end function
'-------------------------------------------------------------------------------
math.bi
Code: Select all
'-------------------------------------------------------------------------------
const as double pi=4*atn(1)
const as double deuxpi=pi*2
const as double pisur2=pi/2
const as double troispisur2=3*pisur2
const as double pisur4=pi/4
const as double pisur180=pi/180
dim shared as double sinus(0 to 360)
dim shared as double cosinus(0 to 360)
'-------------------------------------------------------------------------------
dim as integer math_n
for math_n=0 to 360
sinus(math_n)=sin(pisur180*math_n)
cosinus(math_n)=cos(pisur180*math_n)
next
'-------------------------------------------------------------------------------
Code: Select all
'-------------------------------------------------------------------------------
function str_colonne(str_in as string,str_n_col as integer) as string
dim as integer str_n,str_case_len,str_start_pos,str_end_pos
dim as string str_out
str_start_pos=1
for str_n=1 to str_n_col-1
str_start_pos=instr(str_start_pos,str_in," ")+1
next
str_end_pos=instr(str_start_pos,str_in," ")
str_case_len=str_end_pos-str_start_pos
str_out=mid(str_in,str_start_pos,str_case_len)
return str_out
end function
'-------------------------------------------------------------------------------
trace_points.bi
Code: Select all
'-------------------------------------------------------------------------------
function points_to_array(pts_line_index_max as integer) as integer
dim as integer array_index=0
dim as integer pts_line_index
for pts_line_index=1 to pts_line_index_max
relief_gl_points(array_index+0)=px(pts_line_index)
relief_gl_points(array_index+1)=py(pts_line_index)
relief_gl_points(array_index+2)=-pz(pts_line_index)
'relief_gl_normale(array_index+0)=1
'relief_gl_normale(array_index+1)=1
'relief_gl_normale(array_index+2)=1
relief_gl_color(array_index+0)=col_r(pts_line_index)
relief_gl_color(array_index+1)=col_g(pts_line_index)
relief_gl_color(array_index+2)=col_b(pts_line_index)
array_index+=3
next
end function
'-------------------------------------------------------------------------------
function trace_relief(pts_line_index_max as integer) as integer
glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_COLOR_ARRAY)
'glEnableClientState(GL_NORMAL_ARRAY)
glVertexPointer(3,GL_FLOAT,0,@relief_gl_points(0))
glColorPointer(3,GL_FLOAT,0,@relief_gl_color(0))
'glNormalPointer(GL_FLOAT,0,@relief_gl_normale(0))
'glEnable(GL_NORMALIZE)
'glEnable(GL_COLOR_MATERIAL)
'glShadeModel(GL_FLAT)
glPointSize(3)
glDrawArrays(GL_POINTS,0,pts_line_index_max)
glDisableClientState(GL_VERTEX_ARRAY)
end function
'-------------------------------------------------------------------------------
points.pts
file beginnig only because it's too big to post the full file here... (6194733 lines)
194733
-27.3897 -0.4102 -29.5255 95 97 97 85
-27.3897 -0.4102 -29.5255 95 97 97 85
-27.3897 -0.4102 -29.5255 95 97 97 85
-27.3897 -0.4102 -29.5255 95 97 97 85
-27.2934 -0.3023 -29.3329 63 69 63 51
-27.3328 -0.3694 -29.4730 77 83 78 63
-27.3328 -0.3694 -29.4730 77 83 78 63
-27.2905 -0.4102 -29.3679 94 95 97 83
-27.3328 -0.3694 -29.4730 77 83 78 63
-27.3328 -0.3694 -29.4730 77 83 78 63
-27.2934 -0.3023 -29.3329 63 69 63 51
-27.2905 -0.4102 -29.3679 94 95 97 83
-27.2934 -0.3023 -29.3329 63 69 63 51
-27.2934 -0.3023 -29.3329 63 69 63 51
-27.2905 -0.4102 -29.3679 94 95 97 83
-27.2905 -0.4102 -29.3679 94 95 97 83
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.3314 -0.0571 -29.8859 80 80 82 72
-27.2788 -0.0557 -29.7663 102 101 104 95
-27.2788 -0.0557 -29.7663 102 101 104 95
-27.2788 -0.0557 -29.7663 102 101 104 95
-27.2788 -0.0557 -29.7663 102 101 104 95
-27.4612 0.1180 -29.3709 36 40 36 33
-27.3824 -0.1140 -29.1724 48 51 48 41
-27.3912 -0.0615 -29.2804 74 75 74 72
-27.4656 -0.0148 -29.3534 38 38 39 34
-27.4029 -0.1607 -29.1899 33 35 34 30
-27.3168 -0.1140 -29.1724 73 78 73 67
-27.4612 0.1180 -29.3709 36 40 36 33
-27.3168 -0.1140 -29.1724 73 78 73 67
-27.4043 -0.1593 -29.1316 34 37 33 32
-27.3912 -0.0615 -29.2804 74 75 74 72
-27.4612 0.1180 -29.3709 36 40 36 33
-27.3795 -0.0673 -29.2322 82 85 82 75