Discussion forum about PANORAMIC language

Mac, Windows & Android application development with PANORAMIC language
 
HomeFAQSearchRegisterMemberlistUsergroupsLog in
Latest topics
» Hello world.
by Mon Jun 19, 2017 1:37 am

» Biomorphes de PICKOVER
by Sun Jun 18, 2017 2:33 am

» In less than 10 lines of code
by Fri Jun 16, 2017 5:03 am

» Effect Dopler
by Fri Jun 16, 2017 3:29 am

» SuperEllipse
by Wed Jun 14, 2017 4:01 am

» Plants
by Wed Jun 14, 2017 3:38 am

» Mira's attractor
by Wed Jun 14, 2017 3:30 am

» Triangle of Sierpinski
by Wed Jun 14, 2017 3:22 am

» Esthétique polaire
by Wed Jun 14, 2017 3:16 am

» Butterfly effect : Lorenz equations
by Wed Jun 14, 2017 3:08 am

» Collision detection
by Tue Jun 13, 2017 5:09 am

» The Bees Laline Paull Epub Books
by Mon Oct 10, 2016 8:58 pm

» PANORAMIC for Mac OSX 10 is available
by Tue Aug 09, 2016 6:08 pm

» ide
by Sat Jul 16, 2016 12:27 am

» Can I change the program icon/logo in my application ?
by Thu Jul 07, 2016 3:32 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Share | 
 

 to build cities in 3D

View previous topic View next topic Go down 
AuthorMessage
bignono

avatar

Number of posts : 11
Age : 60
Localisation : Champigny-sur-Marne, 94500, France
Registration date : 2013-03-12

PostSubject: to build cities in 3D   Sat Mar 16, 2013 4:14 pm

Bonjour à tous,
Voici toujours mon programme allégé de mon module de déplacement dans un monde en 3d, auquel j'ai adjoint un petit algorithme qui permet de créer une ville avec des building de toutes sortes.
Ci-joint les images pour les textures que vous copiez et installez dans le répertoire de votre choix. N'oubliez pas de changer "rep$" dans le programme.
En rajoutant d'autres textures differentes, on doit réussir à faire de manière aléatoire de vrais grandes cités.
En plus, cela ressemble un peu à un labyrinthe, vous ne croyez pas?

Hello everyone, Very Happy
Here always my low-fat program of my module of displacement in a world in 3D, with which I associated a small algorithm which makes it possible to create a city with building of all kinds.
Herewith images for textures which you copy and install in the repertoire of your choice. Do not forget to change “rep$” in the program.
By adding other different textures, one must succeed in making in a random way of quoted truths large.
Moreover, does that resemble a little a labyrinth, you do not believe?
Wink Wink Wink
[img]herbe.jpg[/img]
[img]beton[/img]
[img]imm1.jpg[/img]
[img]imm2.jpg[/img]
[img]imm3.jpg[/img]
[img]imm4.jpg[/img]
[img]imm5.jpg[/img]
[img]imm6.jpg[/img]
[img]imm7.jpg[/img]
Here the code: cheers
Code:
' ******************************************************************************
' ****************************** ORDERS KEYBOARD *******************************
' ******************************************************************************
dim esc  :' * KEY ESC ==> END PROGRAM:............................... CASE 27  *
dim tfg  :' * KEY LEFT ARROW ==> TO TURN LEFT:....................... CASE 37  *
dim tfh  :' * KEY HIGHT ARROW ==> TO PROGRESS:....................... CASE 38  *
dim tfd  :' * KEY RIGHT ARROW ==> TO TURN RIGHT:..................... CASE 39  *
dim tfb  :' * KEY LOW ARROW ==> TO BACK:............................. CASE 40  *
dim tcb  :' * KEY "B" ==> TO LOOK AT DOWNWARDS:...................... CASE 66  *
dim tch  :' * KEY "H" ==> TO LOOK AT UPWARDS:........................ CASE 72  *
' ******************************************************************************
dim pn5  :' * KEY "5" ==> RETURN ORIGIN:............................. CASE 101 *
' ******************************************************************************
dim rep$,rot,chy,phy,bh:rot=180:chy=0.7:phy=0.7:rep$="c:\mesprog\ModuleCamera\"
label t1,t2,bouge

on_key_down 0,t1
on_key_up 0,t2

scene()

timer 200:timer_interval 200,1:on_timer 200,bouge
end

bouge:
timer_off 200
deplace()
timer_on 200
return

sub deplace()
dim_local vrot,vd,mv,pv
vrot=1:vd=0.025:mv=1000:pv=1001
if esc=1 then terminate
if tfg=1 then rot=rot+vrot:3d_y_rotate mv,rot
if tfd=1 then rot=rot-vrot:3d_y_rotate mv,rot
if tfh=1 then 3d_move mv,vd
if tfb=1 then 3d_move mv,vd-(2*vd)
if tcb=1 then bh=bh+.2:if bh>4 then bh=4
if tch=1 then bh=bh-.2:if bh<-4 then bh=-4
if pn5=1 then bh=0:rot=180:chy=0.75:phy=0.75:3d_position mv,0,chy,0:3d_y_rotate mv,rot:3d_move mv,-30

3d_position pv,o3d_x_position(mv),o3d_y_position(mv),o3d_z_position(mv):3d_rotate pv,o3d_x_rotate(mv),o3d_y_rotate(mv),o3d_z_rotate(mv)
3d_move pv,1:cam_position o3d_x_position(mv),sin(bh/6.28)+chy,o3d_z_position(mv):point_position o3d_x_position(pv),phy,o3d_z_position(pv)

caption 0,str$(wrap_value(rot))+"° - "+str$(bh)
end_sub

sub scene()
dim_local bx,by,bz,ox,oz,imm
full_space 0:scene3d 1:hide 1:full_space 1:color 1,0,0,200
font_name 0,"Consolas":font_size 0,40:font_bold 0
print_locate (width(0)/2)-(text_width("WAIT! INSTALLATION OF THE SCENE",0)/2),height(0)/3
print "WAIT! INSTALLATION OF THE SCENE"

' ground of our scene
3d_plane 1:3d_scale 1,40,40,1:3d_u_tile 1,200:3d_v_tile 1,200:3d_x_rotate 1,90:3d_y_position 1,0:3d_load_texture 1,rep$+"herbe.jpg"
3d_plane 2:3d_scale 2,2.5,2.5,1:3d_u_tile 2,5:3d_v_tile 2,5:3d_x_rotate 2,90:3d_y_position 2,0.1:3d_load_texture 2,rep$+"beton.jpg"
' algorithm of creation of the buildings
ox=10:oz=10
for bz=-1*oz to oz step 2
  for bx=-1*ox to ox
      imm=int(rnd(1)*11)
      if imm=7
        by=2.25:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm7.jpg"
      end_if
      if imm=6
        by=3:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm6.jpg"
      end_if
      if imm=5
        by=3:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm5.jpg"
      end_if
      if imm=4
        by=2:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm4.jpg"
      end_if
      if imm=3
        by=1.5:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm3.jpg"
      end_if
      if imm=2
        by=1.5:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm2.jpg"
      end_if
      if imm=1
        by=2:3d_box number_3d_objects+1,1,by*2,1
        3d_position number_3d_objects,bx,by,bz:3d_load_texture number_3d_objects,rep$+"imm1.jpg"
      end_if
  next bx
next bz

3d_cube 1000,1:3d_y_rotate 1000,rot:3d_move 1000,-30:3d_hide 1000:3d_mesh 1001

show 1
end_sub

t1:
if key_down_code=27 then esc=1
if key_down_code=37 then tfg=1
if key_down_code=38 then tfh=1
if key_down_code=39 then tfd=1
if key_down_code=40 then tfb=1
if key_down_code=66 then tcb=1
if key_down_code=72 then tch=1
if key_down_code=101 then pn5=1
return
t2:
if key_down_code=27 then esc=0
if key_down_code=37 then tfg=0
if key_down_code=38 then tfh=0
if key_down_code=39 then tfd=0
if key_down_code=40 then tfb=0
if key_down_code=66 then tcb=0
if key_down_code=72 then tch=0
if key_down_code=101 then pn5=0
return
Back to top Go down
View user profile
jicehel



Number of posts : 15
Registration date : 2013-03-12

PostSubject: Re: to build cities in 3D   Sat Mar 23, 2013 12:50 pm

a modified version with a start of collision managment
Code:
' ********************************************************************************
' ******************************* COMMANDES CLAVIER ******************************
' ********************************************************************************
dim esc,cesc : cesc=27 : ' * TOUCHE "ESC" ==> MET FIN AU PROGRAMME:.... CASE 27  *
dim tfg,ctfg : ctfg=37 : ' * FLÈCHE GAUCHE ==> PIVOTER À GAUCHE:....... CASE 37  *
dim tfh,ctfh : ctfh=38 : ' * FLÈCHE HAUTE ==> AVANCER:................. CASE 38  *
dim tfd,ctfd : ctfd=39 : ' * FLÈCHE DROITE ==> PIVOTER À DROITE:....... CASE 39  *
dim tfb,ctfb : ctfb=40 : ' * FLÈCHE BASSE ==> RECULER:................. CASE 40  *
dim tcb,ctcb : ctcb=66 : ' * TOUCHE "B" ==> REGARDER VERS LE BAS:...... CASE 66  *
dim tch,ctch : ctch=72 : ' * TOUCHE "H" ==> REGARDER VERS LE HAUT:..... CASE 72  *
dim pn5,cpn5 : cpn5=101: ' * TOUCHE "5" ==> RETOUR AU POINT D'ORIGINE:. CASE 101 *
' ********************************************************************************

dim rep$,rot,chy,phy,bh,test,i:rot=180:chy=0.7:phy=0.7:rep$="C:\Panoramic-Init\sources\3D_ville\"
label t1,t2,bouge

on_key_down 0,t1
on_key_up 0,t2

scene()

timer 200:timer_interval 200,1:on_timer 200,bouge
end

bouge:
timer_off 200
deplace()
timer_on 200
return

