GeometryBvr scoops =
scoopGeo.transform(
compose(rotate(yVector3, mul(toBvr(8),windDistance)),
scale3(toBvr(1.25))));
Combine these to form the complete weather vane (our first
DirectAnimation module). |
return union(arrow, union(scoops, union(nsewGeo, directionalLight)));
}
}
Back in the lhouseModel class, use the getGeo() model to construct
the vane, and transform it to match the perspective of the scene. |
GeometryBvr vane =
weatherVane.getGeo(windAngle,windDistance, geoBase).transform(
compose(translate(toBvr(-1.1),toBvr(-0.5),toBvr(0)),
compose(rotate(xVector3, toBvr(Math.PI/12)),
compose(rotate(yVector3, toBvr(Math.PI/4)),
scale3(toBvr(0.6))))));
In order to use the geometry in the scene, convert the geometry
to an image. Here, define a helper method that takes any geometry,
and the upper right corner of the scene. It then return a rendered and
scaled image. |
private ImageBvr geometryImage(GeometryBvr geo, Point2Bvr UR) {
CameraBvr camera =
perspectiveCamera(toBvr(1),toBvr(0))
.transform(translate(toBvr(0), toBvr(0), toBvr(2)));
NumberBvr scaleFactor = (NumberBvr)
cond(lte(UR.getX(), UR.getY()), UR.getX(), UR.getY());
return geo.render(camera).transform(scale2(mul(toBvr(2.8), scaleFactor)));
}
Overlay all of the rendered geometry images over the image composed of
all the sprites. |
ImageBvr composite =
overlay(geometryImage(gull, imageUR),
overlay(geometryImage(sailBoat.getGeo(windSpeed, geoBase), imageUR),
overlay(geometryImage(vane, imageUR), allSprites.getImageBvr())));
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.