> Hi.
> I am an aerospace student at RMIT University(Australia). I am trying to
draw
> the orbital path of an asteroid on the Canvas3D object. I have noticed
that
> the Java2D API has classes for elliptical objects, but Java3D hasn't. is
> there any way that an ellipse can be drawn in a Java3D canvas?
>
> thanks,
> EK
The following is a scrap of code that renders an ellipse as a Shape3D in
Java3D using a line array.
It is rendered on the X-Z plane. Just change the point assignment to render
to a different plane or
transform it with a rotation.
-Pedro
Shape3D buildEllipse(double semiMajorAxis, double semiMinorAxis, Color3f
color)
{
// build geometry
int totalLines = 50;
int totalPoints = totalLines * 2;
double tInc = 1.0 / (double) totalLines;
Point3d p0 = new Point3d();
Point3d p1 = new Point3d();
LineArray lineArray = new LineArray(totalPoints, LineArray.COORDINATES);
double t = 0.0;
int lineIndex = 0;
for ( int i = 0; i < totalLines; i++ )
{
p0.x = semiMinorAxis * Math.cos(2.0 * Math.PI * t);
p0.y = 0.0;
p0.z = semiMajorAxis * Math.sin(2.0 * Math.PI * t);
lineArray.setCoordinate(lineIndex++, p0);
p1.x = semiMinorAxis * Math.cos(2.0 * Math.PI * (t+tInc));
p1.y = 0.0;
p1.z = semiMajorAxis * Math.sin(2.0 * Math.PI * (t+tInc));
lineArray.setCoordinate(lineIndex++, p1);
t += tInc;
}
// build appearance
Appearance appearance = new Appearance();
LineAttributes lineAttrib = new LineAttributes(2.0f,
LineAttributes.PATTERN_SOLID, true);
appearance.setLineAttributes( lineAttrib );
ColoringAttributes colorAttributes = new ColoringAttributes(color,
ColoringAttributes.SHADE_FLAT);
appearance.setColoringAttributes( colorAttributes );
RenderingAttributes renderAttrib = new RenderingAttributes();
renderAttrib.setDepthBufferEnable(false);
renderAttrib.setDepthBufferWriteEnable(false);
appearance.setRenderingAttributes(renderAttrib);
// synthesize the object
Shape3D ellipse = new Shape3D(lineArray, appearance);
return ellipse;
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".