Previous Topic Tutorial Home Page Next Topic
Construct an Image of a Textured Rotating Fan


Constructs the image of a rotating two-bladed fan, and textures the given image on all of its four faces.
public ImageBvr textureOnFan(ImageBvr unitImForTexture) {

quad is [-1,+1]x[-1,+1] with texture coordinates [0,1]x[0,1]
GeometryBvr faceObj = importGeometry(buildURL(_geoBase,"quad.x"));

Replicate to give a textured backside as well.
faceObj = union(faceObj,
faceObj.transform(rotate(yVector3, toBvr(Math.PI))));

Replicate both sides with a 90 degree rotation to make a fan.
faceObj = union(faceObj,
faceObj.transform(rotate(yVector3, toBvr(Math.PI/2))));

construct a rotation around the Y axis
Transform3Bvr xf = rotate(yVector3, mul(localTime, toBvr(0.4)));

construct a rotating fan with the texture
faceObj = faceObj.texture(unitImForTexture).transform(xf);

construct a camera with projection point at 3 and near plane at 2
CameraBvr cam = perspectiveCamera(toBvr(3),toBvr(2));

use a light and obtain an image
GeometryBvr geoWithLight = union(faceObj, directionalLight);
ImageBvr im = geoWithLight.render(cam);

return im.transform(compose(translate(0.5, 0.5),
scale2(0.4)));
}


© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

Previous Topic Tutorial Home Page Next Topic