/** * Creates a frustum like prism with elliptical base rather than circular. * The major axis is equivalent to the radius specified and the minor axis * is computed from the eccentricity. * * @param sides Integer number of sides to the prism. * @param radiusTop Double the radius of the top. * @param radiusBase Double the radius of the base. * @param eccentricity Double the eccentricity of the ellipse. * @param height Double the height of the prism. * @param createVBOs Boolean If true, the VBOs are created immediately. */ public NPrism(int sides, double radiusTop, double radiusBase, double eccentricity, double height, boolean createVBOs) { if (sides < 3) throw new IllegalArgumentException("Prisms must have at least 3 sides!"); if ((eccentricity < 0) || (eccentricity >= 1)) throw new IllegalArgumentException("Eccentricity must be in the range [0,1)"); mSideCount = sides; mEccentricity = eccentricity; mRadiusTop = radiusTop; mMinorTop = calculateMinorAxis(mRadiusTop); mRadiusBase = radiusBase; mMinorBase = calculateMinorAxis(mRadiusBase); mHeight = height; init(createVBOs); }
addChild(xAxis); final NPrism xTip = new NPrism(8, 0, 0.1f, 0.25f); xTip.setMaterial(material); xTip.setColor(0xffff0000); // Red xTip.rotate(Vector3.Axis.Z, 90.0); xTip.setPosition(0.875f, 0, 0); addChild(xTip); addChild(yAxis); final NPrism yTip = new NPrism(8, 0, 0.1f, 0.25f); yTip.setMaterial(material); yTip.setColor(0xff00ff00); // Green yTip.setPosition(0, 0.875f, 0); addChild(yTip); addChild(zAxis); final NPrism zTip = new NPrism(8, 0, 0.1f, 0.25f); zTip.setMaterial(material); zTip.setColor(0xff0000ff); // Blue zTip.rotate(Vector3.Axis.X, -90.0); zTip.setPosition(0, 0, 0.875f); addChild(zTip);
setIndices(triangle); vertex0.x = mRadiusTop * Math.cos(angle0 + side * angle_delta); vertex0.y = mHeight/2.0; setIndices(triangle); vertex0.x = vertex2.x; vertex0.y = vertex2.y; setIndices(triangle); vertex0.x = mRadiusTop * Math.cos(angle0 + side * angle_delta); vertex0.y = mHeight / 2.0; setIndices(triangle); vertex0.x = mRadiusBase * Math.cos(angle0 + side * angle_delta); vertex0.y = -mHeight / 2.0; setData(vertices, normals, texture, colors, indices, createVBOs);
setIndices(triangle); vertex0.x = mRadiusTop * Math.cos(angle0 + side * angle_delta); vertex0.y = mHeight/2.0; setIndices(triangle); vertex0.x = vertex2.x; vertex0.y = vertex2.y; setIndices(triangle); vertex0.x = mRadiusTop * Math.cos(angle0 + side * angle_delta); vertex0.y = mHeight / 2.0; setIndices(triangle); vertex0.x = mRadiusBase * Math.cos(angle0 + side * angle_delta); vertex0.y = -mHeight / 2.0; setData(vertices, normals, texture, colors, indices, createVBOs);
/** * Creates a frustum like prism with elliptical base rather than circular. * The major axis is equivalent to the radius specified and the minor axis * is computed from the eccentricity. * * @param sides Integer number of sides to the prism. * @param radiusTop Double the radius of the top. * @param radiusBase Double the radius of the base. * @param eccentricity Double the eccentricity of the ellipse. * @param height Double the height of the prism. * @param createVBOs Boolean If true, the VBOs are created immediately. */ public NPrism(int sides, double radiusTop, double radiusBase, double eccentricity, double height, boolean createVBOs) { if (sides < 3) throw new IllegalArgumentException("Prisms must have at least 3 sides!"); if ((eccentricity < 0) || (eccentricity >= 1)) throw new IllegalArgumentException("Eccentricity must be in the range [0,1)"); mSideCount = sides; mEccentricity = eccentricity; mRadiusTop = radiusTop; mMinorTop = calculateMinorAxis(mRadiusTop); mRadiusBase = radiusBase; mMinorBase = calculateMinorAxis(mRadiusBase); mHeight = height; init(createVBOs); }