2010 October 12 / j|d|a|v|i|s|@|c|a|r|l|e|t|o|n|.|e|d|u

Body3DJr

Inherits from Body3D. A three-dimensional solid with a prescribed overall color and/or texture. Usually you make a solid using one of the specific constructor functions (makeSphere, etc.).

__init__(self, mesh)

Initializes the solid with the given 3D mesh of vertices, texture coordinates, and normals.

setColor(self, color)

Sets the shape's color to the given RGB value. That is, color should be a 3-tuple or 3-list of floats between 0.0 and 1.0, indicating the red, green, and blue. Opacity is not supported. The default is white, (1.0, 1.0, 1.0).

getColor(self)

Returns the color as an RGB tuple.

addColor(self, delta)

Adds the given RGB color tuple to the shape's color.

setTexture(self, texture)

Sets the shape's texture to the given Texture object (or None). The default is None.

getTexture(self)

Returns the shape's Texture object (or None).

Constructor Functions

makeSphere(radius, numSides=32, numLayers=16)

Returns a Body3DJr object that is a sphere of the given radius. The remaining parameters control the quality of the model. The position of the Body3DJr indicates the center of the sphere.

makeEllipsoid(a, b, c, numSides=32, numLayers=16)

Returns a Body3DJr object that is an ellipsoid of radii a, b, c in the x-, y-, z-directions, respectively. The remaining parameters control the quality of the model. The position of the Body3DJr indicates the center of the ellipsoid.

makeBox(width, height, depth, numWide=1, numHigh=1, numDeep=1)

Returns a Body3DJr object that is a width x height x depth box. The remaining parameters control the quality of the model. The position of the Body3DJr indicates the center of the box.

makeCylinder(height, radius, numSides=32, numLayers=1, numAnnuli=1)

Returns a Body3DJr object that is a cylinder of the given height and radius. The ends of the cylinder are capped with disks. The remaining parameters control the quality of the model. The position of the Body3DJr indicates the center of the cylinder.

makeCapsule(height, radius, numSides=32, numLayers=1, numAnnuli=8)

Returns a Body3DJr object that is a capsule of the given height and radius. Specifically, height is the height of the cylindrical part of the capsule; the radius is the radius of the cylindrical part and of the hemispherical caps. The total height of the capsule is therefore height + 2.0 * radius. The remaining parameters control the quality of the model. The position of the Body3DJr indicates the center of the capsule.

makeCone(height, radius, numSides=32, numLayers=1, numAnnuli=1)

Returns a Body3DJr object that is a cone of the given height and radius. The end of the cone is capped with a disk. The remaining parameters control the quality of the model. The cone points up in the z-direction. The position of the Body3DJr indicates the center of mass of the cone; this is 2^(-1/3) ~ 0.7937 of the way down the cone.

makeAxes(length, radius)

Returns a triple of Body3DJrs. Each solid is a cylinder of the given length and radius. The cylinders point in the directions of the x-, y-, and z-axes, and are color-coded red, green, and blue.

makeLandscape(width, height, elevations)

Returns a pair (triangles, vertices, texCoords, normals) that can be used to build a 3D triangular mesh of a surface based on elevations. The surface's shadow in the x-y-plane is width x height. elevations is a 2D array of floats indicating the elevation of the surface above the x-y-plane at even spacings.