This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > January 2004 > CosmoPlayer - dynamically switching background colors





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author CosmoPlayer - dynamically switching background colors
PrisNo6

2004-01-04, 6:29 pm

I am conforming a world developed initially in Cortona for
compatability with CosmoPlayer. One feature dynamically switches the
background colors of the world. After testing, it appears that
CosmoPlayer does not support the set_bind method for backgrounds, so
backgrounds cannot be dynamically changed with CosmoPlayer.

I wanted to confirm this with experienced VRML programers. A testing
code snippet follows which uses the set_bind method. (I also tried an
option group with the same results).

=======================================

#VRML V2.0 utf8
# Set background tester 1/2004

# =========================================================================
# SCENE ENVIRONMENT CHARACTERISTICS
# Initial background

DEF WORLD_BACKGROUND Group {

children [

# version 0: White universe
DEF WhiteBack Background {
skyColor [ 1.0 1.0 1.0, 1.0 1.0 1.0, 1.0 1.0 1.0 ]
skyAngle [ 1.0, 1.0 ]
groundColor [ 1.0 1.0 1.0, 1.0 1.0 1.0, 1.0 1.0 1.0 ]
groundAngle [ 1.0, 1.0 ]
} # End of background

# version 1: Gray universe
DEF GrayBack Background {
skyColor [ 0.9 0.9 0.9, 0.9 0.9 0.9, 0.9 0.9 0.9 ]
skyAngle [ 1.0, 1.0 ]
groundColor [ 0.9 0.9 0.9, 0.9 0.9 0.9, 0.9 0.9 0.9 ]
groundAngle [ 1.0, 1.0 ]
} # End of background

# version 2: Black universe
DEF BlackBack Background {
skyColor [ 0.0 0.0 0.0, 0.0 0.0 0.0, 0.0 0.0 0.0 ]
skyAngle [ 1.0, 1.0 ]
groundColor [ 0.0 0.0 0.0, 0.0 0.0 0.0, 0.0 0.0 0.0 ]
groundAngle [ 1.0, 1.0 ]
} # End of background


# version 3: Red universe
DEF RedBack Background {
skyColor [ 0.6 0.0 0.0, 0.6 0.0 0.0, 0.6 0.0 0.0 ] # Dark red.
Pure red is 1.0
skyAngle [ 1.0, 1.0 ]
groundColor [ 0.6 0.0 0.0, 0.6 0.0 0.0, 0.6 0.0 0.0 ]
groundAngle [ 1.0, 1.0 ]
} # End of background


] # end children WORLD_BACKGROUND
} # end Group WORLD_BACKGROUND


# Navigation
NavigationInfo {
type "EXAMINE"
speed 1.0
headlight FALSE
avatarSize [ 0.005, 0.005, 0.005 ]
} # End of Navigation

# Directional lighting
# From the plane right to re-enforce the direction of the Galactic
Core
# In normal Galactic orientation ( +x to Galactic Core;
+y to Cyngus)
# this makes the scene appear to be lighted by the
Galacitc Core and
# aids in interpreting the orientation of the scene
# A reduced z plane angle (lower than 45 deg), enforces
this theme

# Description result after
rotating
# verison 0: Ahead
DirectionalLight {
# 'Astronomical' orientation
# y z x
direction 0.0 0.0 -1.0 # on the x-plane, x-axis
ambientIntensity 0.5
} # End of Directional lighting

# ===============================
# Binder switch

# Control item button
DEF Control_Button_A TouchSensor { }
DEF Control_Button_Cylinder_A Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 1.0 1.0
transparency .7
} # end Material
} # end Appearance
geometry Cylinder { radius .3 height 0.7 }
} # end Shape Control_Button_Cylinder
# Control item button sensor
DEF Control_Filter_A Script { # On/Off toggle switch without memory
eventIn SFBool set_boolean
url [ "java script:
function set_boolean ( bool, eventTime ) {
// if ( bool == false ) { return; }
if ( bool == true ) { Control_choice = 1; }
}"
]
eventOut SFInt32 Control_choice
eventOut SFBool bool
} # End Control_Filter Script
# Filter script routers are outside end children for Cosmoplayer 2.1
compatability
ROUTE Control_Button_A.isActive TO Control_Filter_A.set_boolean
# KEY ROUTING STATEMENT TO CONTROL DISPLAY OF THIS OBJECT
# ROUTE Control_Filter_A.Control_choice TO
WORLD_BACKGROUND.set_whichChoice
ROUTE Control_Filter_A.bool TO GrayBack.set_bind
# ROUTE Control_Filter_A.Control_choice TO
OPTION_INDICATOR_2.set_whichChoice
Cecile Muller

2004-01-05, 8:28 am

> After testing, it appears that
quote:

> CosmoPlayer does not support the set_bind method for backgrounds, so
> backgrounds cannot be dynamically changed with CosmoPlayer.




The example below works fine in CosmoPlayer too:
--------------
#VRML V2.0 utf8

Background{skyColor 0 1 0}
DEF bg2 Background{skyColor 1 0 0}

Group{
children [
DEF TS TouchSensor{}
Shape{
appearance Appearance{material Material{emissiveColor 0 0 0.2}}
geometry Box{}
}
]
}
DEF brain Script{
field SFNode bg USE bg2
eventIn SFTime touchTime
directOutput TRUE
url "java script:
function touchTime(){bg.set_bind = true;}
"
}
ROUTE TS.touchTime TO brain.touchTime
Viewpoint{}
-------------
PrisNo6

2004-01-05, 6:30 pm

spam@wildpeaks.com (Cecile Muller) wrote in message news:<aff31ac6.0401050418.40018036@posting.google.com>...

Thanks Cecile, looks like the trick is pass the background node inside
the script. I'll give that approach a try. - Kurt
quote:

> The example below works fine in CosmoPlayer too:
> --------------
> #VRML V2.0 utf8 #<snip>
> DEF brain Script{
> field SFNode bg USE bg2 // <snip>
> function touchTime(){bg.set_bind = true;} //<snip>


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews