Hallo,
ich lerne neu Java Programmierung.
Deswegen habe ich diese kleine folgende Frage dazu:
Ich muss mehrere Punkte aus verschiedenen 3 Komponenten (x, y, z) Werten erzeugen.
z.B.: von (1, 2, 3) und (2, 4, 6) muss ich 2 Punkte in Java zeichnen.
Hat jemand Idee dafür?
Wenn jemand mir dabei helfen kann, bin ich sehr dankbar dafür.
Gruß
Angelo
Programmieren - alles kontrollieren 4.934 Themen, 20.613 Beiträge
Hallo wieder,
ich habe ein Beispiel Programm gefunden und weiter bearbeitet.
Aber ich kriege, nur schwarze Fläche, ohne Punkte.
Hat jemand Idee dafür, wie ich es weiter lösen kann.
Gruß
Angelo
Das letzte bearbeitete Programm:
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import javax.media.j3d.Appearance;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Material;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3f;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.SimpleUniverse;
// HelloJava3Da renders a single, rotating cube.
public class HelloJava3Da extends Applet {
/**
* The generated serialVersionUID.
*/
private static final long serialVersionUID = -8652165991244123757L;
public static void main(final String[] args) {
new MainFrame(new HelloJava3Da(), 256, 256);
} // end of main (method of HelloJava3Da)
public HelloJava3Da() {
this.setLayout(new BorderLayout());
final GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();
final Canvas3D canvas3D = new Canvas3D(config);
this.add("Center", canvas3D);
final BranchGroup scene = this.createSceneGraph();
// SimpleUniverse is a Convenience Utility class
final SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
} // end of HelloJava3Da (constructor)
// The following allows this to be run as an application
// as well as an applet
Appearance createAppearance() {
final Appearance appear = new Appearance();
final Material material = new Material();
// material.setDiffuseColor(0.0f, 0.0f, 1.0f);
material.setShininess(50.0f);
// make modifications to default material properties
appear.setMaterial(material);
// ColoringAttributes colorAtt = new ColoringAttributes();
// colorAtt.setShadeModel(ColoringAttributes.SHADE_FLAT);
// appear.setColoringAttributes(colorAtt);
return appear;
}
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
final BranchGroup objRoot = new BranchGroup();
final Transform3D zTrans = new Transform3D();
zTrans.set(new Vector3f(1f, 2f, 1.3f)); // -------------------------------
// POSITION 1
final TransformGroup objTrans = new TransformGroup(zTrans);
objTrans.addChild(new Sphere(0.9f, Primitive.GENERATE_NORMALS, this
.createAppearance()));
final Transform3D zTrans2 = new Transform3D();
zTrans.set(new Vector3f(3f, 3f, 4f)); // -------------------------------
// POSITION 2
final TransformGroup objTrans2 = new TransformGroup(zTrans2);
objTrans2.addChild(new Sphere(0.9f, Primitive.GENERATE_NORMALS, this
.createAppearance()));
objRoot.addChild(objTrans);
objRoot.addChild(objTrans2);
return objRoot;
} // end of CreateSceneGraph method of HelloJava3Da
} // end of class HelloJava3Da