ParallelGraphics Forums
General
You are here: [Forums]::[General]

Registration 
Registration
Forgot your password?

Help 
Help
Support

Quick search 

Subscribe to newsletters 

Install Cortona VRML Client for FREE!
Outline 3D
Try RobinZone!
email:  password:
  General

Subject: Small Problem
Sender: tjames221188@hotmail.com 20.12.07 00:57

Hi everyone,

I have recently been given an assignment on VRML.
In this particular excercise I have been asked to:

make 5 bouncing balls with different heights and colours, all starting upon a single click of any of the balls.

I have managed to make them start individually but i cannot figure out how to make them all start at once.

Here is what I have so far:

#VRML V2.0 utf8

PROTO BouncingBall [
    field SFFloat BounceHeight 1.0
    field SFFloat BallStartHeight 0.0
    field SFColor BallColor 1.0 1.0 1.0
]{
    DEF    Ball Transform{
        children [
            Shape {    
                appearance Appearance {
                material Material {
                diffuseColor IS    BallColor
                }
            }
            geometry Sphere    {
                radius 1.0
            }
        }
        
        ]
    }

    DEF Clock TimeSensor {
        cycleInterval 2.0
        startTime -1.0
        stopTime 0.0
        loop TRUE
    
    }
    DEF    Bouncer Script {
        field SFFloat BounceHeight IS BounceHeight
        field SFFloat BallStartHeight IS BallStartHeight
eventIn SFFloat set_fraction
eventOut SFVec3f value_changed

# change 'vrmlscript' to 'javascript' for newer browsers
url "vrmlscript:
function set_fraction( frac, tm ) {
y = (4.0 * BounceHeight * frac * (1.0 - frac) + BallStartHeight);
                value_changed[0] = 0.0;
value_changed[1] = y;
value_changed[2] = 0.0;
}"
        }
        DEF    Touch TouchSensor { }
        ROUTE Touch.touchTime TO Clock.set_startTime
        ROUTE Clock.fraction_changed TO    Bouncer.set_fraction
        ROUTE Bouncer.value_changed    TO Ball.set_translation
    }

    Group    {
        children [
    Transform {
        translation    -6.0 0.0 0.0
        children DEF Ball1 BouncingBall {
                BallColor 1.0 0.0 0.0
                BounceHeight 4.0
                BallStartHeight    -3.0
                }
                }
    Transform {
        translation    -3.0 0.0 0.0
        children DEF Ball2 BouncingBall {
                BallColor 1.0 1.0 0.0
                BallStartHeight    -3.0
                BounceHeight 5.0
                }
                }
    Transform {
        translation    0.0 0.0 0.0
        children DEF Ball3 BouncingBall {
            BallColor 0.0 1.0 0.0
            BallStartHeight    -3.0
            BounceHeight 8.0
        }
    }
    Transform {
        translation    3.0 0.0 0.0
        children DEF Ball4 BouncingBall {
            BallColor 0.5 0.2 0.0
            BallStartHeight    -3.0
            BounceHeight 3.5
        }
    }
    Transform {
        translation    6.0 0.0 0.0
        children DEF Ball5 BouncingBall {
            BallColor 0.0 0.0 1.0
            BallStartHeight    -3.0
            BounceHeight 6.2
        }
    }
    DEF    Touch TouchSensor {}
    ]
}

Any help you can give is much appreciated,

Thankyou for your time,

Toby James

 


Small Problem / tjames221188@hotmail.com / 20.12.07 00:57
     Re: Small Problem / Uh / 20.12.07 02:46
         Re: Small Problem / tjames221188@hotmail.com / 20.12.07 03:00

Messages in thread: 3


© 1998-2007 ParallelGraphics. All rights reserved. Terms of use.