sub deplace()
dim_local vrot,vd,mv,pv
vrot=1:vd=0.07:mv=1000:pv=1001
if esc=1 then terminate
if tfg=1 then rot=rot+vrot:3d_y_rotate mv,rot: if scancode<>ctfg then tfg=0
if tfd=1 then rot=rot-vrot:3d_y_rotate mv,rot: if scancode<>ctfd then tfd=0
if tfh=1 then 3d_move mv,vd      : if scancode<>ctfh then tfh=0
if tfb=1 then 3d_move mv,vd-(2*vd): if scancode<>ctfb then tfb=0
if tcb=1 then bh=bh+.2:if bh> 4 then bh= 4 : if scancode<>ctcb then tcb=0
if tch=1 then bh=bh-.2:if bh<-4 then bh=-4 : if scancode<>ctch then tch=0
if pn5=1 then bh=0:rot=180:chy=0.75:phy=0.75:3d_position mv,0,chy,0:3d_y_rotate mv,rot:3d_move mv,-30: pn5=0

test=0
for i = 3 to (number_3d_objects - 2)
  if O3D_collision(1000,i)=1 then test = 1
next i
if test = 0
  3d_position pv,o3d_x_position(mv),o3d_y_position(mv),o3d_z_position(mv):3d_rotate pv,o3d_x_rotate(mv),o3d_y_rotate(mv),o3d_z_rotate(mv)
  3d_move pv,1:cam_position o3d_x_position(mv),sin(bh/6.28)+chy,o3d_z_position(mv):point_position o3d_x_position(pv),phy,o3d_z_position(pv)
  caption 0,str$(wrap_value(rot))+"°"+str$(bh)
else
  if tfh=1 then 3d_move mv,vd-(3*vd)
  if tfg=1 then rot=rot-2*vrot:3d_y_rotate mv,rot
  if tfd=1 then rot=rot+2*vrot:3d_y_rotate mv,rot
  if tfb=1 then 3d_move mv,2*vd
end_if
end_sub

sub scene()
dim_local bx,by,bz,ox,oz,imm
full_space 0:scene3d 1:hide 1:full_space 1:color 1,0,0,200
font_name 0,"Consolas":font_size 0,40:font_bold 0
print_locate (width(0)/2)-(text_width("PATIENTEZ! MISE EN PLACE DE LA SCÈNE",0)/2),height(0)/3
print "PATIENTEZ! MISE EN PLACE DE LA SCÈNE"

' sol de notre scene
3d_plane 1:3d_scale 1,40,40,1:3d_u_tile 1,200:3d_v_tile 1,200:3d_x_rotate 1,90:3d_y_position 1,0:3d_load_texture 1,rep$+"herbe.jpg"
3d_plane 2:3d_scale 2,2.5,2.5,1:3d_u_tile 2,5:3d_v_tile 2,5:3d_x_rotate 2,90:3d_y_position 2,0.1:3d_load_texture 2,rep$+"beton.jpg"

' algorithme de création des immeubles
ox=10:oz=10
for bz=-1*oz to oz step 2
  for bx=-1*ox to ox
      imm=int(rnd(1)*11)
      if imm=7 then by=2.5
      if imm=6 or imm=5 then by=3
      if imm=4 or imm=1 then by=2
      if imm=3 or imm=2 then by=1.5
      if imm>0 and imm<8
        3d_box number_3d_objects+1,1,by*2,1
        3d_load_texture number_3d_objects,rep$+"imm"+str$(imm)+".jpg"
        3d_position number_3d_objects,bx,by,bz : 3d_collision_as_cube number_3d_objects
      end_if
  next bx
next bz
3d_cube 1000,1:3d_scale 1000,0.2,0.5,0.5:3d_y_rotate 1000,rot:3d_move 1000,-30:3d_hide 1000:3d_mesh 1001
3d_collision_as_cube 1000

show 1
end_sub

t1:
if key_down_code=cesc then esc=1
if key_down_code=ctfg then tfg=1
if key_down_code=ctfh then tfh=1
if key_down_code=ctfd then tfd=1
if key_down_code=ctfb then tfb=1
if key_down_code=ctcb then tcb=1
if key_down_code=ctch then tch=1
if key_down_code=cpn5 then pn5=1
return
t2:
if key_down_code=cesc then esc=0
if key_down_code=ctfg then tfg=0
if key_down_code=ctfh then tfh=0
if key_down_code=ctfd then tfd=0
if key_down_code=ctfb then tfb=0
if key_down_code=ctcb then tcb=0
if key_down_code=ctch then tch=0
if key_down_code=cpn5 then pn5=0
return
Back to top Go down
View user profile
 
to build cities in 3D
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» How to use ANT build to create HTML reports in Eclispe
» Issue in running generated build using Selenium Webdriver?
» Windows 10 TP Build 9879
» Windows 10 TP Build 9901
» [SOLVED] Windowsupdate not working ! (Build 9926)

Permissions in this forum:You cannot reply to topics in this forum
Discussion forum about PANORAMIC language :: Panoramic for Windows :: Source code (snippets)-
Jump to: