#VRML V2.0 utf8

WorldInfo { 
title  "Cubeiforms" 
info [ 
"Auteur     : Gregoire Cliquet" 
"Email      : greg@x-arn.org" 
"Copyleft  : G.Cliquet / arn 09 2000"
     ]
	  }

NavigationInfo {
		avatarSize [ 3.5, 1.6, 0.75 ] 
	  }
 
DEF Camera01 Viewpoint {
  position 34 0 69
  orientation 1 0 0 0
  fieldOfView 0.7854
  description "Cubeiforms"
}

Group {
	children [
		Collision {
    		collide FALSE
			children [
				DEF Proxy ProximitySensor { 
						size 1e25 1e25 1e25
						center 34 0 19.78 
						}
				DEF Validate Transform {
						children  Transform {
          				translation -2.10 -1.5 -3.8
						children [
                		DEF Validation TouchSensor {}                                
                            Shape {
							geometry Box { size 0.25 0.05 0.001 }
				   			appearance Appearance {
                                   			material DEF Matvalidate Material
											{
          									diffuseColor 1 1 1
											transparency 0.3 }	
                                        	
											texture ImageTexture {
											url  "save.gif"
																  }
											}
                                   }
								   ]
                                  }
			    			     	  }       
							
				DEF Helping Transform {
					children  Transform {
          				translation -1.93 -1.5 -3.8
          				children [
                			Anchor {                                 
                        	 		url ["menu/cpop.html"]
						parameter ["target = _self"]           
                         	 		description ">>>>>>>>>>>>>>>>>>>>  Help ?"
                            			children [
                               				Shape {
											geometry Box { size 0.05 0.05 0.001 }
				   							appearance Appearance {
                                   				material DEF Matvalidate Material {
          										diffuseColor 1 1 1
												transparency 0.3
													}	
                                        	         		      }
                                     				}
                                   			]
			    			     }
						]		
         					     }
							    }        
				
				DEF Proh Transform {
			   		children  Transform {
        					translation  -1.86 -1.5 -3.8
						rotation 0 0 1 0
      						children [
							DEF BoutonH TouchSensor {}
    							Shape {
								geometry Box { size 0.05 0.05 0.001 }
      								appearance Appearance {
       						 		material DEF Math Material {
          								diffuseColor 1 1 1
									transparency 0
					                           		 }				
      							      			      }
      					
    					      		     }
					 		]
						   }
						  }
				DEF Prov Transform {
			   		children  Transform {
        					translation  -1.79 -1.5 -3.8
						rotation 0 0 1 0
      						children [
							DEF BoutonV TouchSensor {}
    							Shape {
								geometry Box { size 0.05 0.05 0.001 }
      								appearance Appearance {
       						 		material DEF Matv Material {
          								diffuseColor 1 1 1
									transparency 0
					                           		 }				
      							      			      }
      					
    					      		     }
					 	]
				     		   }
						  }
	]
		}
	]
}

	DEF Horiz_grill Transform {
  	translation 20 0 5.783
  		children [
    			Shape {
      			appearance Appearance {
        				material DEF MGhorz_0 Material {
          				transparency 0
          				emissiveColor 0.502 0.502 0.502
        			  			  }
      			      		      }

     	geometry DEF GrilleHoriz IndexedLineSet {

        	coord Coordinate {
		point [
		0 0 0, 0 0 28, 2 0 0, 2 0 28, 4 0 0, 4 0 28, 6 0 0, 6 0 28,
		8 0 0, 8 0 28, 10 0 0, 10 0 28, 12 0 0, 12 0 28, 14 0 0, 14 0 28,
		16 0 0, 16 0 28, 18 0 0, 18 0 28, 20 0 0, 20 0 28, 22 0 0, 22 0 28,
		24 0 0, 24 0 28, 26 0 0, 26 0 28, 28 0 0, 28 0 28,
		
		0 0 2, 28 0 2, 0 0 4, 28 0 4, 0 0 6, 28 0 6, 0 0 8, 28 0 8, 0 0 10, 28 0 10
		0 0 12, 28 0 12, 0 0 14, 28 0 14, 0 0 16, 28 0 16, 0 0 18, 28 0 18,
		0 0 20, 28 0 20, 0 0 22, 28 0 22, 0 0 24, 28 0 24, 0 0 26, 28 0 26,
		0 0 28, 28 0 28]
				 }
		coordIndex [
		0, 1, 0, -1, 2, 3, 2, -1, 4, 5, 4, -1, 6, 7, 6, -1, 8, 9, 8, -1,
		10, 11, 10, -1, 12, 13, 12, -1, 14, 15, 14, -1, 16, 17, 16, -1,
		18, 19, 18, -1, 20, 21, 20, -1, 22, 23, 22, -1, 24, 25, 24, -1,
		26, 27, 26, -1, 28, 29, 28, -1,

		0, 28, 0, -1, 1, 29, 1, -1,
		
		30, 31, 30, -1, 32, 33, 32, -1, 34, 35, 34, -1, 36, 37, 36, -1,
		38, 39, 38, -1,	40, 41, 40, -1, 42, 43, 42, -1, 44, 45, 44, -1,
		46, 47, 46, -1, 48, 49, 48, -1,	50, 51, 50, -1, 52, 53, 52, -1,
		54, 55, 54, -1, 56, 57, 56, -1]
 				 }
				}
		     ]
		}

