Crnometro em VRML

0 respostas
Hn1

Boas pessoal

Estive a navegar pelo GUJ e não encontrei nada sobre VRML. Sei que não estou a postar no lugar certo mas como não há um post sobre VRML podiam-me dar uma ajuda a resolver este problema?
Eu ja consegui fazer um relogio analogico, mas estou a me passar não consigo fazer um crnometro tem que ter dois botões um fazr o reset, e o outro faz o stop, e recomeçar o do mesm o sitio onde parou. Estes botões tem que ser feitos com a função TouchSensor(para o activar basta passar o rato por cima).

Este é o codigo vrml ja feito:

#VRML V2.0 utf8

Hugo Oliveira

WorldInfo {
title “VRML Cronometro analogico”

}

Group {
children [

Viewpoint

Viewpoint {
  description "Fit View"
  position 0.0 0.0 350.0
},

Animation clock

DEF Clock TimeSensor {      
  loop TRUE
},


DEF TUBE Transform {
        children [
           Shape {
              appearance Appearance {
                            material Material { } 
                         }
              geometry Cylinder {
                          height 11
                          radius 4
                       }
           },
           DEF SENSOR TouchSensor {}
        ]

}

DEF CLOCK TimeSensor {

enabled       FALSE

cycleInterval 2

loop          TRUE

}
DEF MOVER PositionInterpolator {

key      [ 2, 10, 1 ]

keyValue [ 0 1 0, 0 1.4 0, 10 0.0 0 ]

}

# geometria do cilindro amarelo a base do relogio

DEF Cylinder01-ROOT Transform {

translation 0 0 -10

rotation -1 0 0 -1.571

scale 1 1 1

children [

Transform {

translation 0 5 0

children [

Shape {

appearance Appearance {

material Material {

diffuseColor 1 1 0

shininess 0.8
}
          }
          geometry Cylinder { radius 105 height 9.5 }
        }
      ] 
    }
  ]
},

        
      ] 
    }
DEF Box01-ROOT Transform {

translation -0.117 89.92 0

rotation -1 0 0 -1.571

scale 1 1 1

children [

Transform {

translation 0 2.5 0

children [

Shape {

appearance Appearance {

material Material {

diffuseColor 0.5 0.5 0.5

}

}

geometry Box { size 6 6  25 }

}

]

}

]

},

DEF Box02-ROOT Transform {

translation -45 77.9 0

rotation -0.9 -0.2506 -0.2506 -1.638

scale 1 1 1

children [

DEF HourBox Transform {

translation 0 2.5 0

children [

Shape {

appearance Appearance {

material Material {

diffuseColor 0.5 0.7 1

}

}

geometry Box { size 5 5  21 }

}

]

}

]

},

DEF Box03-ROOT Transform {

translation -77.86 45.04 0

rotation -0.7746 -0.4472 -0.4472 -1.823

scale 1 1 1

scaleOrientation 0.6728 0.7398 0 -0.1766

children [ USE HourBox ]

},

DEF Box04-ROOT Transform {

translation -89.89 0.1642 0

rotation -0.5774 -0.5774 -0.5774 -2.094

scale 1 1 1

scaleOrientation -0.4264 0 -0.9045 -0.4401

children [ USE HourBox ]

},

DEF Box05-ROOT Transform {

translation -77.86 -44.72 0

rotation -0.378 -0.6547 -0.6547 -2.419

scale 1 1 1

scaleOrientation 0.3909 -0.6372 -0.6642 -0.3716

children [ USE HourBox ]

},

DEF Box06-ROOT Transform {

translation -45.01 -77.58 0

rotation -0.1862 -0.6947 -0.6947 -2.773

scale 1 1 1

scaleOrientation -0.2367 0.5183 -0.8218 -0.6884

children [ USE HourBox ]

},

DEF Box07-ROOT Transform {

translation -0.133 -89.61 0

rotation 0 -0.7071 -0.7071 -3.142

scale 1 1 1

scaleOrientation -0.5986 -0.2112 -0.7727 -0.8261

children [ USE HourBox ]

},

DEF Box08-ROOT Transform {

translation 44.75 -77.58 0

rotation 0.1862 -0.6947 -0.6947 -3.51

scale 1 1 1

scaleOrientation -0.4808 -0.3435 -0.8067 -0.3658

children [ USE HourBox ]

},

DEF Box09-ROOT Transform {

translation 77.61 -44.73 0

rotation 0.378 -0.6547 -0.6547 -3.864

scale 1 1 1

scaleOrientation 0.309 -0.1568 -0.938 -0.1556

children [ USE HourBox ]

},

DEF Box10-ROOT Transform {

translation 89.64 0.1482 0

rotation -0.5774 0.5774 0.5774 -2.094

scale 1 1 1

scaleOrientation 0.7864 -0.2441 -0.5674 -0.2538

children [ USE HourBox ]

},

DEF Box11-ROOT Transform {

translation 77.61 45.03 0

rotation -0.7746 0.4472 0.4472 -1.823

scale 1 1 1

scaleOrientation 0.428 -0.851 0.3045 -0.2253

children [ USE HourBox ]

},

DEF Box12-ROOT Transform {

translation 44.76 77.89 0

rotation -0.9351 0.2506 0.2506 -1.638

scale 1 1 1

scaleOrientation 0 -0.9673 0.2538 -0.4808

children [ USE HourBox ]

},

DEF HourHand Transform {

translation 0 0 2.5

children [

Shape {

appearance Appearance {

material Material {

diffuseColor 0.01 0.01 0.01

shininess 0.8
}
      }
      geometry DEF Clock01_hour-FACES IndexedFaceSet {
        ccw TRUE
        solid TRUE
        coord DEF Clock01_hour-COORD Coordinate { point [
          0 67.07 0, 5 0 -0.4808, -5 0 -0.4808, -5 0 0.4808, 5 0 0.4808,
          0 -7.071 0]
        }
        coordIndex [
          0, 4, 1, -1, 1, 5, 2, -1, 2, 3, 0, -1, 3, 5, 4, -1,
          1, 2, 0, -1, 3, 4, 0, -1, 4, 5, 1, -1, 3, 2, 5, -1]
        }
    }
  ]
},
DEF MinuteHand Transform {
  translation 0 0 5
  children [
    Shape {
      appearance Appearance {
        material Material {
          diffuseColor 0 0 1
          shininess 0.8

        }
      }
      geometry DEF Clock01_min-FACES IndexedFaceSet {
        ccw TRUE
        solid TRUE
        coord DEF Clock01_min-COORD Coordinate { point [
          0 92.07 0, 5 0 -0.4808, -5 0 -0.4808, -5 0 0.4808, 5 0 0.4808,
          0 -7.071 0]
        }
        coordIndex [
          0, 4, 1, -1, 1, 5, 2, -1, 2, 3, 0, -1, 3, 5, 4, -1,
          1, 2, 0, -1, 3, 4, 0, -1, 4, 5, 1, -1, 3, 2, 5, -1]
        }
    }
  ]
},
DEF SecondHand Transform {
  translation 0 0 7.5
  children [
    Shape {
      appearance Appearance {
        material Material {
          diffuseColor 1 0 0
          shininess 0.8
          
        }
      }
      geometry DEF Clock01_sec-FACES IndexedFaceSet {
        ccw TRUE
        solid TRUE
        coord DEF Clock01_sec-COORD Coordinate { point [
          0 88.54 0, 2.5 0 -0.2456, -2.5 0 -0.2456, -2.5 0 0.2456,
          2.5 0 0.2456, 0.0798 -20.14 0]
        }
        coordIndex [
          0, 4, 1, -1, 1, 5, 2, -1,
          2, 3, 0, -1, 3, 5, 4, -1, 1, 2, 0, -1, 3, 4, 0, -1,
          4, 5, 1, -1, 3, 2, 5, -1]
        }
    }
  ]
},

Hour Script

DEF HourScript Script {
  url "./clock.js"
  eventIn  SFTime     set_hour
  eventOut SFRotation value_changed
  eventOut MFString   string_changed
}

Minute Script

DEF MinuteScript Script {
  url "./clock.js"
  eventIn  SFTime     set_minute
  eventOut SFRotation value_changed
  eventOut MFString   string_changed
}

Second Script

DEF SecondScript Script {
  url "./clock.js"
  eventIn  SFTime     set_second
  eventOut SFRotation value_changed
  eventOut MFString   string_changed
}

ROUTE Clock.time TO SecondScript.set_second
ROUTE Clock.time TO MinuteScript.set_minute
ROUTE Clock.time TO HourScript.set_hour

ROUTE SecondScript.value_changed TO SecondHand.set_rotation
ROUTE MinuteScript.value_changed TO MinuteHand.set_rotation
ROUTE HourScript.value_changed TO HourHand.set_rotation

ROUTE SENSOR.isOver TO CLOCK.set_enabled
ROUTE CLOCK.fraction_changed TO MOVER.set_fraction
ROUTE MOVER.value_changed TO TUBE.set_translation

Codigo  url clock.js

function set_hour(time, eventTime) {

var dat = new Date();

var hour = dat.getHours();
value_changed[0] = 0;
value_changed[1] = 0;
value_changed[2] = -1;
value_changed[3] = (hour + dat.getMinutes() / 60.0 + dat.getSeconds() / 3600.0) * Math.PI / 6.0;

}

function set_minute(time, eventTime) {

var dat = new Date();

var min = dat.getMinutes();
value_changed[0] = 0;
value_changed[1] = 0;
value_changed[2] = -1;
value_changed[3] = (min + dat.getSeconds() / 60.0) * Math.PI / 30.0;

}

function set_second(time, eventTime) {

var dat = new Date();

var sec = dat.getSeconds();
value_changed[0] = 0;
value_changed[1] = 0;
value_changed[2] = -1;
value_changed[3] = ((dat.getTime() / 1000.0) % 60.0) * Math.PI / 30.0;

}

Criado 26 de abril de 2012
Respostas 0
Participantes 1