| iejat 2005-02-21, 11:18 pm |
| thanks MUFTI...here i found an object that can rotate and translate
together (we can rotate the object after we move the slider)...but
there're something wrong about the rotation of the object...can you find
what's wrong??...thanks
#VRML V2.0 utf8
# object - microwave
#Cosmo Worlds V2.0
PROTO SliderPot [
eventOut SFFloat value_changed
field SFFloat scaleFactor 1
field SFFloat centerDetent 0.05
field SFFloat initialValue 0
]
{
Transform {
children [
Shape {
appearance Appearance {
material Material {
ambientIntensity 1
diffuseColor 1 1 1
shininess 0
}
}
geometry DEF _0 IndexedFaceSet {
coord Coordinate {
point [ -1.5 -5 0,
-0.25 -5 0,
0.25 -5 0,
1.5 -5 0,
-0.25 -4 0,
0.25 -4 0,
-0.25 4 0,
0.25 4 0,
-1.5 5 0,
-0.25 5 0,
0.25 5 0,
1.5 5 0 ]
}
coordIndex [ 0, 1, 9, 8, -1, 2, 3, 11,
10, -1, 1, 2, 5, 4, -1, 6,
7, 10, 9, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
DEF Handle_1 Transform {
children [
DEF PS_2 PlaneSensor {
minPosition 0 -4
maxPosition 0 4
}
Shape {
appearance Appearance {
material Material {
ambientIntensity 0.486
}
}
geometry Box {
}
}
]
translation 0 0 0
}
DEF DisplayScript_3 Script {
eventIn SFVec3f set_translation
eventOut MFString display_string
eventOut SFVec3f translation_changed
eventOut SFFloat value_changed IS value_changed
field SFFloat scaleFactor IS scaleFactor
field SFFloat centerDetent IS centerDetent
field SFFloat initialValue IS initialValue
field SFFloat val 0
url "java script:
// This is necessary because at the time the PROTO is initialized
// the event to the main world seems to get lost in Cosmo Player 2.1
function set_the_translation(value) {
val = value * 0.25 * scaleFactor;
if (Math.abs(val) < centerDetent)
val = 0.0;
if (val == 0) {
display_string[0] = val.toString();
} else if (val < 0) {
display_string[0] = val.toString().substring(0,5);
} else {
display_string[0] = val.toString().substring(0,4);
}
translation_changed = new SFVec3f(0, value, 0);
}
function set_translation(value) {
set_the_translation(value.y);
value_changed = val;
}
function initialize() {
set_translation(new SFVec3f(0, 4.0 * initialValue/scaleFactor, 0));
}
"
}
]
translation 0 0 -0.15
scale 0.003 0.003 0.003
}
ROUTE DisplayScript_3.translation_changed TO Handle_1.set_translation
ROUTE PS_2.translation_changed TO DisplayScript_3.set_translation
}
DEF M_Wave Transform {
children [
WorldInfo {
title "m_wave.wrl"
info [ "(c)1997 3NAME3D/Yglesias Wallock Divekar, Inc.",
"VRMLProps is a trademark of Yglesias Wallock Divekar, Inc." ]
}
DEF Control Script {
eventIn SFTime set_powerTime
eventIn SFBool set_powerTimeOff
eventIn SFTime set_openTime
eventIn SFBool set_openTimeOff
eventIn SFTime set_closeTime
eventIn SFBool set_closeTimeOff
eventOut SFTime powerTime_changed
eventOut SFTime openTime_changed
eventOut SFTime closeTime_changed
field SFBool power FALSE
field SFBool open FALSE
field SFBool close TRUE
url "vrmlscript:
function set_powerTime(value, time) {
if (close && !open) {
power = TRUE;
powerTime_changed = time;
}
}
function set_powerTimeOff(value, time) {
if (!value) { power = FALSE; }
}
function set_openTime(value, time) {
if (!open && !power) {
open = TRUE;
openTime_changed = time;
}
}
function set_openTimeOff(value, time) {
if (!value) { close = FALSE; }
}
function set_closeTime(value, time) {
if (!close) {
close = TRUE;
closeTime_changed = time;
}
}
function set_closeTimeOff(value, time) {
if (!value) { open = FALSE; }
}"
}
Transform {
children [
Transform {
children DEF Ypot SliderPot {
initialValue 1
}
translation 0.215598 0.416003 -0.0351051
rotation -0.999809 -0.0136028 -0.014036 1.53979
scale 2.20108 2.20108 2.20108
scaleOrientation 0.999921 0.00750507 0.0101078 3.92701
}
Transform {
children DEF Zpot SliderPot {
}
translation 0.190455 0.404558 -0.0216213
rotation -0.999809 -0.0136028 -0.014036 1.53979
scale 2.20108 2.20108 2.20108
}
Transform {
children DEF Rpot SliderPot {
scaleFactor 3.14159
centerDetent 0.2
}
translation -0.185288 0.0481212 0.759178
rotation 0.261672 -0.96479 -0.0266176 0.028194
scale 5.04035 5.04035 5.04035
scaleOrientation -0.273434 -0.775109 0.569596 0.0194579
}
]
}
Transform {
children DEF Geom Group {
children [
Transform {
children DEF BoxExterior Shape {
appearance Appearance {
material DEF Ext_Color Material {
ambientIntensity 0.655
diffuseColor 1 1 1
specularColor 1 1 1
shininess 0.616
}
}
geometry DEF _10 IndexedFaceSet {
coord Coordinate {
point [ 0.2286 0 0.1226,
0.2286 0.2286 0.1226,
-0.2286 0.2286 0.1226,
-0.2286 0 0.1226,
0.2286 0 -0.1695,
0.2286 0.2286 -0.1695,
-0.2286 0.2286 -0.1695,
-0.2286 0 -0.1695 ]
}
coordIndex [ 3, 7, 4, 0, -1, 7, 6, 5,
4, -1, 2, 6, 7, 3, -1, 1,
5, 6, 2, -1, 0, 4, 5, 1,
-1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF BoxFront Shape {
appearance Appearance {
material USE Ext_Color
}
geometry DEF _11 IndexedFaceSet {
coord Coordinate {
point [ -0.2286 0 0.1226,
-0.2032 0.0254 0.1226,
-0.2032 0.2032 0.1226,
-0.2286 0.2286 0.1226,
0.1016 0.2032 0.1226,
0.127 0.2286 0.1226,
0.127 0 0.1226,
0.1016 0.0254 0.1226 ]
}
coordIndex [ 0, 1, 2, 3, -1, 4, 5, 3,
2, -1, 6, 5, 4, 7, -1, 0,
6, 7, 1, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF BoxInside Shape {
appearance Appearance {
material DEF InsideColor Material {
ambientIntensity 0
diffuseColor 0.3085 0.3085 0.3085
emissiveColor 0 0 0
}
}
geometry DEF _13 IndexedFaceSet {
coord Coordinate {
point [ 0.1016 0.0254 0.1226,
0.1016 0.2032 0.1226,
-0.2032 0.2032 0.1226,
-0.2032 0.0254 0.1226,
0.1016 0.0254 -0.1314,
0.1016 0.2032 -0.1314,
-0.2032 0.2032 -0.1314,
-0.2032 0.0254 -0.1314 ]
}
coordIndex [ 5, 1, 2, 6, -1, 6, 2, 3,
7, -1, 4, 5, 6, 7, -1, 1,
5, 4, 0, -1, 0, 4, 7, 3,
-1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF FrontPanel Shape {
appearance Appearance {
material Material {
ambientIntensity 0.25
diffuseColor 0.55 0.55 0.55
specularColor 0.27 0.27 0.27
emissiveColor 0.15 0.15 0.15
shininess 0
transparency 0
}
}
geometry DEF _14 IndexedFaceSet {
coord Coordinate {
point [ 0.2286 0 0.1226,
0.2286 0.2286 0.1226,
0.127 0.2286 0.1226,
0.127 0 0.1226,
0.127 0 0.148,
0.127 0.2286 0.148,
0.2286 0.2286 0.148,
0.2286 0 0.148 ]
}
coordIndex [ 4, 3, 0, 7, -1, 7, 0, 1,
6, -1, 7, 6, 5, 4, -1, 6,
1, 2, 5, -1, 3, 4, 5, 2,
-1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children [
DEF ButtonMove Transform {
children [
DEF Button Shape {
appearance Appearance {
material Material {
ambientIntensity 1.904
diffuseColor 0 0 0
specularColor 0.925413 0.949175 1
shininess 0.1273
}
}
geometry DEF _16 IndexedFaceSet {
coord Coordinate {
point [ 0.1381 0.07646 0.1536,
0.1381 0.03494 0.1645,
0.2185 0.03494 0.1645,
0.2185 0.07646 0.1536,
0.1381 0.07646 0.148,
0.1381 0.03494 0.148,
0.2185 0.03494 0.148,
0.2185 0.07646 0.148 ]
}
coordIndex [ 2, 3, 0, 1, -1, 6, 2, 1,
5, -1, 3, 2, 6, 7, -1, 4,
0, 3, 7, -1, 4, 5, 1, 0,
-1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
DEF OpenTouch TouchSensor {
}
]
translation 0.00254779 -0.040069 -0.0020298
rotation 0 0 1 0
scale 0.459114 0.459114 0.459114
scaleOrientation 0.862856 -0.357407 0.357407 2.53533
center 0.1783 0.07005 0.1509
}
Transform {
children Shape {
appearance Appearance {
material Material {
ambientIntensity 0
diffuseColor 0 0 0
specularColor 0.29 0.3 0.29
emissiveColor 0 0 0
shininess 0.08
transparency 0
}
}
geometry Text {
fontStyle FontStyle {
}
string "Open"
}
}
translation 0.164742 0.0210674 0.159431
rotation 0 0 1 0
scale 0.015935 0.015935 0.015935
scaleOrientation -0.00291248 -0.999996 0.000201022 0.0742102
}
]
}
DEF KnobMove Transform {
children [
DEF PowerTouch TouchSensor {
}
Transform {
children DEF KnobArrow Shape {
appearance Appearance {
material Material {
ambientIntensity 0.256
diffuseColor 0.1553 0.1509 0.1517
specularColor 0.5283 0.5244 0.5245
shininess 0.102
}
}
geometry DEF _20 IndexedFaceSet {
coord Coordinate {
point [ 0.1778 0.1823 0.1595,
0.1906 0.1309 0.1595,
0.165 0.1309 0.1595,
0.1778 0.1823 0.1695,
0.1906 0.1309 0.1695,
0.165 0.1309 0.1695 ]
}
coordIndex [ 5, 4, 3, -1, 2, 5, 3, 0,
-1, 5, 2, 1, 4, -1, 4, 1,
0, 3, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF KnobBack Shape {
appearance Appearance {
material Material {
ambientIntensity 1.904
diffuseColor 0.4127 0.455 0.4727
specularColor 0.4206 0.4314 0.4545
shininess 0.1273
}
}
geometry DEF _21 IndexedFaceSet {
coord Coordinate {
point [ 0.1778 0.1203 0.148,
0.1604 0.1249 0.148,
0.1476 0.1377 0.148,
0.143 0.1551 0.148,
0.1476 0.1725 0.148,
0.1604 0.1853 0.148,
0.1778 0.1899 0.148,
0.1952 0.1853 0.148,
0.208 0.1725 0.148,
0.2126 0.1551 0.148,
0.208 0.1377 0.148,
0.1952 0.1249 0.148,
0.1778 0.1203 0.1591,
0.1604 0.1249 0.1591,
0.1476 0.1377 0.1591,
0.143 0.1551 0.1591,
0.1476 0.1725 0.1591,
0.1604 0.1853 0.1591,
0.1778 0.1899 0.1591,
0.1952 0.1853 0.1591,
0.208 0.1725 0.1591,
0.2126 0.1551 0.1591,
0.208 0.1377 0.1591,
0.1952 0.1249 0.1591 ]
}
coordIndex [ 23, 11, 10, 22, -1, 22, 10, 9,
21, -1, 21, 9, 8, 20, -1, 20,
8, 7, 19, -1, 19, 7, 6, 18,
-1, 18, 6, 5, 17, -1, 17, 5,
4, 16, -1, 16, 4, 3, 15, -1,
15, 3, 2, 14, -1, 14, 2, 1,
13, -1, 13, 1, 0, 12, -1, 12,
0, 11, 23, -1, 21, 20, 19, 18,
-1, 17, 16, 15, 18, -1, 15, 14,
13, 12, -1, 15, 12, 21, 18, -1,
12, 23, 22, 21, -1 ]
creaseAngle 0.6109
normalIndex [ ]
texCoordIndex [ ]
}
}
}
]
translation -0.000644624 0.0265008 2.97132e-008
rotation 0 0 1 0
center 0.1778 0.1551 0.1587
}
DEF DoorMove Transform {
children [
DEF CloseTouch TouchSensor {
}
Transform {
children DEF DoorGlass Shape {
appearance Appearance {
material Material {
ambientIntensity 0.25
diffuseColor 0.1524 0.1451 0.1528
specularColor 0.7455 0.7455 0.7455
shininess 0.9576
transparency 0.2548
}
}
geometry DEF _24 IndexedFaceSet {
coord Coordinate {
point [ 0.07166 0.0508 0.148,
0.07166 0.1778 0.148,
0.07166 0.0508 0.1226,
0.07166 0.1778 0.1226,
-0.1786 0.1778 0.148,
-0.1786 0.0508 0.148,
-0.1786 0.1778 0.1226,
-0.1786 0.0508 0.1226 ]
}
coordIndex [ 2, 7, 6, 3, -1, 5, 0, 1,
4, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF DoorMain Shape {
appearance Appearance {
material Material {
ambientIntensity 0.25
diffuseColor 1 1 1
specularColor 0 0 0
emissiveColor 0 0 0
shininess 0
transparency 0
}
}
geometry DEF _25 IndexedFaceSet {
coord Coordinate {
point [ -0.2286 0.2286 0.1226,
-0.2286 0 0.1226,
0.07166 0.0508 0.148,
0.07166 0.1778 0.148,
0.07166 0.0508 0.1226,
0.07166 0.1778 0.1226,
-0.1786 0.1778 0.148,
-0.1786 0.0508 0.148,
-0.1786 0.1778 0.1226,
-0.1786 0.0508 0.1226,
-0.2286 0.2286 0.148,
0.1217 0.2286 0.148,
-0.2286 0 0.148,
0.1217 0 0.148,
0.1217 0.2286 0.1226,
0.1217 0 0.1226 ]
}
coordIndex [ 10, 12, 7, 6, -1, 11, 10, 6,
3, -1, 13, 11, 3, 2, -1, 12,
13, 2, 7, -1, 12, 1, 15, 13,
-1, 14, 11, 13, 15, -1, 0, 10,
11, 14, -1, 1, 12, 10, 0, -1,
15, 1, 9, 4, -1, 14, 15, 4,
5, -1, 14, 5, 8, 0, -1, 8,
9, 1, 0, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
Transform {
children DEF DoorInside Shape {
appearance Appearance {
material DEF Door2Color Material {
ambientIntensity 0.25
diffuseColor 0 0 0.04254
emissiveColor 0 0 0
}
}
geometry DEF _27 IndexedFaceSet {
coord Coordinate {
point [ 0.07166 0.0508 0.1226,
0.07166 0.0508 0.148,
0.07166 0.1778 0.148,
0.07166 0.1778 0.1226,
-0.1786 0.1778 0.148,
-0.1786 0.1778 0.1226,
-0.1786 0.0508 0.1226,
-0.1786 0.0508 0.148 ]
}
coordIndex [ 0, 1, 2, 3, -1, 4, 5, 3,
2, -1, 6, 7, 1, 0, -1, 5,
4, 7, 6, -1 ]
normalIndex [ ]
texCoordIndex [ ]
}
}
}
]
rotation 0 0 1 0
center -0.2288 0.1143 0.1226
}
Transform {
children Shape {
appearance Appearance {
material Material {
ambientIntensity 0
diffuseColor 0.28 0.28 0.28
specularColor 0.241667 0.25 0.241667
emissiveColor 0.27 0.27 0.27
shininess 0.08
transparency 0
}
}
geometry DEF _28 IndexedFaceSet {
coord Coordinate {
point [ -0.722224 -1.66667 -0.00611992,
-0.722224 1.11111 0.000270224,
0.833332 1.11111 3.08521e-005,
0.78655 -1.66666 -0.00180069 ]
}
coordIndex [ 0, 1, 2, 3, -1 ]
solid FALSE
normalIndex [ ]
texCoordIndex [ ]
}
}
translation 0.186238 0.0734769 0.154947
rotation 0.707098 0.707098 0.00497661 3.14321
scale 0.0288606 0.0288607 0.0288606
scaleOrientation 0.0686504 -0.997629 -0.00478076 0.129479
}
]
}
translation 0 0 0
rotation -1 0 0 1.57
}
Transform {
children DEF Animations Group {
children [
Transform {
children DEF PowerOn Group {
children [
DEF PowerTime TimeSensor {
startTime 0
cycleInterval 3
}
DEF InsideEColorInterp ColorInterpolator {
key [ 0, 0.1333, 0.1333, 1,
1 ]
keyValue [ 0 0 0,
0 0 0,
0.7553 0.7553 0.7553,
0.7553 0.7553 0.7553,
0 0 0 ]
}
DEF Door-1aEColorInterp ColorInterpolator {
key [ 0, 0.1333, 0.1333, 1,
1 ]
keyValue [ 0 0 0,
0 0 0,
0.5851 0.5851 0.5851,
0.5851 0.5851 0.5851,
0.01064 0.01064 0.01064 ]
}
DEF KnobRotInterp OrientationInterpolator {
key [ 0, 0.1333, 1 ]
keyValue [ 0 0 1 0,
0 0 -1 1.192,
0 0 1 0 ]
}
]
}
}
Transform {
children DEF DoorOpen Group {
children [
DEF OpenTime TimeSensor {
startTime 0
cycleInterval 1
}
DEF ButtonRotInterp1 OrientationInterpolator {
key [ 0, 0.1 ]
keyValue [ 0 0 1 0,
1 0 0 0.1918 ]
}
DEF ButtonTransInterp1 PositionInterpolator {
key [ 0, 0.1 ]
keyValue [ 0 0 0,
0 0.0007302 -0.003759 ]
}
DEF DoorRotInterp1 OrientationInterpolator {
key [ 0, 0.1, 1 ]
keyValue [ 0 0 1 0,
0 0 1 0,
0 1 0 4.465 ]
}
]
}
}
Transform {
children DEF DoorClose Group {
children [
DEF CloseTime TimeSensor {
startTime 0
cycleInterval 1
}
DEF ButtonRotInterp2 OrientationInterpolator {
key [ 0, 0.95, 1 ]
keyValue [ 1 0 0 0.1918,
1 0 0 0.1918,
0 0 1 0 ]
}
DEF ButtonTransInterp2 PositionInterpolator {
key [ 0, 0.95, 1 ]
keyValue [ 0 0.0007302 -0.003759,
0 0.0007302 -0.003759,
0 0 0 ]
}
DEF DoorRotInterp2 OrientationInterpolator {
key [ 0, 1 ]
keyValue [ 0 1 0 4.465,
0 0 1 0 ]
}
]
}
}
]
}
}
]
translation 0 0 0
rotation -1 0 0 1.57
}
DEF PSMWave PlaneSensor {
minPosition -5 -5
maxPosition 5 5
}
DEF ConstRotation Script {
eventIn SFFloat setX
eventIn SFFloat setY
eventIn SFFloat setZ
eventIn SFFloat setR
eventOut SFRotation rotation_changed
eventOut MFVec3f point_changed
field SFRotation r 0 0 1 0
url "java script:
function setX(value) {
r.x = value;
}
function setY(value) {
r.y = value;
}
function setZ(value) {
r.z = value;
}
function setR(value) {
r.angle = value;
}
function eventsProcessed() {
rotation_changed = r;
point_changed = new MFVec3f (
new SFVec3f(-r.x, -r.y, -r.z), new SFVec3f(r.x, r.y, r.z));
Browser.setDescription('rotation '+r.toString());
}
"
}
ROUTE PowerTouch.touchTime TO Control.set_powerTime
ROUTE PowerTime.isActive TO Control.set_powerTimeOff
ROUTE OpenTouch.touchTime TO Control.set_openTime
ROUTE OpenTime.isActive TO Control.set_openTimeOff
ROUTE CloseTouch.touchTime TO Control.set_closeTime
ROUTE CloseTime.isActive TO Control.set_closeTimeOff
ROUTE InsideEColorInterp.value_changed TO InsideColor.set_emissiveColor
ROUTE ButtonTransInterp1.value_changed TO ButtonMove.set_translation
ROUTE ButtonTransInterp2.value_changed TO ButtonMove.set_translation
ROUTE ButtonRotInterp1.value_changed TO ButtonMove.set_rotation
ROUTE ButtonRotInterp2.value_changed TO ButtonMove.set_rotation
ROUTE KnobRotInterp.value_changed TO KnobMove.set_rotation
ROUTE Door-1aEColorInterp.value_changed TO Door2Color.set_emissiveColor
ROUTE DoorRotInterp1.value_changed TO DoorMove.set_rotation
ROUTE DoorRotInterp2.value_changed TO DoorMove.set_rotation
ROUTE Control.powerTime_changed TO PowerTime.set_startTime
ROUTE PowerTime.fraction_changed TO InsideEColorInterp.set_fraction
ROUTE PowerTime.fraction_changed TO Door-1aEColorInterp.set_fraction
ROUTE PowerTime.fraction_changed TO KnobRotInterp.set_fraction
ROUTE Control.openTime_changed TO OpenTime.set_startTime
ROUTE OpenTime.fraction_changed TO ButtonRotInterp1.set_fraction
ROUTE OpenTime.fraction_changed TO ButtonTransInterp1.set_fraction
ROUTE OpenTime.fraction_changed TO DoorRotInterp1.set_fraction
ROUTE Control.closeTime_changed TO CloseTime.set_startTime
ROUTE CloseTime.fraction_changed TO ButtonRotInterp2.set_fraction
ROUTE CloseTime.fraction_changed TO ButtonTransInterp2.set_fraction
ROUTE CloseTime.fraction_changed TO DoorRotInterp2.set_fraction
ROUTE PSMWave.translation_changed TO M_Wave.set_translation
ROUTE ConstRotation.rotation_changed TO M_Wave.set_rotation
ROUTE Ypot.value_changed TO ConstRotation.setY
ROUTE Zpot.value_changed TO ConstRotation.setZ
ROUTE Rpot.value_changed TO ConstRotation.setR
|