public void updateColor(double R, double G, double B) {
ColorBvr newClr = colorRgb(toBvr(R),toBvr(G),toBvr(B));
sphereClrSw.switchTo(newClr);
}
Set up a simple model consisting of a sphere whose color can be switched
upon notification. |
class VBScriptModel extends Model {
public void createModel(BvrsToRun blist)
{
URL geoBase = buildURL(getImportBase(), "../../../../../Media/geometry/");
Create the sphere's initial color. |
ColorBvr initClr = colorRgb(1,1,1);
Create a switcher behavior that will change whenever the scrollbars
update the color. |
sphereClrSw = new ModifiableBehavior(initClr);
Create a sphere and apply sphereClrSw's behavior to it |
GeometryBvr sphereGeo =
importGeometry(buildURL(geoBase,"sphere.x"));
GeometryBvr coloredSphereGeo =
sphereGeo.diffuseColor((ColorBvr)sphereClrSw.getBvr());
Create a camera and light to render sphere. |
CameraBvr Cam =
perspectiveCamera(toBvr(1),toBvr(0)).transform(
translate(0,0,50) );
GeometryBvr lightGeo =
directionalLight.transform(
translate(0,0,4));
Display the color changing sphere. |
setImage(overlay(
union(coloredSphereGeo, lightGeo).render(Cam),
solidColorImage(white)));
}
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.