DEF Vert_grill Transform {
  	translation 20 0 5.783
  		children [
    			Shape {
      			appearance Appearance {
        				material DEF MGvert_0 Material {
          				emissiveColor 0.502 0.502 0.502
          				transparency 0
        			  			  }
      			      		      }

     	geometry DEF GrilleVert IndexedLineSet {

        	coord Coordinate {
		point [
		14 -14 0, 14 -14 28, 14 -12 0, 14 -12 28, 14 -10 0, 14 -10 28, 14 -8 0, 14 -8 28,
		14 -6 0, 14 -6 28, 14 -4 0, 14 -4 28, 14 -2 0, 14 -2 28, 14 0 0, 14 0 28,
		14 2 0, 14 2 28, 14 4 0, 14 4 28, 14 6 0, 14 6 28, 14 8 0, 14 8 28, 14 10 0, 14 10 28,
		14 12 0, 14 12 28, 14 14 0, 14 14 28,
		14 -14 2, 14 14 2, 14 -14 4, 14 14 4, 14 -14 6, 14 14 6, 14 -14 8, 14 14 8,
		14 -14 10, 14 14 10, 14 -14 12, 14 14 12, 14 -14 14, 14 14 14, 14 -14 16, 14 14 16,
		14 -14 18, 14 14 18, 14 -14 20, 14 14 20, 14 -14 22, 14 14 22, 14 -14 24, 14 14 24,
		14 -14 26, 14 14 26, 14 -14 28, 14 14 28]
				 }

		coordIndex [
		0, 1, 0, -1, 2, 3, 2, -1, 4, 5, 4, -1, 6, 7, 6, -1, 8, 9, 8, -1,
		10, 11, 10, -1, 12, 13, 12, -1, 14, 15, 14, -1, 16, 17, 16, -1, 18, 19, 18, -1,
		20, 21, 20, -1, 22, 23, 22, -1,	24, 25, 24, -1, 26, 27, 26, -1, 28, 29, 28, -1,
		
		0, 28, 0, -1, 1, 29, 1, -1, 30, 31, 30, -1, 32, 33, 32, -1, 34, 35, 34, -1,
		36, 37, 36, -1,	38, 39, 38, -1, 40, 41, 40, -1, 42, 43, 42, -1, 44, 45, 44, -1,
		46, 47, 46, -1, 48, 49, 48, -1,	50, 51, 50, -1, 52, 53, 52, -1, 54, 55, 54, -1,
		56, 57, 56, -1]
 			}
						}
	]
}

DEF Hide_0 Script
{       
	eventIn		SFTime		Hide_H
	eventIn		SFTime		Hide_V
	eventIn		SFTime		Validate_0
	field		SFNode		M_gh USE MGhorz_0
	field		SFNode		M_gv USE MGvert_0
	eventOut	SFFloat		T_gh
	eventOut	SFFloat		Bt_h
	eventOut	SFFloat		T_gv
	eventOut	SFFloat		Bt_v
	field		MFString	urlvise ""
	field		MFString	cible "target=code"

	url	"javascript:
	function Hide_H()
	   {
		if (M_gh.transparency == 0) {
			T_gh = 1;
			Bt_h = 0.5; 
						} else {
							T_gh = 0;
							Bt_h = 0; 
							}
	  }

	  function Hide_V()
	   {
		if (M_gv.transparency == 0) {
			T_gv = 1;
			Bt_v = 0.5; 
						} else {
							T_gv = 0;
							Bt_v = 0; 
							}
	  }
	  
	  function Validate_0()
	  {
	  urlvise[0] = 'javascript:validate()'
	  Browser.loadURL(urlvise, cible)
	  }
		"
}
ROUTE Proxy.orientation_changed TO Validate.rotation
ROUTE Proxy.position_changed TO Validate.translation
ROUTE Proxy.orientation_changed TO Helping.rotation
ROUTE Proxy.position_changed TO Helping.translation
ROUTE Proxy.orientation_changed TO Proh.rotation
ROUTE Proxy.position_changed TO Proh.translation
ROUTE Proxy.orientation_changed TO Prov.rotation
ROUTE Proxy.position_changed TO Prov.translation

ROUTE BoutonH.touchTime TO Hide_0.Hide_H
ROUTE Hide_0.T_gh TO MGhorz_0.set_transparency
ROUTE Hide_0.Bt_h TO Math.set_transparency
ROUTE BoutonV.touchTime TO Hide_0.Hide_V
ROUTE Hide_0.T_gv TO MGvert_0.set_transparency
ROUTE Hide_0.Bt_v TO Matv.set_transparency
ROUTE Validation.touchTime TO Hide_0.Validate_0


PROTO Cube_generik
	 [
	field 			SFVec3f		Place_0 0 0 0
	field			SFString	CubID ""
         ]
{
	Transform {
	translation IS Place_0
  		children [
      		DEF Cube_0 Transform {
        		translation 0 0 0
      				children [
    					Shape {
					geometry Box { size 4 4 4 }
      					appearance Appearance {
       						 material Material {
          						diffuseColor 1 1 1
							transparency 0
					                           }				
      							      }
    					      }
					 ]
		
				     }
		Sound {
		source DEF Name_0 AudioClip
				{description IS CubID }
		      		 }

		DEF Capteur_0 SphereSensor {}
  			]
		  }

DEF Move_0 Script
{       
	eventIn		SFVec3f		Bouge_0
	field		SFNode		Capt_0 USE Capteur_0
	field		SFNode		Cub_0 USE Cube_0
	eventOut	SFVec3f		Modif_0
	eventOut	SFVec3f		Result_0
	field		SFNode		Name USE Name_0
	field		MFString	urlvise ""
	field		MFString	cible "target=code"
	
	url	"javascript:
	function Bouge_0()
	   {
		Modif_0 = Capt_0.trackPoint_changed
		CubID = Name.set_description
		x2 = Modif_0[0]
		a2 = Math.round(x2)
		y2 = Modif_0[1]
		b2 = Math.round(y2)
		z2 = Modif_0[2]
		c2 = Math.round(z2)

			aa = a2%2
				if (aa != 0) { xx = a2 +1;
						} else { xx = a2 }
			bb = b2%2
				if (bb != 0) { yy = b2 +1;
						} else { yy = b2 }
			cc = c2%2
				if (cc != 0) { zz = c2 +1;
						} else { zz = c2 }
			if (xx >= 14) {
			xx = 14 }
			if (xx <= -14) {
			xx = -14 }

			if (yy >= 14) {
			yy = 14 }
			if (yy <= -14) {
			yy = -14 }

			if (zz >= 14) {
			zz = 14 }
			if (zz <= -14) {
			zz = -14 }

			Result_0 =  new SFVec3f(xx, yy, zz)
			print ('Objet n ' +CubID + ' Position = ' +Result_0); 
			urlvise[0] = 'javascript:getCoords(' + CubID + ',' + xx + ',' + yy + ',' + zz + ')'
			Browser.loadURL(urlvise, cible)
			} 
		"
}
ROUTE Capteur_0.trackPoint_changed TO Move_0.Bouge_0
ROUTE Move_0.Result_0 TO Cube_0.set_translation
}

Cube_generik { Place_0 34 0 19.78  CubID "01"} #01
Cube_generik { Place_0 34 0 19.78  CubID "02"} #02
Cube_generik { Place_0 34 0 19.78  CubID "03"} #03
Cube_generik { Place_0 34 0 19.78  CubID "04"} #04
Cube_generik { Place_0 34 0 19.78  CubID "05"} #05 
Cube_generik { Place_0 34 0 19.78  CubID "06"} #06
Cube_generik { Place_0 34 0 19.78  CubID "07"} #07 
Cube_generik { Place_0 34 0 19.78  CubID "08"} #08
Cube_generik { Place_0 34 0 19.78  CubID "09"} #09
Cube_generik { Place_0 34 0 19.78  CubID "10"} #10
Cube_generik { Place_0 34 0 19.78  CubID "11"} #11 
Cube_generik { Place_0 34 0 19.78  CubID "12"} #12
Cube_generik { Place_0 34 0 19.78  CubID "13"} #13
Cube_generik { Place_0 34 0 19.78  CubID "14"} #14
Cube_generik { Place_0 34 0 19.78  CubID "15"} #15
Cube_generik { Place_0 34 0 19.78  CubID "16"} #16
Cube_generik { Place_0 34 0 19.78  CubID "17"} #17
Cube_generik { Place_0 34 0 19.78  CubID "18"} #18
Cube_generik { Place_0 34 0 19.78  CubID "19"} #19
Cube_generik { Place_0 34 0 19.78  CubID "20"} #20 
Cube_generik { Place_0 34 0 19.78  CubID "21"} #21
Cube_generik { Place_0 34 0 19.78  CubID "22"} #22
Cube_generik { Place_0 34 0 19.78  CubID "23"} #23
Cube_generik { Place_0 34 0 19.78  CubID "24"} #24
Cube_generik { Place_0 34 0 19.78  CubID "25"} #25
Cube_generik { Place_0 34 0 19.78  CubID "26"} #26
Cube_generik { Place_0 34 0 19.78  CubID "27"} #27
Cube_generik { Place_0 34 0 19.78  CubID "28"} #28
Cube_generik { Place_0 34 0 19.78  CubID "29"} #29
Cube_generik { Place_0 34 0 19.78  CubID "30"} #30
Cube_generik { Place_0 34 0 19.78  CubID "31"} #31
Cube_generik { Place_0 34 0 19.78  CubID "32"} #32
Cube_generik { Place_0 34 0 19.78  CubID "33"} #33
Cube_generik { Place_0 34 0 19.78  CubID "34"} #34
Cube_generik { Place_0 34 0 19.78  CubID "35"} #35
Cube_generik { Place_0 34 0 19.78  CubID "36"} #36